mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
Bug 1066233 - Part 2: Emitter support for ES6 ClassExpressions. (r=jorendorff)
This commit is contained in:
parent
4c1796a8f6
commit
9a04835fc4
@ -6949,11 +6949,8 @@ EmitClass(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
ClassNames *names = classNode.names();
|
||||
|
||||
ParseNode *heritageExpression = classNode.heritage();
|
||||
LexicalScopeNode *innerBlock = classNode.scope();
|
||||
|
||||
ParseNode *classMethods = innerBlock->pn_expr;
|
||||
MOZ_ASSERT(classMethods->isKind(PNK_CLASSMETHODLIST));
|
||||
|
||||
ParseNode *classMethods = classNode.methodList();
|
||||
ParseNode *constructor = nullptr;
|
||||
for (ParseNode *mn = classMethods->pn_head; mn; mn = mn->pn_next) {
|
||||
ClassMethod &method = mn->as<ClassMethod>();
|
||||
@ -6970,8 +6967,10 @@ EmitClass(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
bool savedStrictness = bce->sc->setLocalStrictMode(true);
|
||||
|
||||
StmtInfoBCE stmtInfo(cx);
|
||||
if (!EnterBlockScope(cx, bce, &stmtInfo, innerBlock->pn_objbox, JSOP_UNINITIALIZED))
|
||||
return false;
|
||||
if (names) {
|
||||
if (!EnterBlockScope(cx, bce, &stmtInfo, classNode.scopeObject(), JSOP_UNINITIALIZED))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (heritageExpression) {
|
||||
if (!EmitTree(cx, bce, heritageExpression))
|
||||
@ -7009,20 +7008,28 @@ EmitClass(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
if (Emit1(cx, bce, JSOP_POP) < 0)
|
||||
return false;
|
||||
|
||||
// That DEFCONST is never gonna be used, but use it here for logical consistency.
|
||||
ParseNode *innerName = names->innerBinding();
|
||||
if (!EmitLexicalInitialization(cx, bce, innerName, JSOP_DEFCONST))
|
||||
return false;
|
||||
bool shouldPopResult = false;
|
||||
if (names) {
|
||||
// That DEFCONST is never gonna be used, but use it here for logical consistency.
|
||||
ParseNode *innerName = names->innerBinding();
|
||||
if (!EmitLexicalInitialization(cx, bce, innerName, JSOP_DEFCONST))
|
||||
return false;
|
||||
|
||||
if (!LeaveNestedScope(cx, bce, &stmtInfo))
|
||||
return false;
|
||||
if (!LeaveNestedScope(cx, bce, &stmtInfo))
|
||||
return false;
|
||||
|
||||
ParseNode *outerName = names->outerBinding();
|
||||
if (!EmitLexicalInitialization(cx, bce, outerName, JSOP_DEFVAR))
|
||||
return false;
|
||||
ParseNode *outerName = names->outerBinding();
|
||||
if (outerName) {
|
||||
if (!EmitLexicalInitialization(cx, bce, outerName, JSOP_DEFVAR))
|
||||
return false;
|
||||
shouldPopResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Emit1(cx, bce, JSOP_POP) < 0)
|
||||
return false;
|
||||
if (shouldPopResult) {
|
||||
if (Emit1(cx, bce, JSOP_POP) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_TRUE(bce->sc->setLocalStrictMode(savedStrictness));
|
||||
|
||||
|
@ -1408,8 +1408,18 @@ struct ClassNode : public TernaryNode {
|
||||
ParseNode *heritage() const {
|
||||
return pn_kid2;
|
||||
}
|
||||
LexicalScopeNode *scope() const {
|
||||
return &pn_kid3->as<LexicalScopeNode>();
|
||||
ParseNode *methodList() const {
|
||||
if (pn_kid3->isKind(PNK_CLASSMETHODLIST))
|
||||
return pn_kid3;
|
||||
|
||||
MOZ_ASSERT(pn_kid3->is<LexicalScopeNode>());
|
||||
ParseNode *list = pn_kid3->pn_expr;
|
||||
MOZ_ASSERT(list->isKind(PNK_CLASSMETHODLIST));
|
||||
return list;
|
||||
}
|
||||
ObjectBox *scopeObject() const {
|
||||
MOZ_ASSERT(pn_kid3->is<LexicalScopeNode>());
|
||||
return pn_kid3->pn_objbox;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user