feat: class 公有字段 define 语义 + computed key 类定义期求值一次

This commit is contained in:
爱特每羊队
2026-08-09 09:35:24 +08:00
parent d4fffcdcc6
commit 38abdfd9ab
15 changed files with 470 additions and 67 deletions
+3 -1
View File
@@ -65,6 +65,7 @@ impl Inst {
| OpCode::DELETE_PROP_STATIC
| OpCode::DELETE_PROP_DYNAMIC
| OpCode::DEFINE_ACCESSOR
| OpCode::DEFINE_PROP
| OpCode::SET_HOME_OBJECT
// SPILL 写 VM spill 栈而非寄存器(恢复由 UNSPILL 写 rd)
| OpCode::SPILL
@@ -256,7 +257,8 @@ impl Inst {
| OpCode::SET_PRIVATE
| OpCode::INIT_PRIVATE
| OpCode::PRIVATE_BRAND_IN
| OpCode::DEFINE_ACCESSOR => {
| OpCode::DEFINE_ACCESSOR
| OpCode::DEFINE_PROP => {
push_operand(&mut uses, &self.rd);
push_operand(&mut uses, &self.a);
push_operand(&mut uses, &self.b);
+6
View File
@@ -173,6 +173,12 @@ impl Inst {
Self::with_ext(OpCode::DEFINE_ACCESSOR, home, get, set, &[key_idx])
}
/// define 数据属性:target 为宿主对象,value/key 为寄存器。
/// 不触发原型链 setter,与 SET_PROP 语义不同。
pub fn define_prop(target: Operand, value: Operand, key: Operand) -> Self {
Self::new(OpCode::DEFINE_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])