зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1518391 - Part 4: Use pn_u.function.syntaxKind instead of pn_op for FunctionNode. r=jorendorff
Differential Revision: https://phabricator.services.mozilla.com/D18329 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2f0e1b5e4e
Коммит
3469b17a67
|
@ -5637,7 +5637,8 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::emitFunction(FunctionNode* funNode,
|
|||
// Non-hoisted functions simply emit their respective op.
|
||||
if (!funNode->functionIsHoisted()) {
|
||||
// JSOP_LAMBDA_ARROW is always preceded by a new.target
|
||||
MOZ_ASSERT(fun->isArrow() == (funNode->getOp() == JSOP_LAMBDA_ARROW));
|
||||
MOZ_ASSERT(fun->isArrow() ==
|
||||
(funNode->syntaxKind() == FunctionSyntaxKind::Arrow));
|
||||
if (funbox->isAsync()) {
|
||||
MOZ_ASSERT(!needsProto);
|
||||
return emitAsyncWrapper(index, funbox->needsHomeObject(), fun->isArrow(),
|
||||
|
@ -5657,13 +5658,17 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::emitFunction(FunctionNode* funNode,
|
|||
}
|
||||
|
||||
if (needsProto) {
|
||||
MOZ_ASSERT(funNode->getOp() == JSOP_LAMBDA);
|
||||
MOZ_ASSERT(funNode->syntaxKind() ==
|
||||
FunctionSyntaxKind::DerivedClassConstructor);
|
||||
return emitIndex32(JSOP_FUNWITHPROTO, index);
|
||||
}
|
||||
|
||||
// This is a FunctionExpression, ArrowFunctionExpression, or class
|
||||
// constructor. Emit the single instruction (without location info).
|
||||
return emitIndex32(funNode->getOp(), index);
|
||||
JSOp op = funNode->syntaxKind() == FunctionSyntaxKind::Arrow
|
||||
? JSOP_LAMBDA_ARROW
|
||||
: JSOP_LAMBDA;
|
||||
return emitIndex32(op, index);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!needsProto);
|
||||
|
@ -5692,7 +5697,7 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::emitFunction(FunctionNode* funNode,
|
|||
}
|
||||
} else {
|
||||
MOZ_ASSERT(sc->isGlobalContext() || sc->isEvalContext());
|
||||
MOZ_ASSERT(funNode->getOp() == JSOP_NOP);
|
||||
MOZ_ASSERT(funNode->syntaxKind() == FunctionSyntaxKind::Statement);
|
||||
MOZ_ASSERT(inPrologue());
|
||||
if (funbox->isAsync()) {
|
||||
if (!emitAsyncWrapper(index, fun->isMethod(), fun->isArrow(),
|
||||
|
|
|
@ -776,7 +776,7 @@ class FullParseHandler {
|
|||
public:
|
||||
FunctionNodeType newFunction(FunctionSyntaxKind syntaxKind,
|
||||
const TokenPos& pos) {
|
||||
return new_<FunctionNode>(syntaxKind, JSOP_NOP, pos);
|
||||
return new_<FunctionNode>(syntaxKind, pos);
|
||||
}
|
||||
|
||||
BinaryNodeType newObjectMethodOrPropertyDefinition(Node key, Node value,
|
||||
|
|
|
@ -1499,20 +1499,8 @@ inline bool ParseNode::isForLoopDeclaration() const {
|
|||
|
||||
class FunctionNode : public ParseNode {
|
||||
public:
|
||||
FunctionNode(FunctionSyntaxKind syntaxKind, JSOp op, const TokenPos& pos)
|
||||
: ParseNode(ParseNodeKind::Function, op, pos) {
|
||||
MOZ_ASSERT(op == JSOP_NOP || op == JSOP_LAMBDA_ARROW || op == JSOP_LAMBDA);
|
||||
MOZ_ASSERT_IF(op == JSOP_NOP, syntaxKind == FunctionSyntaxKind::Statement);
|
||||
MOZ_ASSERT_IF(op == JSOP_LAMBDA_ARROW,
|
||||
syntaxKind == FunctionSyntaxKind::Arrow);
|
||||
MOZ_ASSERT_IF(
|
||||
op == JSOP_LAMBDA,
|
||||
syntaxKind == FunctionSyntaxKind::Statement ||
|
||||
syntaxKind == FunctionSyntaxKind::Construction ||
|
||||
syntaxKind == FunctionSyntaxKind::DerivedClassConstructor ||
|
||||
syntaxKind == FunctionSyntaxKind::Method ||
|
||||
syntaxKind == FunctionSyntaxKind::Getter ||
|
||||
syntaxKind == FunctionSyntaxKind::Setter);
|
||||
FunctionNode(FunctionSyntaxKind syntaxKind, const TokenPos& pos)
|
||||
: ParseNode(ParseNodeKind::Function, JSOP_NOP, pos) {
|
||||
MOZ_ASSERT(!pn_u.function.body);
|
||||
MOZ_ASSERT(!pn_u.function.funbox);
|
||||
MOZ_ASSERT(is<FunctionNode>());
|
||||
|
@ -1555,8 +1543,7 @@ class FunctionNode : public ParseNode {
|
|||
FunctionSyntaxKind syntaxKind() const { return pn_u.function.syntaxKind; }
|
||||
|
||||
bool functionIsHoisted() const {
|
||||
MOZ_ASSERT(isOp(JSOP_LAMBDA) || isOp(JSOP_LAMBDA_ARROW) || isOp(JSOP_NOP));
|
||||
return isOp(JSOP_NOP);
|
||||
return syntaxKind() == FunctionSyntaxKind::Statement;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче