Skip to content

Commit 5c1f4b5

Browse files
committed
Update the SimX library to use the latest syn parsing library AST nodes
1 parent fe307be commit 5c1f4b5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

simx/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use proc_macro::TokenStream;
44
use proc_macro2::Span;
55
use quote::quote;
66
use serde::{Deserialize, Serialize};
7-
use syn::{parse_macro_input, Expr, FnArg, Ident, ImplItem, ImplItemMethod, ItemImpl, Stmt};
7+
use syn::{parse_macro_input, Expr, FnArg, Ident, ImplItem, ImplItemFn, ItemImpl, Stmt};
88

99
const EVENTS_INT_EXPRESSION: &str = "events_int";
1010
const EVENTS_EXT_EXPRESSION: &str = "events_ext";
@@ -55,7 +55,7 @@ fn model_implementation(item: &ItemImpl) -> Option<ModelImplementation> {
5555
}
5656
}
5757

58-
fn get_method_args(method: &ImplItemMethod) -> Vec<String> {
58+
fn get_method_args(method: &ImplItemFn) -> Vec<String> {
5959
method
6060
.sig
6161
.inputs
@@ -70,13 +70,13 @@ fn get_method_args(method: &ImplItemMethod) -> Vec<String> {
7070
.collect()
7171
}
7272

73-
fn get_state_transitions(method: &ImplItemMethod) -> Vec<(String, String)> {
73+
fn get_state_transitions(method: &ImplItemFn) -> Vec<(String, String)> {
7474
method
7575
.block
7676
.stmts
7777
.iter()
7878
.filter_map(|stmt| match stmt {
79-
Stmt::Semi(Expr::Assign(assign), _) => {
79+
Stmt::Expr(Expr::Assign(assign), _) => {
8080
let assign_left = &assign.left;
8181
let assign_right = &assign.right;
8282
Some((
@@ -89,17 +89,17 @@ fn get_state_transitions(method: &ImplItemMethod) -> Vec<(String, String)> {
8989
.collect()
9090
}
9191

92-
fn get_schedulings(method: &ImplItemMethod) -> Option<Vec<EventEdge>> {
92+
fn get_schedulings(method: &ImplItemFn) -> Option<Vec<EventEdge>> {
9393
method.block.stmts.iter().find_map(|stmt| {
94-
if let Stmt::Expr(Expr::MethodCall(method_call)) = stmt {
94+
if let Stmt::Expr(Expr::MethodCall(method_call), _) = stmt {
9595
Some(vec![EventEdge {
9696
event_expression_target: method_call.method.to_string(),
9797
// TODO parameters
9898
parameters: Vec::new(),
9999
condition: None,
100100
delay: None,
101101
}])
102-
} else if let Stmt::Expr(Expr::Match(match_)) = stmt {
102+
} else if let Stmt::Expr(Expr::Match(match_), _) = stmt {
103103
Some(
104104
match_
105105
.arms
@@ -151,7 +151,7 @@ fn add_event_rules_transition_method(mut input: ItemImpl) -> TokenStream {
151151
.items
152152
.iter()
153153
.filter_map(|method| {
154-
if let ImplItem::Method(method) = method {
154+
if let ImplItem::Fn(method) = method {
155155
Some(method)
156156
} else {
157157
None
@@ -205,7 +205,7 @@ fn add_event_rules_scheduling_method(mut input: ItemImpl) -> TokenStream {
205205
.items
206206
.iter()
207207
.filter_map(|method| {
208-
if let ImplItem::Method(method) = method {
208+
if let ImplItem::Fn(method) = method {
209209
if method.sig.ident == events_int_ident {
210210
Some((DevsTransitions::Internal, method))
211211
} else if method.sig.ident == events_ext_ident {

0 commit comments

Comments
 (0)