adapt to changes in rtfm-syntax

This commit is contained in:
Jorge Aparicio 2019-08-20 15:11:24 +02:00
parent 2f4f185778
commit 0e146f8d11
11 changed files with 28 additions and 14 deletions

View file

@ -169,9 +169,10 @@ pub fn app<'a>(app: &'a App, analysis: &Analysis) -> parse::Result<Extra<'a>> {
peripherals = if *x { Some(0) } else { None }
}
CustomArg::UInt(x) if app.args.cores != 1 => {
peripherals = if *x < u64::from(app.args.cores) {
Some(*x as u8)
CustomArg::UInt(s) if app.args.cores != 1 => {
let x = s.parse::<u8>().ok();
peripherals = if x.is_some() && x.unwrap() < app.args.cores {
Some(x.unwrap())
} else {
return Err(parse::Error::new(
k.span(),

View file

@ -126,7 +126,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
#(#root)*
#(#mod_resources)*
#mod_resources
#(#root_hardware_tasks)*

View file

@ -115,6 +115,7 @@ pub fn codegen(
let stmts = &task.stmts;
let section = util::link_section("text", core);
// XXX shouldn't this have a cfg_core?
let locals_pat = locals_pat.iter();
user_tasks.push(quote!(
#(#attrs)*
#[allow(non_snake_case)]

View file

@ -58,6 +58,7 @@ pub fn codegen(
let context = &idle.context;
let stmts = &idle.stmts;
let section = util::link_section("text", core);
let locals_pat = locals_pat.iter();
let user_idle = Some(quote!(
#(#attrs)*
#[allow(non_snake_case)]
@ -70,6 +71,7 @@ pub fn codegen(
}
));
let locals_new = locals_new.iter();
let call_idle = quote!(#name(
#(#locals_new,)*
#name::Context::new(&rtfm::export::Priority::new(0))

View file

@ -83,6 +83,7 @@ pub fn codegen(
let attrs = &init.attrs;
let stmts = &init.stmts;
let section = util::link_section("text", core);
let locals_pat = locals_pat.iter();
let user_init = Some(quote!(
#(#attrs)*
#cfg_core
@ -102,6 +103,7 @@ pub fn codegen(
const_app = Some(constructor);
}
let locals_new = locals_new.iter();
let call_init =
Some(quote!(let late = #name(#(#locals_new,)* #name::Context::new(core.into()));));

View file

@ -168,6 +168,7 @@ pub fn codegen(
let attrs = &task.attrs;
let cfgs = &task.cfgs;
let stmts = &task.stmts;
let locals_pat = locals_pat.iter();
user_tasks.push(quote!(
#(#attrs)*
#(#cfgs)*

View file

@ -3,13 +3,13 @@ use core::sync::atomic::{AtomicUsize, Ordering};
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
use rtfm_syntax::{ast::App, Context, Core};
use syn::{ArgCaptured, Attribute, Ident, IntSuffix, LitInt};
use syn::{Attribute, Ident, LitInt, PatType};
use crate::check::Extra;
/// Turns `capacity` into an unsuffixed integer literal
pub fn capacity_literal(capacity: u8) -> LitInt {
LitInt::new(u64::from(capacity), IntSuffix::None, Span::call_site())
LitInt::new(&capacity.to_string(), Span::call_site())
}
/// Turns `capacity` into a type-level (`typenum`) integer
@ -194,7 +194,7 @@ pub fn rendezvous_ident(core: Core) -> Ident {
//
// `inputs` could be &[`input: Foo`] OR &[`mut x: i32`, `ref y: i64`]
pub fn regroup_inputs(
inputs: &[ArgCaptured],
inputs: &[PatType],
) -> (
// args e.g. &[`_0`], &[`_0: i32`, `_1: i64`]
Vec<TokenStream2>,

View file

@ -1,5 +1,4 @@
#![deny(warnings)]
#![recursion_limit = "128"]
extern crate proc_macro;