mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
parent
1031b1fc43
commit
f374ab472d
1 changed files with 41 additions and 35 deletions
|
|
@ -7615,11 +7615,43 @@ BytecodeEmitter::emitPropertyList(ListNode* obj, PropertyEmitter& pe, PropListTy
|
||||||
{
|
{
|
||||||
// [stack] CTOR? OBJ
|
// [stack] CTOR? OBJ
|
||||||
|
|
||||||
|
size_t curFieldKeyIndex = 0;
|
||||||
for (ParseNode* propdef : obj->contents()) {
|
for (ParseNode* propdef : obj->contents()) {
|
||||||
if (propdef->is<ClassField>()) {
|
if (propdef->is<ClassField>()) {
|
||||||
// Skip over class fields and emit them at the end. This is needed
|
MOZ_ASSERT(type == ClassBody);
|
||||||
// because they're all emitted into a single array, which is then stored
|
// Only handle computing field keys here: the .initializers lambda array
|
||||||
// into a local variable
|
// is created elsewhere.
|
||||||
|
ClassField* field = &propdef->as<ClassField>();
|
||||||
|
if (field->name().getKind() == PNK_COMPUTED_NAME) {
|
||||||
|
if (!emitGetName(cx->names().dotFieldKeys)) {
|
||||||
|
// [stack] CTOR? OBJ ARRAY
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseNode* nameExpr = field->name().as<UnaryNode>().kid();
|
||||||
|
|
||||||
|
if (!emitTree(nameExpr)) {
|
||||||
|
// [stack] ARRAY KEY
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!emit1(JSOP_TOID)) {
|
||||||
|
// [stack] ARRAY KEY
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!emitUint32Operand(JSOP_INITELEM_ARRAY, curFieldKeyIndex)) {
|
||||||
|
// [stack] ARRAY
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!emit1(JSOP_POP)) {
|
||||||
|
// [stack] CTOR? OBJ
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
curFieldKeyIndex++;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7903,7 +7935,8 @@ BytecodeEmitter::setupFieldInitializers(ListNode* classMembers)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// BytecodeEmitter::emitCreateFieldKeys does `let .fieldKeys = [keyExpr, ...];`
|
// BytecodeEmitter::emitCreateFieldKeys does `let .fieldKeys = [...];`
|
||||||
|
// BytecodeEmitter::emitPropertyList fills in the elements of the array.
|
||||||
// See Parser::fieldInitializer for the `this[.fieldKeys[0]]` part.
|
// See Parser::fieldInitializer for the `this[.fieldKeys[0]]` part.
|
||||||
bool
|
bool
|
||||||
BytecodeEmitter::emitCreateFieldKeys(ListNode* obj)
|
BytecodeEmitter::emitCreateFieldKeys(ListNode* obj)
|
||||||
|
|
@ -7931,34 +7964,6 @@ BytecodeEmitter::emitCreateFieldKeys(ListNode* obj)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t curFieldKeyIndex = 0;
|
|
||||||
for (ParseNode* propdef : obj->contents()) {
|
|
||||||
if (propdef->is<ClassField>()) {
|
|
||||||
ClassField* field = &propdef->as<ClassField>();
|
|
||||||
if (field->name().getKind() == PNK_COMPUTED_NAME) {
|
|
||||||
ParseNode* nameExpr = field->name().as<UnaryNode>().kid();
|
|
||||||
|
|
||||||
if (!emitTree(nameExpr)) {
|
|
||||||
// [stack] ARRAY KEY
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!emit1(JSOP_TOID)) {
|
|
||||||
// [stack] ARRAY KEY
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!emitUint32Operand(JSOP_INITELEM_ARRAY, curFieldKeyIndex)) {
|
|
||||||
// [stack] ARRAY
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
curFieldKeyIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(curFieldKeyIndex == numFieldKeys);
|
|
||||||
|
|
||||||
if (!noe.emitAssignment()) {
|
if (!noe.emitAssignment()) {
|
||||||
// [stack] ARRAY
|
// [stack] ARRAY
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -8690,14 +8695,15 @@ BytecodeEmitter::emitClass(ClassNode* classNode)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!emitCreateFieldKeys(classMembers))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!emitPropertyList(classMembers, ce, ClassBody)) {
|
if (!emitPropertyList(classMembers, ce, ClassBody)) {
|
||||||
// [stack] CTOR HOMEOBJ
|
// [stack] CTOR HOMEOBJ
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!emitCreateFieldKeys(classMembers))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!ce.emitEnd(kind)) {
|
if (!ce.emitEnd(kind)) {
|
||||||
// [stack] # class declaration
|
// [stack] # class declaration
|
||||||
// [stack]
|
// [stack]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue