aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/post_init.rs
blob: 9268e040f1ea398e05b169ac521253854924077d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use rtic_syntax::ast::App;

use crate::{analyze::Analysis, codegen::util};

/// Generates code that runs after `#[init]` returns
pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
    let mut stmts = vec![];

    // Initialize late resources
    if !analysis.late_resources.is_empty() {
        // BTreeSet wrapped in a vector
        for name in analysis.late_resources.first().unwrap() {
            let mangled_name = util::mangle_ident(&name);
            // If it's live
            let cfgs = app.late_resources[name].cfgs.clone();
            if analysis.locations.get(name).is_some() {
                // Need to also include the cfgs
                stmts.push(quote!(
                #(#cfgs)*
                #mangled_name.as_mut_ptr().write(late.#name);
                ));
            }
        }
    }

    for (monotonic, _) in app.monotonics.iter() {
        stmts.push(quote!(#monotonic::reset();));
    }

    // Forget the monotonics so they won't be dropped.
    stmts.push(quote!(core::mem::forget(monotonics);));

    // Enable the interrupts -- this completes the `init`-ialization phase
    stmts.push(quote!(rtic::export::interrupt::enable();));

    stmts
}
able'>jarred/wip-more-reliable Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-07-04Update __global.zigGravatar Jarred Sumner 1-4/+4
2022-07-04[jsc] Make JSC own the memory for source code stringsGravatar Jarred Sumner 2-19/+40