diff options
author | 2023-01-07 14:26:55 +0100 | |
---|---|---|
committer | 2023-03-01 00:31:08 +0100 | |
commit | 76595b7aedd2a14aea8569b75fabe62120f93230 (patch) | |
tree | 5b94ff5b348a57347066e97f1bac8dda1d716b80 /macros/src/codegen/init.rs | |
parent | b054e871d486e8eb35e3c98a73652640238c5e7d (diff) | |
download | rtic-76595b7aedd2a14aea8569b75fabe62120f93230.tar.gz rtic-76595b7aedd2a14aea8569b75fabe62120f93230.tar.zst rtic-76595b7aedd2a14aea8569b75fabe62120f93230.zip |
All codegen is now explicit
Diffstat (limited to 'macros/src/codegen/init.rs')
-rw-r--r-- | macros/src/codegen/init.rs | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index 3b2bcd47..6e1059f7 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -7,21 +7,8 @@ use crate::{ syntax::{ast::App, Context}, }; -type CodegenResult = ( - // mod_app_idle -- the `${init}Resources` constructor - Option<TokenStream2>, - // root_init -- items that must be placed in the root of the crate: - // - the `${init}Locals` struct - // - the `${init}Resources` struct - // - the `${init}LateResources` struct - // - the `${init}` module, which contains types like `${init}::Context` - Vec<TokenStream2>, - // user_init -- the `#[init]` function written by the user - TokenStream2, -); - /// Generates support code for `#[init]` functions -pub fn codegen(app: &App, analysis: &Analysis) -> CodegenResult { +pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { let init = &app.init; let name = &init.name; @@ -98,5 +85,11 @@ pub fn codegen(app: &App, analysis: &Analysis) -> CodegenResult { root_init.push(module::codegen(Context::Init, app, analysis)); - (mod_app, root_init, user_init) + quote!( + #mod_app + + #(#root_init)* + + #user_init + ) } |