summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/BytecodeEmitter.h
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-20 12:40:00 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-20 12:40:00 +0100
commit2a57d73c3b5304be3f9be51018a1bbee79f007e2 (patch)
tree90bd70148cd2ee939092d6e70bd618ab5df914b1 /js/src/frontend/BytecodeEmitter.h
parentcaa2a53c402c7b509e9939e9aefe595dc0dbe516 (diff)
downloadUXP-2a57d73c3b5304be3f9be51018a1bbee79f007e2.tar
UXP-2a57d73c3b5304be3f9be51018a1bbee79f007e2.tar.gz
UXP-2a57d73c3b5304be3f9be51018a1bbee79f007e2.tar.lz
UXP-2a57d73c3b5304be3f9be51018a1bbee79f007e2.tar.xz
UXP-2a57d73c3b5304be3f9be51018a1bbee79f007e2.zip
Bug 1204028: Evaluate LHS reference before RHS in destructuring
Issue #73 [Depends on] Bug 1147371: Implement IteratorClose
Diffstat (limited to 'js/src/frontend/BytecodeEmitter.h')
-rw-r--r--js/src/frontend/BytecodeEmitter.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h
index f09b529ed..066c06672 100644
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -609,7 +609,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// Emit bytecode to put operands for a JSOP_GETELEM/CALLELEM/SETELEM/DELELEM
// opcode onto the stack in the right order. In the case of SETELEM, the
// value to be assigned must already be pushed.
- enum class EmitElemOption { Get, Set, Call, IncDec, CompoundAssign };
+ enum class EmitElemOption { Get, Set, Call, IncDec, CompoundAssign, Ref };
MOZ_MUST_USE bool emitElemOperands(ParseNode* pn, EmitElemOption opts);
MOZ_MUST_USE bool emitElemOpBase(JSOp op);
@@ -642,10 +642,18 @@ struct MOZ_STACK_CLASS BytecodeEmitter
DestructuringAssignment
};
- // emitDestructuringLHS assumes the to-be-destructured value has been pushed on
- // the stack and emits code to destructure a single lhs expression (either a
- // name or a compound []/{} expression).
- MOZ_MUST_USE bool emitDestructuringLHS(ParseNode* target, DestructuringFlavor flav);
+ // emitDestructuringLHSRef emits the lhs expression's reference.
+ // If the lhs expression is object property |OBJ.prop|, it emits |OBJ|.
+ // If it's object element |OBJ[ELEM]|, it emits |OBJ| and |ELEM|.
+ // If there's nothing to evaluate for the reference, it emits nothing.
+ // |emitted| parameter receives the number of values pushed onto the stack.
+ MOZ_MUST_USE bool emitDestructuringLHSRef(ParseNode* target, size_t* emitted);
+
+ // emitSetOrInitializeDestructuring assumes the lhs expression's reference
+ // and the to-be-destructured value has been pushed on the stack. It emits
+ // code to destructure a single lhs expression (either a name or a compound
+ // []/{} expression).
+ MOZ_MUST_USE bool emitSetOrInitializeDestructuring(ParseNode* target, DestructuringFlavor flav);
// emitDestructuringOps assumes the to-be-destructured value has been
// pushed on the stack and emits code to destructure each part of a [] or