mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
feat: class 私有成员语义(字段/方法/访问器 + brand 检查 + 契约修复)
This commit is contained in:
@@ -24,14 +24,13 @@ fn assign_ids(module: &mut CompiledModule, next_id: &mut u32) {
|
||||
if opcode::opcode(*instr) == OpCode::CREATE_CLOSURE {
|
||||
let rel = opcode::imm16(*instr) as usize;
|
||||
// rel 应为 1-based 子模块下标;0 表示无引用(异常输入),按未解析处理。
|
||||
let flat = if rel > 0 { module.sub_modules.get(rel - 1).map(|s| s.flat_id).unwrap_or(0) } else { 0 };
|
||||
let flat = if rel > 0 {
|
||||
module.sub_modules.get(rel - 1).map(|s| s.flat_id).unwrap_or(0)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let rd = opcode::rd(*instr);
|
||||
*instr = opcode::encode(
|
||||
OpCode::CREATE_CLOSURE,
|
||||
rd,
|
||||
(flat & 0xFF) as u8,
|
||||
((flat >> 8) & 0xFF) as u8,
|
||||
);
|
||||
*instr = opcode::encode(OpCode::CREATE_CLOSURE, rd, (flat & 0xFF) as u8, ((flat >> 8) & 0xFF) as u8);
|
||||
}
|
||||
}
|
||||
for sub in &mut module.sub_modules {
|
||||
|
||||
@@ -537,7 +537,10 @@ fn compile_call_spread_emits_spread_opcodes() {
|
||||
"f(...args) should emit CALL_SPREAD"
|
||||
);
|
||||
assert!(
|
||||
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::NEW_EXPRESSION_SPREAD),
|
||||
module
|
||||
.bytecode
|
||||
.iter()
|
||||
.any(|&i| opcode::opcode(i) == OpCode::NEW_EXPRESSION_SPREAD),
|
||||
"new f(...args) should emit NEW_EXPRESSION_SPREAD"
|
||||
);
|
||||
// 无 spread 的调用不发 spread 变体
|
||||
|
||||
Reference in New Issue
Block a user