зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1155472 - Add the ES6 grammar parametrization to all the Parser methods, so that the permissibility of |in|, |yield| as keyword, &c. is specified directly, not by inspecting instantaneous statefulness. Don't change the statefulness yet, tho -- stop relying on it (where appropriate) in a later patch. r=efaust
--HG-- extra : rebase_source : 2252911e0b715c50ba75507b818c7b4575bb98cc
This commit is contained in:
Родитель
fe0bc04799
Коммит
01d9f60fd0
|
@ -498,7 +498,7 @@ ParseVarOrConstStatement(AsmJSParser& parser, ParseNode** var)
|
|||
return true;
|
||||
}
|
||||
|
||||
*var = parser.statement();
|
||||
*var = parser.statement(YieldIsName);
|
||||
if (!*var)
|
||||
return false;
|
||||
|
||||
|
@ -7604,7 +7604,9 @@ ParseFunction(ModuleCompiler& m, ParseNode** fnOut)
|
|||
if (!funpc.init(tokenStream))
|
||||
return false;
|
||||
|
||||
if (!m.parser().functionArgsAndBodyGeneric(fn, fun, Normal, Statement)) {
|
||||
if (!m.parser().functionArgsAndBodyGeneric(InAllowed, YieldIsName, fn, fun, Normal,
|
||||
Statement))
|
||||
{
|
||||
if (tokenStream.hadError() || directives == newDirectives)
|
||||
return false;
|
||||
|
||||
|
@ -8182,7 +8184,7 @@ CheckModuleReturn(ModuleCompiler& m)
|
|||
return m.fail(nullptr, "invalid asm.js statement");
|
||||
}
|
||||
|
||||
ParseNode* returnStmt = m.parser().statement();
|
||||
ParseNode* returnStmt = m.parser().statement(YieldIsName);
|
||||
if (!returnStmt)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject sco
|
|||
TokenStream::Position pos(parser.keepAtoms);
|
||||
parser.tokenStream.tell(&pos);
|
||||
|
||||
ParseNode* pn = parser.statement(canHaveDirectives);
|
||||
ParseNode* pn = parser.statement(YieldIsName, canHaveDirectives);
|
||||
if (!pn) {
|
||||
if (parser.hadAbortedSyntaxParse()) {
|
||||
// Parsing inner functions lazily may lead the parser into an
|
||||
|
@ -366,7 +366,7 @@ frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject sco
|
|||
return nullptr;
|
||||
MOZ_ASSERT(parser.pc == pc.ptr());
|
||||
|
||||
pn = parser.statement();
|
||||
pn = parser.statement(YieldIsName);
|
||||
}
|
||||
if (!pn) {
|
||||
MOZ_ASSERT(!parser.hadAbortedSyntaxParse());
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -331,6 +331,13 @@ enum VarContext { HoistVars, DontHoistVars };
|
|||
enum FunctionType { Getter, Setter, Normal };
|
||||
enum PropListType { ObjectLiteral, ClassBody };
|
||||
|
||||
// Specify a value for an ES6 grammar parametrization. We have no enum for
|
||||
// [Return] because its behavior is exactly equivalent to checking whether
|
||||
// we're in a function box -- easier and simpler than passing an extra
|
||||
// parameter everywhere.
|
||||
enum YieldHandling { YieldIsName, YieldIsKeyword };
|
||||
enum InHandling { InAllowed, InProhibited };
|
||||
|
||||
template <typename ParseHandler>
|
||||
class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
||||
{
|
||||
|
@ -460,10 +467,11 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
|
||||
Node stringLiteral();
|
||||
Node noSubstitutionTemplate();
|
||||
Node templateLiteral();
|
||||
bool taggedTemplate(Node nodeList, TokenKind tt);
|
||||
Node templateLiteral(YieldHandling yieldHandling);
|
||||
bool taggedTemplate(YieldHandling yieldHandling, Node nodeList, TokenKind tt);
|
||||
bool appendToCallSiteObj(Node callSiteObj);
|
||||
bool addExprAndGetNextTemplStrToken(Node nodeList, TokenKind* ttp);
|
||||
bool addExprAndGetNextTemplStrToken(YieldHandling yieldHandling, Node nodeList,
|
||||
TokenKind* ttp);
|
||||
|
||||
inline Node newName(PropertyName* name);
|
||||
inline Node newYieldExpression(uint32_t begin, Node expr, bool isYieldStar = false);
|
||||
|
@ -471,9 +479,9 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
inline bool abortIfSyntaxParser();
|
||||
|
||||
public:
|
||||
|
||||
/* Public entry points for parsing. */
|
||||
Node statement(bool canHaveDirectives = false);
|
||||
Node statement(YieldHandling yieldHandling, bool canHaveDirectives = false);
|
||||
|
||||
bool maybeParseDirective(Node list, Node pn, bool* cont);
|
||||
|
||||
// Parse a function, given only its body. Used for the Function and
|
||||
|
@ -492,9 +500,11 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
* statements; pass ExpressionBody if the body is a single expression.
|
||||
*/
|
||||
enum FunctionBodyType { StatementListBody, ExpressionBody };
|
||||
Node functionBody(FunctionSyntaxKind kind, FunctionBodyType type);
|
||||
Node functionBody(InHandling inHandling, YieldHandling yieldHandling, FunctionSyntaxKind kind,
|
||||
FunctionBodyType type);
|
||||
|
||||
bool functionArgsAndBodyGeneric(Node pn, HandleFunction fun, FunctionType type,
|
||||
bool functionArgsAndBodyGeneric(InHandling inHandling, YieldHandling yieldHandling, Node pn,
|
||||
HandleFunction fun, FunctionType type,
|
||||
FunctionSyntaxKind kind);
|
||||
|
||||
// Determine whether |yield| is a valid name in the current context, or
|
||||
|
@ -535,67 +545,74 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
* Some parsers have two versions: an always-inlined version (with an 'i'
|
||||
* suffix) and a never-inlined version (with an 'n' suffix).
|
||||
*/
|
||||
Node functionStmt();
|
||||
Node functionStmt(YieldHandling yieldHandling);
|
||||
Node functionExpr(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node statements();
|
||||
Node statements(YieldHandling yieldHandling);
|
||||
|
||||
Node blockStatement();
|
||||
Node ifStatement();
|
||||
Node doWhileStatement();
|
||||
Node whileStatement();
|
||||
Node forStatement();
|
||||
Node switchStatement();
|
||||
Node continueStatement();
|
||||
Node breakStatement();
|
||||
Node returnStatement();
|
||||
Node withStatement();
|
||||
Node labeledStatement();
|
||||
Node throwStatement();
|
||||
Node tryStatement();
|
||||
Node blockStatement(YieldHandling yieldHandling);
|
||||
Node ifStatement(YieldHandling yieldHandling);
|
||||
Node doWhileStatement(YieldHandling yieldHandling);
|
||||
Node whileStatement(YieldHandling yieldHandling);
|
||||
Node forStatement(YieldHandling yieldHandling);
|
||||
Node switchStatement(YieldHandling yieldHandling);
|
||||
Node continueStatement(YieldHandling yieldHandling);
|
||||
Node breakStatement(YieldHandling yieldHandling);
|
||||
Node returnStatement(YieldHandling yieldHandling);
|
||||
Node withStatement(YieldHandling yieldHandling);
|
||||
Node labeledStatement(YieldHandling yieldHandling);
|
||||
Node throwStatement(YieldHandling yieldHandling);
|
||||
Node tryStatement(YieldHandling yieldHandling);
|
||||
Node debuggerStatement();
|
||||
|
||||
Node lexicalDeclaration(bool isConst);
|
||||
Node letDeclarationOrBlock();
|
||||
Node lexicalDeclaration(YieldHandling yieldHandling, bool isConst);
|
||||
Node letDeclarationOrBlock(YieldHandling yieldHandling);
|
||||
Node importDeclaration();
|
||||
Node exportDeclaration();
|
||||
Node expressionStatement(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node variables(ParseNodeKind kind, bool* psimple = nullptr,
|
||||
StaticBlockObject* blockObj = nullptr,
|
||||
VarContext varContext = HoistVars);
|
||||
Node expr(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node assignExpr(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node assignExprWithoutYield(unsigned err);
|
||||
Node yieldExpression();
|
||||
Node condExpr1(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node orExpr1(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node unaryExpr(InvokedPrediction invoked = PredictUninvoked);
|
||||
Node memberExpr(TokenKind tt, bool allowCallSyntax,
|
||||
Node expressionStatement(YieldHandling yieldHandling,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node variables(YieldHandling yieldHandling,
|
||||
ParseNodeKind kind, bool* psimple = nullptr,
|
||||
StaticBlockObject* blockObj = nullptr, VarContext varContext = HoistVars);
|
||||
Node expr(InHandling inHandling, YieldHandling yieldHandling,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node assignExpr(InHandling inHandling, YieldHandling yieldHandling,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node primaryExpr(TokenKind tt, InvokedPrediction invoked = PredictUninvoked);
|
||||
Node parenExprOrGeneratorComprehension();
|
||||
Node exprInParens();
|
||||
Node assignExprWithoutYield(YieldHandling yieldHandling, unsigned err);
|
||||
Node yieldExpression(InHandling inHandling);
|
||||
Node condExpr1(InHandling inHandling, YieldHandling yieldHandling,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node orExpr1(InHandling inHandling, YieldHandling yieldHandling,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node unaryExpr(YieldHandling yieldHandling, InvokedPrediction invoked = PredictUninvoked);
|
||||
Node memberExpr(YieldHandling yieldHandling, TokenKind tt, bool allowCallSyntax,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node primaryExpr(YieldHandling yieldHandling, TokenKind tt,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node parenExprOrGeneratorComprehension(YieldHandling yieldHandling);
|
||||
Node exprInParens(InHandling inHandling, YieldHandling yieldHandling);
|
||||
|
||||
bool checkAndMarkSuperScope();
|
||||
|
||||
bool methodDefinition(PropListType listType, Node propList, Node propname, FunctionType type,
|
||||
GeneratorKind generatorKind, bool isStatic, JSOp Op);
|
||||
bool methodDefinition(YieldHandling yieldHandling, PropListType listType, Node propList,
|
||||
Node propname, FunctionType type, GeneratorKind generatorKind,
|
||||
bool isStatic, JSOp Op);
|
||||
|
||||
/*
|
||||
* Additional JS parsers.
|
||||
*/
|
||||
bool functionArguments(FunctionSyntaxKind kind, FunctionType type, Node* list, Node funcpn,
|
||||
bool* hasRest);
|
||||
bool functionArguments(YieldHandling yieldHandling, FunctionSyntaxKind kind, FunctionType type,
|
||||
Node* list, Node funcpn, bool* hasRest);
|
||||
|
||||
Node functionDef(HandlePropertyName name, FunctionType type, FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind, InvokedPrediction invoked = PredictUninvoked);
|
||||
bool functionArgsAndBody(Node pn, HandleFunction fun,
|
||||
FunctionType type, FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind,
|
||||
Node functionDef(InHandling inHandling, YieldHandling uieldHandling, HandlePropertyName name,
|
||||
FunctionType type, FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
bool functionArgsAndBody(InHandling inHandling, Node pn, HandleFunction fun, FunctionType type,
|
||||
FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||
Directives inheritedDirectives, Directives* newDirectives);
|
||||
|
||||
Node unaryOpExpr(ParseNodeKind kind, JSOp op, uint32_t begin);
|
||||
Node unaryOpExpr(YieldHandling yieldHandling, ParseNodeKind kind, JSOp op, uint32_t begin);
|
||||
|
||||
Node condition();
|
||||
Node condition(InHandling inHandling, YieldHandling yieldHandling);
|
||||
|
||||
Node generatorComprehensionLambda(GeneratorKind comprehensionKind, unsigned begin,
|
||||
Node innerStmt);
|
||||
|
@ -613,17 +630,19 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
Node arrayComprehension(uint32_t begin);
|
||||
Node generatorComprehension(uint32_t begin);
|
||||
|
||||
bool argumentList(Node listNode, bool* isSpread);
|
||||
Node deprecatedLetBlockOrExpression(LetContext letContext);
|
||||
Node destructuringExpr(BindData<ParseHandler>* data, TokenKind tt);
|
||||
Node destructuringExprWithoutYield(BindData<ParseHandler>* data, TokenKind tt, unsigned msg);
|
||||
bool argumentList(YieldHandling yieldHandling, Node listNode, bool* isSpread);
|
||||
Node deprecatedLetBlockOrExpression(YieldHandling yieldHandling, LetContext letContext);
|
||||
Node destructuringExpr(YieldHandling yieldHandling, BindData<ParseHandler>* data,
|
||||
TokenKind tt);
|
||||
Node destructuringExprWithoutYield(YieldHandling yieldHandling, BindData<ParseHandler>* data,
|
||||
TokenKind tt, unsigned msg);
|
||||
|
||||
enum ClassContext { ClassStatement, ClassExpression };
|
||||
Node classDefinition(ClassContext classContext);
|
||||
Node classDefinition(YieldHandling yieldHandling, ClassContext classContext);
|
||||
|
||||
Node identifierName();
|
||||
Node identifierName(YieldHandling yieldHandling);
|
||||
|
||||
bool matchLabel(MutableHandle<PropertyName*> label);
|
||||
bool matchLabel(YieldHandling yieldHandling, MutableHandle<PropertyName*> label);
|
||||
|
||||
bool allowsForEachIn() {
|
||||
#if !JS_HAS_FOR_EACH_IN
|
||||
|
@ -662,11 +681,11 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
Node pushLexicalScope(Handle<StaticBlockObject*> blockObj, StmtInfoPC* stmt);
|
||||
Node pushLetScope(Handle<StaticBlockObject*> blockObj, StmtInfoPC* stmt);
|
||||
bool noteNameUse(HandlePropertyName name, Node pn);
|
||||
Node computedPropertyName(Node literal);
|
||||
Node arrayInitializer();
|
||||
Node computedPropertyName(YieldHandling yieldHandling, Node literal);
|
||||
Node arrayInitializer(YieldHandling yieldHandling);
|
||||
Node newRegExp();
|
||||
|
||||
Node propertyList(PropListType type);
|
||||
Node propertyList(YieldHandling yieldHandling, PropListType type);
|
||||
Node newPropertyListNode(PropListType type);
|
||||
|
||||
bool checkAndPrepareLexical(bool isConst, const TokenPos& errorPos);
|
||||
|
|
Загрузка…
Ссылка в новой задаче