Change so that var definitions can be a module's return value (#6504)
* Change so that var definitions can be a module's return value * Change car wheel assembly to use the new return mechanism * Add sim test * Update output * Update module docs * Add safety check to only work with modules * Fix to use updated keyword args
This commit is contained in:
@ -278,7 +278,7 @@ impl ExecutorContext {
|
||||
|
||||
let annotations = &variable_declaration.outer_attrs;
|
||||
|
||||
let memory_item = self
|
||||
let value = self
|
||||
.execute_expr(
|
||||
&variable_declaration.declaration.init,
|
||||
exec_state,
|
||||
@ -289,13 +289,14 @@ impl ExecutorContext {
|
||||
.await?;
|
||||
exec_state
|
||||
.mut_stack()
|
||||
.add(var_name.clone(), memory_item, source_range)?;
|
||||
.add(var_name.clone(), value.clone(), source_range)?;
|
||||
|
||||
// Track exports.
|
||||
if let ItemVisibility::Export = variable_declaration.visibility {
|
||||
exec_state.mod_local.module_exports.push(var_name);
|
||||
}
|
||||
last_expr = None;
|
||||
// Variable declaration can be the return value of a module.
|
||||
last_expr = matches!(body_type, BodyType::Root).then_some(value);
|
||||
}
|
||||
BodyItem::TypeDeclaration(ty) => {
|
||||
let metadata = Metadata::from(&**ty);
|
||||
|
Reference in New Issue
Block a user