From 151707db5d98195eb894f9e4a798d417ea6895e3 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Wed, 24 Aug 2016 17:28:39 -0700 Subject: [PATCH] Bug 1288459 - Split variable-statement parsing into its own parser function. r=arai --HG-- extra : rebase_source : 574f08e92b8e8e9f0f35e86a48986e956828c09a --- js/src/frontend/Parser.cpp | 22 ++++++++++++++-------- js/src/frontend/Parser.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index c55dfb785a5c..4c4eaa37977f 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -6424,6 +6424,18 @@ Parser::peekShouldParseLetDeclaration(bool* parseDeclOut, return true; } +template +typename ParseHandler::Node +Parser::variableStatement(YieldHandling yieldHandling) +{ + Node vars = declarationList(yieldHandling, PNK_VAR); + if (!vars) + return null(); + if (!MatchOrInsertSemicolonAfterExpression(tokenStream)) + return null(); + return vars; +} + template typename ParseHandler::Node Parser::statement(YieldHandling yieldHandling, bool canHaveDirectives) @@ -6442,14 +6454,8 @@ Parser::statement(YieldHandling yieldHandling, bool canHaveDirecti return blockStatement(yieldHandling); // VariableStatement[?Yield] - case TOK_VAR: { - Node pn = declarationList(yieldHandling, PNK_VAR); - if (!pn) - return null(); - if (!MatchOrInsertSemicolonAfterExpression(tokenStream)) - return null(); - return pn; - } + case TOK_VAR: + return variableStatement(yieldHandling); // EmptyStatement case TOK_SEMI: diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index b55b635e3cd6..69a3687b163f 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -1046,6 +1046,8 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter Node catchBlockStatement(YieldHandling yieldHandling, HandlePropertyName simpleCatchParam); Node debuggerStatement(); + Node variableStatement(YieldHandling yieldHandling); + Node lexicalDeclaration(YieldHandling yieldHandling, bool isConst); Node importDeclaration(); Node exportDeclaration();