feat: 解构模式语义补齐(REST 枚举/getter/computed 排除、IteratorClose、RegAlloc def 干涉、for-in 捕获遮蔽)
This commit is contained in:
@@ -301,8 +301,11 @@ impl Inst {
|
||||
// for-in/of 迭代器:INIT 读 a;NEXT/DONE 读迭代器栈隐式状态
|
||||
OpCode::FOR_IN_INIT | OpCode::FOR_OF_INIT => push_operand(&mut uses, &self.a),
|
||||
OpCode::FOR_IN_NEXT | OpCode::FOR_IN_DONE | OpCode::FOR_OF_NEXT | OpCode::FOR_OF_DONE => {}
|
||||
// REST_OBJECT:读 a(ext 是 excluded_idx 常量)
|
||||
OpCode::REST_OBJECT => push_operand(&mut uses, &self.a),
|
||||
// REST_OBJECT:读 a(src)与可选 b(运行时 excluded 数组),ext 是 excluded_idx 常量
|
||||
OpCode::REST_OBJECT => {
|
||||
push_operand(&mut uses, &self.a);
|
||||
push_operand(&mut uses, &self.b);
|
||||
}
|
||||
// SPREAD_OBJECT:原地改目标对象,读目标(rd)与源(a)
|
||||
OpCode::SPREAD_OBJECT => {
|
||||
push_operand(&mut uses, &self.rd);
|
||||
|
||||
@@ -203,8 +203,10 @@ impl Inst {
|
||||
}
|
||||
|
||||
/// 对象 rest 展开:`{...src, 排除 excluded_idx 常量列出的键}` 存入 `rest`。
|
||||
pub fn rest_object(rest: Operand, src: Operand, excluded_idx: u32) -> Self {
|
||||
Self::with_ext(OpCode::REST_OBJECT, rest, src, Operand::None, &[excluded_idx])
|
||||
/// `excl_arr` 为可选运行时 excluded 键数组寄存器(computed key 求值结果),
|
||||
/// None 时仅用编译期 excluded_idx 常量。
|
||||
pub fn rest_object(rest: Operand, src: Operand, excluded_idx: u32, excl_arr: Option<Operand>) -> Self {
|
||||
Self::with_ext(OpCode::REST_OBJECT, rest, src, excl_arr.unwrap_or(Operand::None), &[excluded_idx])
|
||||
}
|
||||
|
||||
/// 对象字面量 spread 展开:把源 `src` 的可枚举自有属性写入目标对象 `rd`(原地改)。
|
||||
|
||||
Reference in New Issue
Block a user