refactor: 哈希表存储属性以支持无上限属性个数

This commit is contained in:
爱特每羊队
2026-06-07 15:25:47 +08:00
parent 52fbd3c3d4
commit f6e635cdbe
19 changed files with 779 additions and 599 deletions
+6 -3
View File
@@ -204,7 +204,7 @@ impl Compiler {
ctx.alloc_reg();
ctx.projected_pc += 1;
ctx.alloc_reg();
ctx.projected_pc += 3;
ctx.projected_pc += 5; // LOAD_VAR + IC_GET_PROP + 3 ext words
}
_ => {
self.count_expression(&call.callee, ctx);
@@ -229,7 +229,9 @@ impl Compiler {
ctx.projected_pc += 1;
}
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_CONST key
ctx.projected_pc += 1; // IC_SET_PROP or COMPOUND_MEMBER_*
ctx.projected_pc += 3; // 3 IC ext words
} else if let oxide_parser::AssignmentTarget::ComputedMemberExpression(member) =
&assign.left
{
@@ -319,7 +321,7 @@ impl Compiler {
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_CONST key
ctx.projected_pc += 1; // IC_GET_PROP
ctx.projected_pc += 1; // IC ext word
ctx.projected_pc += 3; // 3 IC ext words
}
Expression::ComputedMemberExpression(member) => {
self.count_expression(&member.object, ctx);
@@ -340,7 +342,8 @@ impl Compiler {
ctx.alloc_reg();
ctx.projected_pc += 1;
ctx.alloc_reg();
ctx.projected_pc += 1;
ctx.projected_pc += 1; // MEMBER_INC/MEMBER_DEC opcode
ctx.projected_pc += 3; // 3 IC ext words
}
SimpleAssignmentTarget::ComputedMemberExpression(member) => {
self.count_expression(&member.object, ctx);
+10
View File
@@ -525,6 +525,8 @@ impl Compiler {
));
ctx.emit(opcode::encode(OpCode::IC_GET_PROP, 0, obj_reg, key_reg));
ctx.emit(0);
ctx.emit(0);
ctx.emit(0);
Ok(obj_reg)
}
Expression::ComputedMemberExpression(member) => {
@@ -618,6 +620,8 @@ impl Compiler {
};
ctx.emit(opcode::encode(op, obj_reg, val_reg, key_reg));
ctx.emit(0);
ctx.emit(0);
ctx.emit(0);
Ok(val_reg)
} else {
ctx.emit(opcode::encode(
@@ -627,6 +631,8 @@ impl Compiler {
key_reg,
));
ctx.emit(0);
ctx.emit(0);
ctx.emit(0);
Ok(val_reg)
}
} else if let oxide_parser::AssignmentTarget::ComputedMemberExpression(member) =
@@ -716,6 +722,8 @@ impl Compiler {
};
ctx.emit(opcode::encode(op, obj_reg, val_reg, key_reg));
ctx.emit(0);
ctx.emit(0);
ctx.emit(0);
Ok(val_reg)
}
SimpleAssignmentTarget::ComputedMemberExpression(member) => {
@@ -755,6 +763,8 @@ impl Compiler {
ctx.emit(opcode::encode(OpCode::LOAD_VAR, callee_reg, obj_reg, 0));
ctx.emit(opcode::encode(OpCode::IC_GET_PROP, 0, callee_reg, key_reg));
ctx.emit(0);
ctx.emit(0);
ctx.emit(0);
(callee_reg, obj_reg)
}
_ => {