1
0
forked from M-Labs/nac3

Compare commits

..

2 Commits

Author SHA1 Message Date
c94f407732 cargo fmt 2024-09-12 17:34:22 +08:00
d9ac662787 artiq: support async rpcs 2024-09-12 17:34:22 +08:00

View File

@ -863,14 +863,12 @@ impl Nac3 {
}
}
/// Retrieves the Name.id from a decorator, supports decorators with arguments.
fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
if let ExprKind::Name { id, .. } = decorator.node {
// Bare decorator
return Some(id.to_string());
} else if let ExprKind::Call { func, .. } = &decorator.node {
// Decorators that are calls (e.g. "@rpc()") have Call for the node,
// need to extract the id from within.
// decorators with flags (e.g. rpc async) have Call for the node,
// extract the id from within
if let ExprKind::Name { id, .. } = func.node {
return Some(id.to_string());
}
@ -878,11 +876,10 @@ fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
None
}
/// Retrieves flags from a decorator, if any.
fn decorator_get_flags(decorator: &Located<ExprKind>) -> Vec<Constant> {
let mut flags = vec![];
if let ExprKind::Call { keywords, .. } = &decorator.node {
for keyword in keywords {
for keyword in keywords.iter() {
if keyword.node.arg != Some("flags".into()) {
continue;
}