Add set_catch, unset_catch instructions

This commit is contained in:
Andrew Morris
2023-03-23 09:35:33 +11:00
parent 56f6ce5922
commit 337c5c5296
11 changed files with 50 additions and 14 deletions

View File

@@ -20,6 +20,12 @@ pub struct BytecodeStackFrame {
pub param_end: usize,
pub this_target: Option<usize>,
pub return_target: Option<usize>,
pub catch_setting: Option<CatchSetting>,
}
pub struct CatchSetting {
pub pos: usize,
pub register: Option<usize>,
}
impl BytecodeStackFrame {
@@ -404,6 +410,17 @@ impl StackFrameTrait for BytecodeStackFrame {
Import | ImportStar => {
panic!("TODO: Dynamic imports")
}
SetCatch => {
self.catch_setting = Some(CatchSetting {
pos: self.decoder.decode_pos(),
register: self.decoder.decode_register_index(),
});
}
UnsetCatch => {
self.catch_setting = None;
}
};
Ok(FrameStepOk::Continue)

View File

@@ -50,11 +50,12 @@ impl VsFunction {
data: self.bytecode.clone(),
pos: self.start,
},
registers: registers,
registers,
param_start: self.binds.len() + 2,
param_end: self.parameter_count + 2,
this_target: None,
return_target: None,
catch_setting: None,
});
}
}