Bug 883333, part 12 - Factor block parsing out of Parser::statement. r=Waldo.

--HG--
extra : rebase_source : 1af9d3df561cb5d9bc2c16c77451d070f48bccf4
This commit is contained in:
Jason Orendorff 2013-06-21 08:18:00 -05:00
parent ea3d94b648
commit 4b8a5826f3
2 changed files with 21 additions and 13 deletions

View File

@ -3327,6 +3327,25 @@ PushBlocklikeStatement(StmtInfoPC *stmt, StmtType type, ParseContext<ParseHandle
return GenerateBlockId(pc, stmt->blockid);
}
template <typename ParseHandler>
typename ParseHandler::Node
Parser<ParseHandler>::blockStatement()
{
JS_ASSERT(tokenStream.currentToken().type == TOK_LC);
StmtInfoPC stmtInfo(context);
if (!PushBlocklikeStatement(&stmtInfo, STMT_BLOCK, pc))
return null();
Node list = statements();
if (!list)
return null();
MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_IN_COMPOUND);
PopStatementPC(context, pc);
return list;
}
template <typename ParseHandler>
typename ParseHandler::Node
Parser<ParseHandler>::newBindingNode(PropertyName *name, bool functionScope, VarContext varContext)
@ -4799,19 +4818,7 @@ Parser<ParseHandler>::statement(bool canHaveDirectives)
switch (tokenStream.getToken(TSF_OPERAND)) {
case TOK_LC:
{
StmtInfoPC stmtInfo(context);
if (!PushBlocklikeStatement(&stmtInfo, STMT_BLOCK, pc))
return null();
pn = statements();
if (!pn)
return null();
MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_IN_COMPOUND);
PopStatementPC(context, pc);
return pn;
}
return blockStatement();
case TOK_VAR:
pn = variables(PNK_VAR);

View File

@ -417,6 +417,7 @@ struct Parser : private AutoGCRooter, public StrictModeGetter
Node functionExpr();
Node statements();
Node blockStatement();
Node ifStatement();
Node doWhileStatement();
Node whileStatement();