Add Vm::exit_module
This does all of the routines necessary for exiting a module's execution. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -81,43 +81,3 @@ impl Object for Module {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Module method implementations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
impl Module {
|
||||
pub(crate) fn execute(vm: &mut Vm, state: FunctionState) -> FunctionResult {
|
||||
match state {
|
||||
FunctionState::Begin => {
|
||||
let this = vm.frame_stack()[0].clone();
|
||||
let value = with_obj_downcast(this.clone(), |module: &Module| {
|
||||
module.evaluated_value.clone()
|
||||
});
|
||||
|
||||
// don't evaluate this twice
|
||||
if let Some(value) = value {
|
||||
return FunctionResult::ReturnPush(value);
|
||||
}
|
||||
|
||||
vm.enter_module(this.clone());
|
||||
FunctionResult::Yield(0)
|
||||
}
|
||||
FunctionState::Resume(0) => {
|
||||
let this = vm.frame_stack()[0].clone();
|
||||
let obj = with_obj_downcast(this.clone(), |module: &Module| {
|
||||
assert_eq!(module.globals().len(), vm.globals().len());
|
||||
let obj = Obj::create();
|
||||
module
|
||||
.globals()
|
||||
.iter()
|
||||
.zip(vm.globals())
|
||||
.for_each(|(name, value)| {
|
||||
obj.borrow_mut().set_attr(name, value.clone());
|
||||
});
|
||||
obj
|
||||
});
|
||||
FunctionResult::ReturnPush(obj)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user