feat: 支持 Object 成员方法

This commit is contained in:
2026-06-07 01:59:30 +08:00
parent 439b61e359
commit 9ca35d75e0
16 changed files with 568 additions and 47 deletions
+17 -4
View File
@@ -91,7 +91,7 @@ impl CompileCtx {
}
pub(crate) fn reset_regs(&mut self) {
self.next_reg = 0;
self.next_reg = self.builtin_reg_map.len() as u8;
self.projected_pc = 0;
self.label_counter = 0;
}
@@ -169,9 +169,22 @@ impl CompileCtx {
pub(crate) fn pre_register_builtins(&mut self) {
let builtins = [
"NaN", "undefined", "Object", "Array", "String", "Number", "Boolean",
"Function", "Error", "Math", "JSON", "Promise", "parseInt", "parseFloat",
"isNaN", "isFinite",
"NaN",
"undefined",
"Object",
"Array",
"String",
"Number",
"Boolean",
"Function",
"Error",
"Math",
"JSON",
"Promise",
"parseInt",
"parseFloat",
"isNaN",
"isFinite",
];
for name in &builtins {
let reg = self.alloc_reg();