зеркало из https://github.com/mozilla/gecko-dev.git
Bug 883333, part 12 - Factor block parsing out of Parser::statement. r=Waldo.
--HG-- extra : rebase_source : 1af9d3df561cb5d9bc2c16c77451d070f48bccf4
This commit is contained in:
Родитель
0a53f84be3
Коммит
27931d088d
|
@ -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);
|
||||
|
|
|
@ -417,6 +417,7 @@ struct Parser : private AutoGCRooter, public StrictModeGetter
|
|||
Node functionExpr();
|
||||
Node statements();
|
||||
|
||||
Node blockStatement();
|
||||
Node ifStatement();
|
||||
Node doWhileStatement();
|
||||
Node whileStatement();
|
||||
|
|
Загрузка…
Ссылка в новой задаче