fix(emit): catch 参数支持解构 pattern(数组/对象/默认值)
This commit is contained in:
@@ -47,11 +47,10 @@ impl Emitter {
|
|||||||
if let Some(catch) = &ts.handler {
|
if let Some(catch) = &ts.handler {
|
||||||
ctx.push_scope();
|
ctx.push_scope();
|
||||||
if let Some(param) = &catch.param {
|
if let Some(param) = &catch.param {
|
||||||
let catch_reg = ctx.alloc_reg();
|
let src_reg = ctx.alloc_reg();
|
||||||
if let oxide_parser::BindingPattern::BindingIdentifier(bi) = ¶m.pattern {
|
// 异常值在 VM 物理 regs[0](unwind 展开处写入),STORE_VAR a=None 读回。
|
||||||
ctx.declare_initialized(bi.name.as_str(), catch_reg, VariableDeclarationKind::Let, false)?;
|
ctx.inst(Inst::new(OpCode::STORE_VAR, Operand::Reg(src_reg), Operand::None, Operand::None));
|
||||||
ctx.inst(Inst::new(OpCode::STORE_VAR, Operand::Reg(catch_reg), Operand::None, Operand::None));
|
self.emit_binding_pattern(¶m.pattern, src_reg, VariableDeclarationKind::Let, false, ctx)?;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let mut last_catch_result: Option<u32> = None;
|
let mut last_catch_result: Option<u32> = None;
|
||||||
for s in &catch.body.body {
|
for s in &catch.body.body {
|
||||||
|
|||||||
Reference in New Issue
Block a user