mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 19:21:11 +08:00
fix: 脚本顶层 var/function 声明落 globalThis(DEFINE_GLOBAL_PROP 非可配置数据属性)
This commit is contained in:
@@ -66,6 +66,7 @@ impl Inst {
|
||||
| OpCode::DELETE_PROP_DYNAMIC
|
||||
| OpCode::DEFINE_ACCESSOR
|
||||
| OpCode::DEFINE_PROP
|
||||
| OpCode::DEFINE_GLOBAL_PROP
|
||||
| OpCode::SET_HOME_OBJECT
|
||||
// SPILL 写 VM spill 栈而非寄存器(恢复由 UNSPILL 写 rd)
|
||||
| OpCode::SPILL
|
||||
@@ -231,11 +232,9 @@ impl Inst {
|
||||
// HALT:隐式读 reg 0(顶层返回值)
|
||||
OpCode::HALT => uses.push(0),
|
||||
// RETURN/THROW/YIELD/YIELD_STAR/AWAIT:读 rd(None→0)
|
||||
OpCode::RETURN
|
||||
| OpCode::THROW
|
||||
| OpCode::YIELD
|
||||
| OpCode::YIELD_STAR
|
||||
| OpCode::AWAIT => push_operand(&mut uses, &self.rd),
|
||||
OpCode::RETURN | OpCode::THROW | OpCode::YIELD | OpCode::YIELD_STAR | OpCode::AWAIT => {
|
||||
push_operand(&mut uses, &self.rd)
|
||||
}
|
||||
// 加载族:a 槽是 Const/Imm 立即数,无寄存器 use
|
||||
OpCode::LOAD_CONST
|
||||
| OpCode::CREATE_CLOSURE
|
||||
@@ -264,7 +263,8 @@ impl Inst {
|
||||
| OpCode::SET_ELEM
|
||||
| OpCode::INIT_PRIVATE
|
||||
| OpCode::DEFINE_ACCESSOR
|
||||
| OpCode::DEFINE_PROP => {
|
||||
| OpCode::DEFINE_PROP
|
||||
| OpCode::DEFINE_GLOBAL_PROP => {
|
||||
push_operand(&mut uses, &self.rd);
|
||||
push_operand(&mut uses, &self.a);
|
||||
push_operand(&mut uses, &self.b);
|
||||
|
||||
@@ -197,6 +197,12 @@ impl Inst {
|
||||
Self::new(OpCode::DEFINE_PROP, target, value, key)
|
||||
}
|
||||
|
||||
/// 定义全局 var 绑定数据属性:target 为全局对象,value/key 为寄存器。
|
||||
/// 属性可写/可枚举/不可配置(脚本顶层 var/function 声明的属性描述符)。
|
||||
pub fn define_global_prop(target: Operand, value: Operand, key: Operand) -> Self {
|
||||
Self::new(OpCode::DEFINE_GLOBAL_PROP, target, value, key)
|
||||
}
|
||||
|
||||
/// 静态删除属性:obj 同时放 rd/a 槽,const_idx 为属性名常量下标。
|
||||
pub fn delete_prop_static(obj: Operand, const_idx: u32) -> Self {
|
||||
Self::with_ext(OpCode::DELETE_PROP_STATIC, obj, obj, Operand::None, &[const_idx])
|
||||
|
||||
Reference in New Issue
Block a user