forked from M-Labs/nac3
make note of subkernel id, and destination at some point
This commit is contained in:
parent
4b816d7211
commit
9a3463e027
|
@ -412,6 +412,7 @@ impl Nac3 {
|
||||||
let mut module_to_resolver_cache: HashMap<u64, _> = HashMap::new();
|
let mut module_to_resolver_cache: HashMap<u64, _> = HashMap::new();
|
||||||
|
|
||||||
let mut rpc_ids = vec![];
|
let mut rpc_ids = vec![];
|
||||||
|
let mut subkernel_ids = vec![];
|
||||||
for (stmt, path, module) in &self.top_levels {
|
for (stmt, path, module) in &self.top_levels {
|
||||||
let py_module: &PyAny = module.extract(py)?;
|
let py_module: &PyAny = module.extract(py)?;
|
||||||
let module_id: u64 = id_fn.call1((py_module,))?.extract()?;
|
let module_id: u64 = id_fn.call1((py_module,))?.extract()?;
|
||||||
|
@ -501,6 +502,8 @@ impl Nac3 {
|
||||||
.any(|decorator| decorator_id_string(decorator) == Some("subkernel".to_string()))
|
.any(|decorator| decorator_id_string(decorator) == Some("subkernel".to_string()))
|
||||||
{
|
{
|
||||||
store_fun.call1(py, (def_id.0.into_py(py), module.getattr(py, name.to_string().as_str()).unwrap())).unwrap();
|
store_fun.call1(py, (def_id.0.into_py(py), module.getattr(py, name.to_string().as_str()).unwrap())).unwrap();
|
||||||
|
let dest = decorator_list.SOMETHING;
|
||||||
|
subkernel_rpc_ids.push((None, def_id, dest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StmtKind::ClassDef { name, body, .. } => {
|
StmtKind::ClassDef { name, body, .. } => {
|
||||||
|
@ -523,6 +526,15 @@ impl Nac3 {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
rpc_ids.push((Some((class_obj.clone(), *name)), def_id, is_async));
|
rpc_ids.push((Some((class_obj.clone(), *name)), def_id, is_async));
|
||||||
|
} else if decorator_list.iter().any(|decorator| matches!(decorator.node, ExprKind::Name { id, .. } if id == "subkernel".into())) {
|
||||||
|
if name == &"__init__".into() {
|
||||||
|
return Err(CompileError::new_err(format!(
|
||||||
|
"compilation failed\n----------\nThe constructor of class {} should not be decorated with subkernel decorator (at {})",
|
||||||
|
class_name, stmt.location
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
let dest = decorator_list.iter(). // figure out what's in the decorator list
|
||||||
|
subkernel_ids.push((Some((class_obj.clone(), *name)), def_id, dest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2134,6 +2134,13 @@ impl TopLevelComposer {
|
||||||
instance_to_symbol.insert(String::new(), simple_name.to_string());
|
instance_to_symbol.insert(String::new(), simple_name.to_string());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if !decorator_list.is_empty()
|
||||||
|
&& matches!(&decorator_list[0].node,
|
||||||
|
ast::ExprKind::Name{ id, .. } if id == &"subkernel".into())
|
||||||
|
{
|
||||||
|
instance_to_symbol.insert(String::new(), simple_name.to_string());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if matches!(&decorator_list[0].node, ExprKind::Name { id, .. } if id == &"rpc".into())
|
if matches!(&decorator_list[0].node, ExprKind::Name { id, .. } if id == &"rpc".into())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue