feat: compiler/test262 runner 接线 + 模块顶层 this 绑定
- Compiler::compile_module:Emitter::emit_program_module → 统一 IR 管线(DCE/regalloc/lower/flatten) - CompiledModule.is_es_module:VM run 时模块顶层 this=undefined(脚本仍为全局对象) - 全局注册 __moduleLinkGet - test262 runner:Test262ModuleLoader(相对路径解析 + import attributes 判定 json/text/bytes),is_module 走 compile_module
This commit is contained in:
@@ -333,9 +333,14 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
// 全局代码的 this 绑定为全局对象(ECMA-262 全局执行上下文)。
|
||||
// 顶层 this:脚本为全局对象(ECMA-262 全局执行上下文);
|
||||
// ES module 顶层环境 GetThisBinding 返回 undefined。
|
||||
let global = self.session.global_object();
|
||||
self.regs[254] = JsValue::from_js_object(global.as_ptr() as *mut JsObject);
|
||||
self.regs[254] = if module.is_es_module {
|
||||
JsValue::undefined()
|
||||
} else {
|
||||
JsValue::from_js_object(global.as_ptr() as *mut JsObject)
|
||||
};
|
||||
|
||||
let result = self.dispatch();
|
||||
// 顶层执行结束后 drain 微任务队列:Promise reactions 与 thenable 委托在此执行。
|
||||
|
||||
Reference in New Issue
Block a user