author | Jeff Walden <jwalden@mit.edu> |
Mon, 06 Apr 2015 17:32:51 -0400 | |
changeset 243428 | 03335da9925a4be70809949aa3194078f7578df0 |
parent 243427 | ef3e09a6a0c3d0c8c77625d27b27d47831115f59 |
child 243429 | d7a5e972e003b26a47476b46ca6366e05f830c39 |
push id | 28738 |
push user | cbook@mozilla.com |
push date | Tue, 12 May 2015 14:11:31 +0000 |
treeherder | mozilla-central@bedce1b405a3 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | efaust |
bugs | 1155472 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -5967,85 +5967,39 @@ Parser<ParseHandler>::statement(bool can MOZ_ASSERT(checkOptionsCalled); JS_CHECK_RECURSION(context, return null()); TokenKind tt; if (!tokenStream.getToken(&tt, TokenStream::Operand)) return null(); switch (tt) { + // BlockStatement[?Yield, ?Return] case TOK_LC: return blockStatement(); - case TOK_CONST: - if (!abortIfSyntaxParser()) - return null(); - return lexicalDeclaration(/* isConst = */ true); - + // VariableStatement[?Yield] case TOK_VAR: { Node pn = variables(PNK_VAR); if (!pn) return null(); // Tell js_EmitTree to generate a final POP. handler.setListFlag(pn, PNX_POPVAR); if (!MatchOrInsertSemicolon(tokenStream)) return null(); return pn; } - case TOK_LET: - return letDeclarationOrBlock(); - case TOK_IMPORT: - return importDeclaration(); - case TOK_EXPORT: - return exportDeclaration(); + // EmptyStatement case TOK_SEMI: return handler.newEmptyStatement(pos()); - case TOK_IF: - return ifStatement(); - case TOK_DO: - return doWhileStatement(); - case TOK_WHILE: - return whileStatement(); - case TOK_FOR: - return forStatement(); - case TOK_SWITCH: - return switchStatement(); - case TOK_CONTINUE: - return continueStatement(); - case TOK_BREAK: - return breakStatement(); - case TOK_RETURN: - return returnStatement(); - case TOK_WITH: - return withStatement(); - case TOK_THROW: - return throwStatement(); - case TOK_TRY: - return tryStatement(); - case TOK_FUNCTION: - return functionStmt(); - case TOK_DEBUGGER: - return debuggerStatement(); - case TOK_CLASS: - if (!abortIfSyntaxParser()) - return null(); - return classDefinition(ClassStatement); - - /* TOK_CATCH and TOK_FINALLY are both handled in the TOK_TRY case */ - case TOK_CATCH: - report(ParseError, false, null(), JSMSG_CATCH_WITHOUT_TRY); - return null(); - - case TOK_FINALLY: - report(ParseError, false, null(), JSMSG_FINALLY_WITHOUT_TRY); - return null(); - + + // ExpressionStatement[?Yield] case TOK_STRING: if (!canHaveDirectives && tokenStream.currentToken().atom() == context->names().useAsm) { if (!abortIfSyntaxParser()) return null(); if (!report(ParseWarning, false, null(), JSMSG_USE_ASM_DIRECTIVE_FAIL)) return null(); } return expressionStatement(); @@ -6074,16 +6028,106 @@ Parser<ParseHandler>::statement(bool can return expressionStatement(); } case TOK_NEW: return expressionStatement(PredictInvoked); default: return expressionStatement(); + + // IfStatement[?Yield, ?Return] + case TOK_IF: + return ifStatement(); + + // BreakableStatement[?Yield, ?Return] + // + // BreakableStatement[Yield, Return]: + // IterationStatement[?Yield, ?Return] + // SwitchStatement[?Yield, ?Return] + case TOK_DO: + return doWhileStatement(); + + case TOK_WHILE: + return whileStatement(); + + case TOK_FOR: + return forStatement(); + + case TOK_SWITCH: + return switchStatement(); + + // ContinueStatement[?Yield] + case TOK_CONTINUE: + return continueStatement(); + + // BreakStatement[?Yield] + case TOK_BREAK: + return breakStatement(); + + // [+Return] ReturnStatement[?Yield] + case TOK_RETURN: + return returnStatement(); + + // WithStatement[?Yield, ?Return] + case TOK_WITH: + return withStatement(); + + // LabelledStatement[?Yield, ?Return] + // This is really handled by TOK_NAME and TOK_YIELD cases above. + + // ThrowStatement[?Yield] + case TOK_THROW: + return throwStatement(); + + // TryStatement[?Yield, ?Return] + case TOK_TRY: + return tryStatement(); + + // DebuggerStatement + case TOK_DEBUGGER: + return debuggerStatement(); + + // HoistableDeclaration[?Yield] + case TOK_FUNCTION: + return functionStmt(); + + // ClassDeclaration[?Yield] + case TOK_CLASS: + if (!abortIfSyntaxParser()) + return null(); + return classDefinition(ClassStatement); + + // LexicalDeclaration[In, ?Yield] + case TOK_LET: + return letDeclarationOrBlock(); + case TOK_CONST: + if (!abortIfSyntaxParser()) + return null(); + return lexicalDeclaration(/* isConst = */ true); + + // ImportDeclaration (only inside modules) + case TOK_IMPORT: + return importDeclaration(); + + // ExportDeclaration (only inside modules) + case TOK_EXPORT: + return exportDeclaration(); + + // Miscellaneous error cases arguably better caught here than elsewhere. + + case TOK_CATCH: + report(ParseError, false, null(), JSMSG_CATCH_WITHOUT_TRY); + return null(); + + case TOK_FINALLY: + report(ParseError, false, null(), JSMSG_FINALLY_WITHOUT_TRY); + return null(); + + // NOTE: default case handled in the ExpressionStatement section. } } template <typename ParseHandler> typename ParseHandler::Node Parser<ParseHandler>::expr(InvokedPrediction invoked) { Node pn = assignExpr(invoked);