fix: 修复数组长度与槽位索引截断问题

This commit is contained in:
爱特每羊队
2026-06-08 22:55:52 +08:00
parent 22cbccdf6c
commit e57e140bef
16 changed files with 242 additions and 159 deletions
+2 -13
View File
@@ -318,19 +318,8 @@ impl Compiler {
self.count_expression(expr, ctx);
}
}
// CALL_NATIVE: 1 opcode + 1 ext word; CALL(0x40): 1 opcode
let is_builtin = match &call.callee {
Expression::Identifier(ident) => ctx.is_builtin(ident.name.as_str()),
Expression::StaticMemberExpression(m) => {
if let Expression::Identifier(ident) = &m.object {
ctx.is_builtin(ident.name.as_str())
} else {
false
}
}
_ => false,
};
ctx.projected_pc += if is_builtin { 2 } else { 1 };
// CALL and CALL_NATIVE both carry 1 ext word for arg_count.
ctx.projected_pc += 2;
ctx.alloc_reg(); // result register
ctx.projected_pc += 1; // LOAD_VAR result <- regs[0]
}