feat: 支持访问器描述符与 get/set 语法

This commit is contained in:
爱特每羊队
2026-06-09 16:22:24 +08:00
parent 044c8a4303
commit ed0864d01f
13 changed files with 457 additions and 77 deletions
@@ -278,3 +278,21 @@ fn compile_class_declaration_default_constructor_creates_submodule() {
"default constructor submodule should be marked as class constructor"
);
}
#[test]
fn compile_class_instance_getter_emits_define_accessor() {
let module = compile_source("class A { get x() { return 1; } }");
assert!(
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR),
"class getter should emit DEFINE_ACCESSOR"
);
}
#[test]
fn compile_class_static_setter_emits_define_accessor() {
let module = compile_source("class A { static set x(v) { this.y = v; } }");
assert!(
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR),
"static class setter should emit DEFINE_ACCESSOR"
);
}