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)