Remove deprecated "i::" prefix from the pre-parser.

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/26296006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17208 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bdc8c36c
...@@ -56,14 +56,14 @@ namespace v8 { ...@@ -56,14 +56,14 @@ namespace v8 {
namespace internal { namespace internal {
PreParser::PreParseResult PreParser::PreParseLazyFunction( PreParser::PreParseResult PreParser::PreParseLazyFunction(
i::LanguageMode mode, bool is_generator, i::ParserRecorder* log) { LanguageMode mode, bool is_generator, ParserRecorder* log) {
log_ = log; log_ = log;
// Lazy functions always have trivial outer scopes (no with/catch scopes). // Lazy functions always have trivial outer scopes (no with/catch scopes).
Scope top_scope(&scope_, kTopLevelScope); Scope top_scope(&scope_, kTopLevelScope);
set_language_mode(mode); set_language_mode(mode);
Scope function_scope(&scope_, kFunctionScope); Scope function_scope(&scope_, kFunctionScope);
function_scope.set_is_generator(is_generator); function_scope.set_is_generator(is_generator);
ASSERT_EQ(i::Token::LBRACE, scanner()->current_token()); ASSERT_EQ(Token::LBRACE, scanner()->current_token());
bool ok = true; bool ok = true;
int start_position = peek_position(); int start_position = peek_position();
ParseLazyFunctionLiteralBody(&ok); ParseLazyFunctionLiteralBody(&ok);
...@@ -71,7 +71,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction( ...@@ -71,7 +71,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
if (!ok) { if (!ok) {
ReportUnexpectedToken(scanner()->current_token()); ReportUnexpectedToken(scanner()->current_token());
} else { } else {
ASSERT_EQ(i::Token::RBRACE, scanner()->peek()); ASSERT_EQ(Token::RBRACE, scanner()->peek());
if (!is_classic_mode()) { if (!is_classic_mode()) {
int end_pos = scanner()->location().end_pos; int end_pos = scanner()->location().end_pos;
CheckOctalLiteral(start_position, end_pos, &ok); CheckOctalLiteral(start_position, end_pos, &ok);
...@@ -97,33 +97,33 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction( ...@@ -97,33 +97,33 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
// That means that contextual checks (like a label being declared where // That means that contextual checks (like a label being declared where
// it is used) are generally omitted. // it is used) are generally omitted.
void PreParser::ReportUnexpectedToken(i::Token::Value token) { void PreParser::ReportUnexpectedToken(Token::Value token) {
// We don't report stack overflows here, to avoid increasing the // We don't report stack overflows here, to avoid increasing the
// stack depth even further. Instead we report it after parsing is // stack depth even further. Instead we report it after parsing is
// over, in ParseProgram. // over, in ParseProgram.
if (token == i::Token::ILLEGAL && stack_overflow()) { if (token == Token::ILLEGAL && stack_overflow()) {
return; return;
} }
i::Scanner::Location source_location = scanner()->location(); Scanner::Location source_location = scanner()->location();
// Four of the tokens are treated specially // Four of the tokens are treated specially
switch (token) { switch (token) {
case i::Token::EOS: case Token::EOS:
return ReportMessageAt(source_location, "unexpected_eos", NULL); return ReportMessageAt(source_location, "unexpected_eos", NULL);
case i::Token::NUMBER: case Token::NUMBER:
return ReportMessageAt(source_location, "unexpected_token_number", NULL); return ReportMessageAt(source_location, "unexpected_token_number", NULL);
case i::Token::STRING: case Token::STRING:
return ReportMessageAt(source_location, "unexpected_token_string", NULL); return ReportMessageAt(source_location, "unexpected_token_string", NULL);
case i::Token::IDENTIFIER: case Token::IDENTIFIER:
return ReportMessageAt(source_location, return ReportMessageAt(source_location,
"unexpected_token_identifier", NULL); "unexpected_token_identifier", NULL);
case i::Token::FUTURE_RESERVED_WORD: case Token::FUTURE_RESERVED_WORD:
return ReportMessageAt(source_location, "unexpected_reserved", NULL); return ReportMessageAt(source_location, "unexpected_reserved", NULL);
case i::Token::FUTURE_STRICT_RESERVED_WORD: case Token::FUTURE_STRICT_RESERVED_WORD:
return ReportMessageAt(source_location, return ReportMessageAt(source_location,
"unexpected_strict_reserved", NULL); "unexpected_strict_reserved", NULL);
default: default:
const char* name = i::Token::String(token); const char* name = Token::String(token);
ReportMessageAt(source_location, "unexpected_token", name); ReportMessageAt(source_location, "unexpected_token", name);
} }
} }
...@@ -149,10 +149,10 @@ PreParser::Statement PreParser::ParseSourceElement(bool* ok) { ...@@ -149,10 +149,10 @@ PreParser::Statement PreParser::ParseSourceElement(bool* ok) {
// GeneratorDeclaration // GeneratorDeclaration
switch (peek()) { switch (peek()) {
case i::Token::FUNCTION: case Token::FUNCTION:
return ParseFunctionDeclaration(ok); return ParseFunctionDeclaration(ok);
case i::Token::LET: case Token::LET:
case i::Token::CONST: case Token::CONST:
return ParseVariableStatement(kSourceElement, ok); return ParseVariableStatement(kSourceElement, ok);
default: default:
return ParseStatement(ok); return ParseStatement(ok);
...@@ -171,7 +171,7 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token, ...@@ -171,7 +171,7 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token,
if (allow_directive_prologue) { if (allow_directive_prologue) {
if (statement.IsUseStrictLiteral()) { if (statement.IsUseStrictLiteral()) {
set_language_mode(allow_harmony_scoping() ? set_language_mode(allow_harmony_scoping() ?
i::EXTENDED_MODE : i::STRICT_MODE); EXTENDED_MODE : STRICT_MODE);
} else if (!statement.IsStringLiteral()) { } else if (!statement.IsStringLiteral()) {
allow_directive_prologue = false; allow_directive_prologue = false;
} }
...@@ -216,55 +216,55 @@ PreParser::Statement PreParser::ParseStatement(bool* ok) { ...@@ -216,55 +216,55 @@ PreParser::Statement PreParser::ParseStatement(bool* ok) {
// Keep the source position of the statement // Keep the source position of the statement
switch (peek()) { switch (peek()) {
case i::Token::LBRACE: case Token::LBRACE:
return ParseBlock(ok); return ParseBlock(ok);
case i::Token::CONST: case Token::CONST:
case i::Token::LET: case Token::LET:
case i::Token::VAR: case Token::VAR:
return ParseVariableStatement(kStatement, ok); return ParseVariableStatement(kStatement, ok);
case i::Token::SEMICOLON: case Token::SEMICOLON:
Next(); Next();
return Statement::Default(); return Statement::Default();
case i::Token::IF: case Token::IF:
return ParseIfStatement(ok); return ParseIfStatement(ok);
case i::Token::DO: case Token::DO:
return ParseDoWhileStatement(ok); return ParseDoWhileStatement(ok);
case i::Token::WHILE: case Token::WHILE:
return ParseWhileStatement(ok); return ParseWhileStatement(ok);
case i::Token::FOR: case Token::FOR:
return ParseForStatement(ok); return ParseForStatement(ok);
case i::Token::CONTINUE: case Token::CONTINUE:
return ParseContinueStatement(ok); return ParseContinueStatement(ok);
case i::Token::BREAK: case Token::BREAK:
return ParseBreakStatement(ok); return ParseBreakStatement(ok);
case i::Token::RETURN: case Token::RETURN:
return ParseReturnStatement(ok); return ParseReturnStatement(ok);
case i::Token::WITH: case Token::WITH:
return ParseWithStatement(ok); return ParseWithStatement(ok);
case i::Token::SWITCH: case Token::SWITCH:
return ParseSwitchStatement(ok); return ParseSwitchStatement(ok);
case i::Token::THROW: case Token::THROW:
return ParseThrowStatement(ok); return ParseThrowStatement(ok);
case i::Token::TRY: case Token::TRY:
return ParseTryStatement(ok); return ParseTryStatement(ok);
case i::Token::FUNCTION: { case Token::FUNCTION: {
i::Scanner::Location start_location = scanner()->peek_location(); Scanner::Location start_location = scanner()->peek_location();
Statement statement = ParseFunctionDeclaration(CHECK_OK); Statement statement = ParseFunctionDeclaration(CHECK_OK);
i::Scanner::Location end_location = scanner()->location(); Scanner::Location end_location = scanner()->location();
if (!is_classic_mode()) { if (!is_classic_mode()) {
ReportMessageAt(start_location.beg_pos, end_location.end_pos, ReportMessageAt(start_location.beg_pos, end_location.end_pos,
"strict_function", NULL); "strict_function", NULL);
...@@ -275,7 +275,7 @@ PreParser::Statement PreParser::ParseStatement(bool* ok) { ...@@ -275,7 +275,7 @@ PreParser::Statement PreParser::ParseStatement(bool* ok) {
} }
} }
case i::Token::DEBUGGER: case Token::DEBUGGER:
return ParseDebuggerStatement(ok); return ParseDebuggerStatement(ok);
default: default:
...@@ -290,11 +290,11 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) { ...@@ -290,11 +290,11 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
// GeneratorDeclaration :: // GeneratorDeclaration ::
// 'function' '*' Identifier '(' FormalParameterListopt ')' // 'function' '*' Identifier '(' FormalParameterListopt ')'
// '{' FunctionBody '}' // '{' FunctionBody '}'
Expect(i::Token::FUNCTION, CHECK_OK); Expect(Token::FUNCTION, CHECK_OK);
bool is_generator = allow_generators() && Check(i::Token::MUL); bool is_generator = allow_generators() && Check(Token::MUL);
Identifier identifier = ParseIdentifier(CHECK_OK); Identifier identifier = ParseIdentifier(CHECK_OK);
i::Scanner::Location location = scanner()->location(); Scanner::Location location = scanner()->location();
Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK); Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK);
...@@ -320,15 +320,15 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) { ...@@ -320,15 +320,15 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
// Note that a Block does not introduce a new execution scope! // Note that a Block does not introduce a new execution scope!
// (ECMA-262, 3rd, 12.2) // (ECMA-262, 3rd, 12.2)
// //
Expect(i::Token::LBRACE, CHECK_OK); Expect(Token::LBRACE, CHECK_OK);
while (peek() != i::Token::RBRACE) { while (peek() != Token::RBRACE) {
if (is_extended_mode()) { if (is_extended_mode()) {
ParseSourceElement(CHECK_OK); ParseSourceElement(CHECK_OK);
} else { } else {
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
} }
} }
Expect(i::Token::RBRACE, ok); Expect(Token::RBRACE, ok);
return Statement::Default(); return Statement::Default();
} }
...@@ -372,9 +372,9 @@ PreParser::Statement PreParser::ParseVariableDeclarations( ...@@ -372,9 +372,9 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
// ConstBinding :: // ConstBinding ::
// BindingPattern '=' AssignmentExpression // BindingPattern '=' AssignmentExpression
bool require_initializer = false; bool require_initializer = false;
if (peek() == i::Token::VAR) { if (peek() == Token::VAR) {
Consume(i::Token::VAR); Consume(Token::VAR);
} else if (peek() == i::Token::CONST) { } else if (peek() == Token::CONST) {
// TODO(ES6): The ES6 Draft Rev4 section 12.2.2 reads: // TODO(ES6): The ES6 Draft Rev4 section 12.2.2 reads:
// //
// ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';'
...@@ -385,20 +385,20 @@ PreParser::Statement PreParser::ParseVariableDeclarations( ...@@ -385,20 +385,20 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
// However disallowing const in classic mode will break compatibility with // However disallowing const in classic mode will break compatibility with
// existing pages. Therefore we keep allowing const with the old // existing pages. Therefore we keep allowing const with the old
// non-harmony semantics in classic mode. // non-harmony semantics in classic mode.
Consume(i::Token::CONST); Consume(Token::CONST);
switch (language_mode()) { switch (language_mode()) {
case i::CLASSIC_MODE: case CLASSIC_MODE:
break; break;
case i::STRICT_MODE: { case STRICT_MODE: {
i::Scanner::Location location = scanner()->peek_location(); Scanner::Location location = scanner()->peek_location();
ReportMessageAt(location, "strict_const", NULL); ReportMessageAt(location, "strict_const", NULL);
*ok = false; *ok = false;
return Statement::Default(); return Statement::Default();
} }
case i::EXTENDED_MODE: case EXTENDED_MODE:
if (var_context != kSourceElement && if (var_context != kSourceElement &&
var_context != kForStatement) { var_context != kForStatement) {
i::Scanner::Location location = scanner()->peek_location(); Scanner::Location location = scanner()->peek_location();
ReportMessageAt(location.beg_pos, location.end_pos, ReportMessageAt(location.beg_pos, location.end_pos,
"unprotected_const", NULL); "unprotected_const", NULL);
*ok = false; *ok = false;
...@@ -407,7 +407,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations( ...@@ -407,7 +407,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
require_initializer = true; require_initializer = true;
break; break;
} }
} else if (peek() == i::Token::LET) { } else if (peek() == Token::LET) {
// ES6 Draft Rev4 section 12.2.1: // ES6 Draft Rev4 section 12.2.1:
// //
// LetDeclaration : let LetBindingList ; // LetDeclaration : let LetBindingList ;
...@@ -415,16 +415,16 @@ PreParser::Statement PreParser::ParseVariableDeclarations( ...@@ -415,16 +415,16 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
// * It is a Syntax Error if the code that matches this production is not // * It is a Syntax Error if the code that matches this production is not
// contained in extended code. // contained in extended code.
if (!is_extended_mode()) { if (!is_extended_mode()) {
i::Scanner::Location location = scanner()->peek_location(); Scanner::Location location = scanner()->peek_location();
ReportMessageAt(location.beg_pos, location.end_pos, ReportMessageAt(location.beg_pos, location.end_pos,
"illegal_let", NULL); "illegal_let", NULL);
*ok = false; *ok = false;
return Statement::Default(); return Statement::Default();
} }
Consume(i::Token::LET); Consume(Token::LET);
if (var_context != kSourceElement && if (var_context != kSourceElement &&
var_context != kForStatement) { var_context != kForStatement) {
i::Scanner::Location location = scanner()->peek_location(); Scanner::Location location = scanner()->peek_location();
ReportMessageAt(location.beg_pos, location.end_pos, ReportMessageAt(location.beg_pos, location.end_pos,
"unprotected_let", NULL); "unprotected_let", NULL);
*ok = false; *ok = false;
...@@ -442,7 +442,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations( ...@@ -442,7 +442,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
int nvars = 0; // the number of variables declared int nvars = 0; // the number of variables declared
do { do {
// Parse variable name. // Parse variable name.
if (nvars > 0) Consume(i::Token::COMMA); if (nvars > 0) Consume(Token::COMMA);
Identifier identifier = ParseIdentifier(CHECK_OK); Identifier identifier = ParseIdentifier(CHECK_OK);
if (!is_classic_mode() && !identifier.IsValidStrictVariable()) { if (!is_classic_mode() && !identifier.IsValidStrictVariable()) {
StrictModeIdentifierViolation(scanner()->location(), StrictModeIdentifierViolation(scanner()->location(),
...@@ -452,12 +452,12 @@ PreParser::Statement PreParser::ParseVariableDeclarations( ...@@ -452,12 +452,12 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
return Statement::Default(); return Statement::Default();
} }
nvars++; nvars++;
if (peek() == i::Token::ASSIGN || require_initializer) { if (peek() == Token::ASSIGN || require_initializer) {
Expect(i::Token::ASSIGN, CHECK_OK); Expect(Token::ASSIGN, CHECK_OK);
ParseAssignmentExpression(var_context != kForStatement, CHECK_OK); ParseAssignmentExpression(var_context != kForStatement, CHECK_OK);
if (decl_props != NULL) *decl_props = kHasInitializers; if (decl_props != NULL) *decl_props = kHasInitializers;
} }
} while (peek() == i::Token::COMMA); } while (peek() == Token::COMMA);
if (num_decl != NULL) *num_decl = nvars; if (num_decl != NULL) *num_decl = nvars;
return Statement::Default(); return Statement::Default();
...@@ -475,8 +475,8 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) { ...@@ -475,8 +475,8 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
ASSERT(is_classic_mode() || ASSERT(is_classic_mode() ||
(!expr.AsIdentifier().IsFutureStrictReserved() && (!expr.AsIdentifier().IsFutureStrictReserved() &&
!expr.AsIdentifier().IsYield())); !expr.AsIdentifier().IsYield()));
if (peek() == i::Token::COLON) { if (peek() == Token::COLON) {
Consume(i::Token::COLON); Consume(Token::COLON);
return ParseStatement(ok); return ParseStatement(ok);
} }
// Preparsing is disabled for extensions (because the extension details // Preparsing is disabled for extensions (because the extension details
...@@ -493,12 +493,12 @@ PreParser::Statement PreParser::ParseIfStatement(bool* ok) { ...@@ -493,12 +493,12 @@ PreParser::Statement PreParser::ParseIfStatement(bool* ok) {
// IfStatement :: // IfStatement ::
// 'if' '(' Expression ')' Statement ('else' Statement)? // 'if' '(' Expression ')' Statement ('else' Statement)?
Expect(i::Token::IF, CHECK_OK); Expect(Token::IF, CHECK_OK);
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
if (peek() == i::Token::ELSE) { if (peek() == Token::ELSE) {
Next(); Next();
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
} }
...@@ -510,12 +510,12 @@ PreParser::Statement PreParser::ParseContinueStatement(bool* ok) { ...@@ -510,12 +510,12 @@ PreParser::Statement PreParser::ParseContinueStatement(bool* ok) {
// ContinueStatement :: // ContinueStatement ::
// 'continue' [no line terminator] Identifier? ';' // 'continue' [no line terminator] Identifier? ';'
Expect(i::Token::CONTINUE, CHECK_OK); Expect(Token::CONTINUE, CHECK_OK);
i::Token::Value tok = peek(); Token::Value tok = peek();
if (!scanner()->HasAnyLineTerminatorBeforeNext() && if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
tok != i::Token::SEMICOLON && tok != Token::SEMICOLON &&
tok != i::Token::RBRACE && tok != Token::RBRACE &&
tok != i::Token::EOS) { tok != Token::EOS) {
ParseIdentifier(CHECK_OK); ParseIdentifier(CHECK_OK);
} }
ExpectSemicolon(CHECK_OK); ExpectSemicolon(CHECK_OK);
...@@ -527,12 +527,12 @@ PreParser::Statement PreParser::ParseBreakStatement(bool* ok) { ...@@ -527,12 +527,12 @@ PreParser::Statement PreParser::ParseBreakStatement(bool* ok) {
// BreakStatement :: // BreakStatement ::
// 'break' [no line terminator] Identifier? ';' // 'break' [no line terminator] Identifier? ';'
Expect(i::Token::BREAK, CHECK_OK); Expect(Token::BREAK, CHECK_OK);
i::Token::Value tok = peek(); Token::Value tok = peek();
if (!scanner()->HasAnyLineTerminatorBeforeNext() && if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
tok != i::Token::SEMICOLON && tok != Token::SEMICOLON &&
tok != i::Token::RBRACE && tok != Token::RBRACE &&
tok != i::Token::EOS) { tok != Token::EOS) {
ParseIdentifier(CHECK_OK); ParseIdentifier(CHECK_OK);
} }
ExpectSemicolon(CHECK_OK); ExpectSemicolon(CHECK_OK);
...@@ -547,18 +547,18 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { ...@@ -547,18 +547,18 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
// Consume the return token. It is necessary to do the before // Consume the return token. It is necessary to do the before
// reporting any errors on it, because of the way errors are // reporting any errors on it, because of the way errors are
// reported (underlining). // reported (underlining).
Expect(i::Token::RETURN, CHECK_OK); Expect(Token::RETURN, CHECK_OK);
// An ECMAScript program is considered syntactically incorrect if it // An ECMAScript program is considered syntactically incorrect if it
// contains a return statement that is not within the body of a // contains a return statement that is not within the body of a
// function. See ECMA-262, section 12.9, page 67. // function. See ECMA-262, section 12.9, page 67.
// This is not handled during preparsing. // This is not handled during preparsing.
i::Token::Value tok = peek(); Token::Value tok = peek();
if (!scanner()->HasAnyLineTerminatorBeforeNext() && if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
tok != i::Token::SEMICOLON && tok != Token::SEMICOLON &&
tok != i::Token::RBRACE && tok != Token::RBRACE &&
tok != i::Token::EOS) { tok != Token::EOS) {
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
} }
ExpectSemicolon(CHECK_OK); ExpectSemicolon(CHECK_OK);
...@@ -569,16 +569,16 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { ...@@ -569,16 +569,16 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
PreParser::Statement PreParser::ParseWithStatement(bool* ok) { PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
// WithStatement :: // WithStatement ::
// 'with' '(' Expression ')' Statement // 'with' '(' Expression ')' Statement
Expect(i::Token::WITH, CHECK_OK); Expect(Token::WITH, CHECK_OK);
if (!is_classic_mode()) { if (!is_classic_mode()) {
i::Scanner::Location location = scanner()->location(); Scanner::Location location = scanner()->location();
ReportMessageAt(location, "strict_mode_with", NULL); ReportMessageAt(location, "strict_mode_with", NULL);
*ok = false; *ok = false;
return Statement::Default(); return Statement::Default();
} }
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
Scope::InsideWith iw(scope_); Scope::InsideWith iw(scope_);
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
...@@ -590,30 +590,30 @@ PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) { ...@@ -590,30 +590,30 @@ PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) {
// SwitchStatement :: // SwitchStatement ::
// 'switch' '(' Expression ')' '{' CaseClause* '}' // 'switch' '(' Expression ')' '{' CaseClause* '}'
Expect(i::Token::SWITCH, CHECK_OK); Expect(Token::SWITCH, CHECK_OK);
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
Expect(i::Token::LBRACE, CHECK_OK); Expect(Token::LBRACE, CHECK_OK);
i::Token::Value token = peek(); Token::Value token = peek();
while (token != i::Token::RBRACE) { while (token != Token::RBRACE) {
if (token == i::Token::CASE) { if (token == Token::CASE) {
Expect(i::Token::CASE, CHECK_OK); Expect(Token::CASE, CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
} else { } else {
Expect(i::Token::DEFAULT, CHECK_OK); Expect(Token::DEFAULT, CHECK_OK);
} }
Expect(i::Token::COLON, CHECK_OK); Expect(Token::COLON, CHECK_OK);
token = peek(); token = peek();
while (token != i::Token::CASE && while (token != Token::CASE &&
token != i::Token::DEFAULT && token != Token::DEFAULT &&
token != i::Token::RBRACE) { token != Token::RBRACE) {
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
token = peek(); token = peek();
} }
} }
Expect(i::Token::RBRACE, ok); Expect(Token::RBRACE, ok);
return Statement::Default(); return Statement::Default();
} }
...@@ -622,13 +622,13 @@ PreParser::Statement PreParser::ParseDoWhileStatement(bool* ok) { ...@@ -622,13 +622,13 @@ PreParser::Statement PreParser::ParseDoWhileStatement(bool* ok) {
// DoStatement :: // DoStatement ::
// 'do' Statement 'while' '(' Expression ')' ';' // 'do' Statement 'while' '(' Expression ')' ';'
Expect(i::Token::DO, CHECK_OK); Expect(Token::DO, CHECK_OK);
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
Expect(i::Token::WHILE, CHECK_OK); Expect(Token::WHILE, CHECK_OK);
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, ok); Expect(Token::RPAREN, ok);
if (peek() == i::Token::SEMICOLON) Consume(i::Token::SEMICOLON); if (peek() == Token::SEMICOLON) Consume(Token::SEMICOLON);
return Statement::Default(); return Statement::Default();
} }
...@@ -637,10 +637,10 @@ PreParser::Statement PreParser::ParseWhileStatement(bool* ok) { ...@@ -637,10 +637,10 @@ PreParser::Statement PreParser::ParseWhileStatement(bool* ok) {
// WhileStatement :: // WhileStatement ::
// 'while' '(' Expression ')' Statement // 'while' '(' Expression ')' Statement
Expect(i::Token::WHILE, CHECK_OK); Expect(Token::WHILE, CHECK_OK);
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
ParseStatement(ok); ParseStatement(ok);
return Statement::Default(); return Statement::Default();
} }
...@@ -660,12 +660,12 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { ...@@ -660,12 +660,12 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
// ForStatement :: // ForStatement ::
// 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
Expect(i::Token::FOR, CHECK_OK); Expect(Token::FOR, CHECK_OK);
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
if (peek() != i::Token::SEMICOLON) { if (peek() != Token::SEMICOLON) {
if (peek() == i::Token::VAR || peek() == i::Token::CONST || if (peek() == Token::VAR || peek() == Token::CONST ||
peek() == i::Token::LET) { peek() == Token::LET) {
bool is_let = peek() == i::Token::LET; bool is_let = peek() == Token::LET;
int decl_count; int decl_count;
VariableDeclarationProperties decl_props = kHasNoInitializers; VariableDeclarationProperties decl_props = kHasNoInitializers;
ParseVariableDeclarations( ParseVariableDeclarations(
...@@ -675,7 +675,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { ...@@ -675,7 +675,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
bool accept_OF = !has_initializers; bool accept_OF = !has_initializers;
if (accept_IN && CheckInOrOf(accept_OF)) { if (accept_IN && CheckInOrOf(accept_OF)) {
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
return Statement::Default(); return Statement::Default();
...@@ -684,7 +684,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { ...@@ -684,7 +684,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
Expression lhs = ParseExpression(false, CHECK_OK); Expression lhs = ParseExpression(false, CHECK_OK);
if (CheckInOrOf(lhs.IsIdentifier())) { if (CheckInOrOf(lhs.IsIdentifier())) {
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
return Statement::Default(); return Statement::Default();
...@@ -693,17 +693,17 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { ...@@ -693,17 +693,17 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
} }
// Parsed initializer at this point. // Parsed initializer at this point.
Expect(i::Token::SEMICOLON, CHECK_OK); Expect(Token::SEMICOLON, CHECK_OK);
if (peek() != i::Token::SEMICOLON) { if (peek() != Token::SEMICOLON) {
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
} }
Expect(i::Token::SEMICOLON, CHECK_OK); Expect(Token::SEMICOLON, CHECK_OK);
if (peek() != i::Token::RPAREN) { if (peek() != Token::RPAREN) {
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
} }
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
ParseStatement(ok); ParseStatement(ok);
return Statement::Default(); return Statement::Default();
...@@ -714,9 +714,9 @@ PreParser::Statement PreParser::ParseThrowStatement(bool* ok) { ...@@ -714,9 +714,9 @@ PreParser::Statement PreParser::ParseThrowStatement(bool* ok) {
// ThrowStatement :: // ThrowStatement ::
// 'throw' [no line terminator] Expression ';' // 'throw' [no line terminator] Expression ';'
Expect(i::Token::THROW, CHECK_OK); Expect(Token::THROW, CHECK_OK);
if (scanner()->HasAnyLineTerminatorBeforeNext()) { if (scanner()->HasAnyLineTerminatorBeforeNext()) {
i::Scanner::Location pos = scanner()->location(); Scanner::Location pos = scanner()->location();
ReportMessageAt(pos, "newline_after_throw", NULL); ReportMessageAt(pos, "newline_after_throw", NULL);
*ok = false; *ok = false;
return Statement::Default(); return Statement::Default();
...@@ -742,14 +742,14 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) { ...@@ -742,14 +742,14 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
// In preparsing, allow any number of catch/finally blocks, including zero // In preparsing, allow any number of catch/finally blocks, including zero
// of both. // of both.
Expect(i::Token::TRY, CHECK_OK); Expect(Token::TRY, CHECK_OK);
ParseBlock(CHECK_OK); ParseBlock(CHECK_OK);
bool catch_or_finally_seen = false; bool catch_or_finally_seen = false;
if (peek() == i::Token::CATCH) { if (peek() == Token::CATCH) {
Consume(i::Token::CATCH); Consume(Token::CATCH);
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
Identifier id = ParseIdentifier(CHECK_OK); Identifier id = ParseIdentifier(CHECK_OK);
if (!is_classic_mode() && !id.IsValidStrictVariable()) { if (!is_classic_mode() && !id.IsValidStrictVariable()) {
StrictModeIdentifierViolation(scanner()->location(), StrictModeIdentifierViolation(scanner()->location(),
...@@ -758,14 +758,14 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) { ...@@ -758,14 +758,14 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
ok); ok);
return Statement::Default(); return Statement::Default();
} }
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
{ Scope::InsideWith iw(scope_); { Scope::InsideWith iw(scope_);
ParseBlock(CHECK_OK); ParseBlock(CHECK_OK);
} }
catch_or_finally_seen = true; catch_or_finally_seen = true;
} }
if (peek() == i::Token::FINALLY) { if (peek() == Token::FINALLY) {
Consume(i::Token::FINALLY); Consume(Token::FINALLY);
ParseBlock(CHECK_OK); ParseBlock(CHECK_OK);
catch_or_finally_seen = true; catch_or_finally_seen = true;
} }
...@@ -783,7 +783,7 @@ PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) { ...@@ -783,7 +783,7 @@ PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) {
// DebuggerStatement :: // DebuggerStatement ::
// 'debugger' ';' // 'debugger' ';'
Expect(i::Token::DEBUGGER, CHECK_OK); Expect(Token::DEBUGGER, CHECK_OK);
ExpectSemicolon(ok); ExpectSemicolon(ok);
return Statement::Default(); return Statement::Default();
} }
...@@ -804,8 +804,8 @@ PreParser::Expression PreParser::ParseExpression(bool accept_IN, bool* ok) { ...@@ -804,8 +804,8 @@ PreParser::Expression PreParser::ParseExpression(bool accept_IN, bool* ok) {
// Expression ',' AssignmentExpression // Expression ',' AssignmentExpression
Expression result = ParseAssignmentExpression(accept_IN, CHECK_OK); Expression result = ParseAssignmentExpression(accept_IN, CHECK_OK);
while (peek() == i::Token::COMMA) { while (peek() == Token::COMMA) {
Expect(i::Token::COMMA, CHECK_OK); Expect(Token::COMMA, CHECK_OK);
ParseAssignmentExpression(accept_IN, CHECK_OK); ParseAssignmentExpression(accept_IN, CHECK_OK);
result = Expression::Default(); result = Expression::Default();
} }
...@@ -821,14 +821,14 @@ PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, ...@@ -821,14 +821,14 @@ PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN,
// YieldExpression // YieldExpression
// LeftHandSideExpression AssignmentOperator AssignmentExpression // LeftHandSideExpression AssignmentOperator AssignmentExpression
if (scope_->is_generator() && peek() == i::Token::YIELD) { if (scope_->is_generator() && peek() == Token::YIELD) {
return ParseYieldExpression(ok); return ParseYieldExpression(ok);
} }
i::Scanner::Location before = scanner()->peek_location(); Scanner::Location before = scanner()->peek_location();
Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK);
if (!i::Token::IsAssignmentOp(peek())) { if (!Token::IsAssignmentOp(peek())) {
// Parsed conditional expression only (no assignment). // Parsed conditional expression only (no assignment).
return expression; return expression;
} }
...@@ -836,17 +836,17 @@ PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, ...@@ -836,17 +836,17 @@ PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN,
if (!is_classic_mode() && if (!is_classic_mode() &&
expression.IsIdentifier() && expression.IsIdentifier() &&
expression.AsIdentifier().IsEvalOrArguments()) { expression.AsIdentifier().IsEvalOrArguments()) {
i::Scanner::Location after = scanner()->location(); Scanner::Location after = scanner()->location();
ReportMessageAt(before.beg_pos, after.end_pos, ReportMessageAt(before.beg_pos, after.end_pos,
"strict_lhs_assignment", NULL); "strict_lhs_assignment", NULL);
*ok = false; *ok = false;
return Expression::Default(); return Expression::Default();
} }
i::Token::Value op = Next(); // Get assignment operator. Token::Value op = Next(); // Get assignment operator.
ParseAssignmentExpression(accept_IN, CHECK_OK); ParseAssignmentExpression(accept_IN, CHECK_OK);
if ((op == i::Token::ASSIGN) && expression.IsThisProperty()) { if ((op == Token::ASSIGN) && expression.IsThisProperty()) {
scope_->AddProperty(); scope_->AddProperty();
} }
...@@ -858,8 +858,8 @@ PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, ...@@ -858,8 +858,8 @@ PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN,
PreParser::Expression PreParser::ParseYieldExpression(bool* ok) { PreParser::Expression PreParser::ParseYieldExpression(bool* ok) {
// YieldExpression :: // YieldExpression ::
// 'yield' '*'? AssignmentExpression // 'yield' '*'? AssignmentExpression
Consume(i::Token::YIELD); Consume(Token::YIELD);
Check(i::Token::MUL); Check(Token::MUL);
ParseAssignmentExpression(false, CHECK_OK); ParseAssignmentExpression(false, CHECK_OK);
...@@ -876,13 +876,13 @@ PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN, ...@@ -876,13 +876,13 @@ PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN,
// We start using the binary expression parser for prec >= 4 only! // We start using the binary expression parser for prec >= 4 only!
Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
if (peek() != i::Token::CONDITIONAL) return expression; if (peek() != Token::CONDITIONAL) return expression;
Consume(i::Token::CONDITIONAL); Consume(Token::CONDITIONAL);
// In parsing the first assignment expression in conditional // In parsing the first assignment expression in conditional
// expressions we always accept the 'in' keyword; see ECMA-262, // expressions we always accept the 'in' keyword; see ECMA-262,
// section 11.12, page 58. // section 11.12, page 58.
ParseAssignmentExpression(true, CHECK_OK); ParseAssignmentExpression(true, CHECK_OK);
Expect(i::Token::COLON, CHECK_OK); Expect(Token::COLON, CHECK_OK);
ParseAssignmentExpression(accept_IN, CHECK_OK); ParseAssignmentExpression(accept_IN, CHECK_OK);
return Expression::Default(); return Expression::Default();
} }
...@@ -918,19 +918,19 @@ PreParser::Expression PreParser::ParseUnaryExpression(bool* ok) { ...@@ -918,19 +918,19 @@ PreParser::Expression PreParser::ParseUnaryExpression(bool* ok) {
// '~' UnaryExpression // '~' UnaryExpression
// '!' UnaryExpression // '!' UnaryExpression
i::Token::Value op = peek(); Token::Value op = peek();
if (i::Token::IsUnaryOp(op)) { if (Token::IsUnaryOp(op)) {
op = Next(); op = Next();
ParseUnaryExpression(ok); ParseUnaryExpression(ok);
return Expression::Default(); return Expression::Default();
} else if (i::Token::IsCountOp(op)) { } else if (Token::IsCountOp(op)) {
op = Next(); op = Next();
i::Scanner::Location before = scanner()->peek_location(); Scanner::Location before = scanner()->peek_location();
Expression expression = ParseUnaryExpression(CHECK_OK); Expression expression = ParseUnaryExpression(CHECK_OK);
if (!is_classic_mode() && if (!is_classic_mode() &&
expression.IsIdentifier() && expression.IsIdentifier() &&
expression.AsIdentifier().IsEvalOrArguments()) { expression.AsIdentifier().IsEvalOrArguments()) {
i::Scanner::Location after = scanner()->location(); Scanner::Location after = scanner()->location();
ReportMessageAt(before.beg_pos, after.end_pos, ReportMessageAt(before.beg_pos, after.end_pos,
"strict_lhs_prefix", NULL); "strict_lhs_prefix", NULL);
*ok = false; *ok = false;
...@@ -946,14 +946,14 @@ PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { ...@@ -946,14 +946,14 @@ PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) {
// PostfixExpression :: // PostfixExpression ::
// LeftHandSideExpression ('++' | '--')? // LeftHandSideExpression ('++' | '--')?
i::Scanner::Location before = scanner()->peek_location(); Scanner::Location before = scanner()->peek_location();
Expression expression = ParseLeftHandSideExpression(CHECK_OK); Expression expression = ParseLeftHandSideExpression(CHECK_OK);
if (!scanner()->HasAnyLineTerminatorBeforeNext() && if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
i::Token::IsCountOp(peek())) { Token::IsCountOp(peek())) {
if (!is_classic_mode() && if (!is_classic_mode() &&
expression.IsIdentifier() && expression.IsIdentifier() &&
expression.AsIdentifier().IsEvalOrArguments()) { expression.AsIdentifier().IsEvalOrArguments()) {
i::Scanner::Location after = scanner()->location(); Scanner::Location after = scanner()->location();
ReportMessageAt(before.beg_pos, after.end_pos, ReportMessageAt(before.beg_pos, after.end_pos,
"strict_lhs_postfix", NULL); "strict_lhs_postfix", NULL);
*ok = false; *ok = false;
...@@ -971,7 +971,7 @@ PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) { ...@@ -971,7 +971,7 @@ PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) {
// (NewExpression | MemberExpression) ... // (NewExpression | MemberExpression) ...
Expression result = Expression::Default(); Expression result = Expression::Default();
if (peek() == i::Token::NEW) { if (peek() == Token::NEW) {
result = ParseNewExpression(CHECK_OK); result = ParseNewExpression(CHECK_OK);
} else { } else {
result = ParseMemberExpression(CHECK_OK); result = ParseMemberExpression(CHECK_OK);
...@@ -979,10 +979,10 @@ PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) { ...@@ -979,10 +979,10 @@ PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) {
while (true) { while (true) {
switch (peek()) { switch (peek()) {
case i::Token::LBRACK: { case Token::LBRACK: {
Consume(i::Token::LBRACK); Consume(Token::LBRACK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RBRACK, CHECK_OK); Expect(Token::RBRACK, CHECK_OK);
if (result.IsThis()) { if (result.IsThis()) {
result = Expression::ThisProperty(); result = Expression::ThisProperty();
} else { } else {
...@@ -991,14 +991,14 @@ PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) { ...@@ -991,14 +991,14 @@ PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) {
break; break;
} }
case i::Token::LPAREN: { case Token::LPAREN: {
ParseArguments(CHECK_OK); ParseArguments(CHECK_OK);
result = Expression::Default(); result = Expression::Default();
break; break;
} }
case i::Token::PERIOD: { case Token::PERIOD: {
Consume(i::Token::PERIOD); Consume(Token::PERIOD);
ParseIdentifierName(CHECK_OK); ParseIdentifierName(CHECK_OK);
if (result.IsThis()) { if (result.IsThis()) {
result = Expression::ThisProperty(); result = Expression::ThisProperty();
...@@ -1029,9 +1029,9 @@ PreParser::Expression PreParser::ParseNewExpression(bool* ok) { ...@@ -1029,9 +1029,9 @@ PreParser::Expression PreParser::ParseNewExpression(bool* ok) {
// lists as long as it has 'new' prefixes left // lists as long as it has 'new' prefixes left
unsigned new_count = 0; unsigned new_count = 0;
do { do {
Consume(i::Token::NEW); Consume(Token::NEW);
new_count++; new_count++;
} while (peek() == i::Token::NEW); } while (peek() == Token::NEW);
return ParseMemberWithNewPrefixesExpression(new_count, ok); return ParseMemberWithNewPrefixesExpression(new_count, ok);
} }
...@@ -1050,10 +1050,10 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( ...@@ -1050,10 +1050,10 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression(
// Parse the initial primary or function expression. // Parse the initial primary or function expression.
Expression result = Expression::Default(); Expression result = Expression::Default();
if (peek() == i::Token::FUNCTION) { if (peek() == Token::FUNCTION) {
Consume(i::Token::FUNCTION); Consume(Token::FUNCTION);
bool is_generator = allow_generators() && Check(i::Token::MUL); bool is_generator = allow_generators() && Check(Token::MUL);
Identifier identifier = Identifier::Default(); Identifier identifier = Identifier::Default();
if (peek_any_identifier()) { if (peek_any_identifier()) {
identifier = ParseIdentifier(CHECK_OK); identifier = ParseIdentifier(CHECK_OK);
...@@ -1072,10 +1072,10 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( ...@@ -1072,10 +1072,10 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression(
while (true) { while (true) {
switch (peek()) { switch (peek()) {
case i::Token::LBRACK: { case Token::LBRACK: {
Consume(i::Token::LBRACK); Consume(Token::LBRACK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RBRACK, CHECK_OK); Expect(Token::RBRACK, CHECK_OK);
if (result.IsThis()) { if (result.IsThis()) {
result = Expression::ThisProperty(); result = Expression::ThisProperty();
} else { } else {
...@@ -1083,8 +1083,8 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( ...@@ -1083,8 +1083,8 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression(
} }
break; break;
} }
case i::Token::PERIOD: { case Token::PERIOD: {
Consume(i::Token::PERIOD); Consume(Token::PERIOD);
ParseIdentifierName(CHECK_OK); ParseIdentifierName(CHECK_OK);
if (result.IsThis()) { if (result.IsThis()) {
result = Expression::ThisProperty(); result = Expression::ThisProperty();
...@@ -1093,7 +1093,7 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( ...@@ -1093,7 +1093,7 @@ PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression(
} }
break; break;
} }
case i::Token::LPAREN: { case Token::LPAREN: {
if (new_count == 0) return result; if (new_count == 0) return result;
// Consume one of the new prefixes (already parsed). // Consume one of the new prefixes (already parsed).
ParseArguments(CHECK_OK); ParseArguments(CHECK_OK);
...@@ -1124,59 +1124,59 @@ PreParser::Expression PreParser::ParsePrimaryExpression(bool* ok) { ...@@ -1124,59 +1124,59 @@ PreParser::Expression PreParser::ParsePrimaryExpression(bool* ok) {
Expression result = Expression::Default(); Expression result = Expression::Default();
switch (peek()) { switch (peek()) {
case i::Token::THIS: { case Token::THIS: {
Next(); Next();
result = Expression::This(); result = Expression::This();
break; break;
} }
case i::Token::FUTURE_RESERVED_WORD: case Token::FUTURE_RESERVED_WORD:
case i::Token::FUTURE_STRICT_RESERVED_WORD: case Token::FUTURE_STRICT_RESERVED_WORD:
case i::Token::YIELD: case Token::YIELD:
case i::Token::IDENTIFIER: { case Token::IDENTIFIER: {
Identifier id = ParseIdentifier(CHECK_OK); Identifier id = ParseIdentifier(CHECK_OK);
result = Expression::FromIdentifier(id); result = Expression::FromIdentifier(id);
break; break;
} }
case i::Token::NULL_LITERAL: case Token::NULL_LITERAL:
case i::Token::TRUE_LITERAL: case Token::TRUE_LITERAL:
case i::Token::FALSE_LITERAL: case Token::FALSE_LITERAL:
case i::Token::NUMBER: { case Token::NUMBER: {
Next(); Next();
break; break;
} }
case i::Token::STRING: { case Token::STRING: {
Next(); Next();
result = GetStringSymbol(); result = GetStringSymbol();
break; break;
} }
case i::Token::ASSIGN_DIV: case Token::ASSIGN_DIV:
result = ParseRegExpLiteral(true, CHECK_OK); result = ParseRegExpLiteral(true, CHECK_OK);
break; break;
case i::Token::DIV: case Token::DIV:
result = ParseRegExpLiteral(false, CHECK_OK); result = ParseRegExpLiteral(false, CHECK_OK);
break; break;
case i::Token::LBRACK: case Token::LBRACK:
result = ParseArrayLiteral(CHECK_OK); result = ParseArrayLiteral(CHECK_OK);
break; break;
case i::Token::LBRACE: case Token::LBRACE:
result = ParseObjectLiteral(CHECK_OK); result = ParseObjectLiteral(CHECK_OK);
break; break;
case i::Token::LPAREN: case Token::LPAREN:
Consume(i::Token::LPAREN); Consume(Token::LPAREN);
parenthesized_function_ = (peek() == i::Token::FUNCTION); parenthesized_function_ = (peek() == Token::FUNCTION);
result = ParseExpression(true, CHECK_OK); result = ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
result = result.Parenthesize(); result = result.Parenthesize();
break; break;
case i::Token::MOD: case Token::MOD:
result = ParseV8Intrinsic(CHECK_OK); result = ParseV8Intrinsic(CHECK_OK);
break; break;
...@@ -1194,16 +1194,16 @@ PreParser::Expression PreParser::ParsePrimaryExpression(bool* ok) { ...@@ -1194,16 +1194,16 @@ PreParser::Expression PreParser::ParsePrimaryExpression(bool* ok) {
PreParser::Expression PreParser::ParseArrayLiteral(bool* ok) { PreParser::Expression PreParser::ParseArrayLiteral(bool* ok) {
// ArrayLiteral :: // ArrayLiteral ::
// '[' Expression? (',' Expression?)* ']' // '[' Expression? (',' Expression?)* ']'
Expect(i::Token::LBRACK, CHECK_OK); Expect(Token::LBRACK, CHECK_OK);
while (peek() != i::Token::RBRACK) { while (peek() != Token::RBRACK) {
if (peek() != i::Token::COMMA) { if (peek() != Token::COMMA) {
ParseAssignmentExpression(true, CHECK_OK); ParseAssignmentExpression(true, CHECK_OK);
} }
if (peek() != i::Token::RBRACK) { if (peek() != Token::RBRACK) {
Expect(i::Token::COMMA, CHECK_OK); Expect(Token::COMMA, CHECK_OK);
} }
} }
Expect(i::Token::RBRACK, CHECK_OK); Expect(Token::RBRACK, CHECK_OK);
scope_->NextMaterializedLiteralIndex(); scope_->NextMaterializedLiteralIndex();
return Expression::Default(); return Expression::Default();
...@@ -1219,24 +1219,24 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { ...@@ -1219,24 +1219,24 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) {
ObjectLiteralChecker checker(this, language_mode()); ObjectLiteralChecker checker(this, language_mode());
Expect(i::Token::LBRACE, CHECK_OK); Expect(Token::LBRACE, CHECK_OK);
while (peek() != i::Token::RBRACE) { while (peek() != Token::RBRACE) {
i::Token::Value next = peek(); Token::Value next = peek();
switch (next) { switch (next) {
case i::Token::IDENTIFIER: case Token::IDENTIFIER:
case i::Token::FUTURE_RESERVED_WORD: case Token::FUTURE_RESERVED_WORD:
case i::Token::FUTURE_STRICT_RESERVED_WORD: { case Token::FUTURE_STRICT_RESERVED_WORD: {
bool is_getter = false; bool is_getter = false;
bool is_setter = false; bool is_setter = false;
ParseIdentifierNameOrGetOrSet(&is_getter, &is_setter, CHECK_OK); ParseIdentifierNameOrGetOrSet(&is_getter, &is_setter, CHECK_OK);
if ((is_getter || is_setter) && peek() != i::Token::COLON) { if ((is_getter || is_setter) && peek() != Token::COLON) {
i::Token::Value name = Next(); Token::Value name = Next();
bool is_keyword = i::Token::IsKeyword(name); bool is_keyword = Token::IsKeyword(name);
if (name != i::Token::IDENTIFIER && if (name != Token::IDENTIFIER &&
name != i::Token::FUTURE_RESERVED_WORD && name != Token::FUTURE_RESERVED_WORD &&
name != i::Token::FUTURE_STRICT_RESERVED_WORD && name != Token::FUTURE_STRICT_RESERVED_WORD &&
name != i::Token::NUMBER && name != Token::NUMBER &&
name != i::Token::STRING && name != Token::STRING &&
!is_keyword) { !is_keyword) {
*ok = false; *ok = false;
return Expression::Default(); return Expression::Default();
...@@ -1247,25 +1247,25 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { ...@@ -1247,25 +1247,25 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) {
PropertyKind type = is_getter ? kGetterProperty : kSetterProperty; PropertyKind type = is_getter ? kGetterProperty : kSetterProperty;
checker.CheckProperty(name, type, CHECK_OK); checker.CheckProperty(name, type, CHECK_OK);
ParseFunctionLiteral(false, CHECK_OK); ParseFunctionLiteral(false, CHECK_OK);
if (peek() != i::Token::RBRACE) { if (peek() != Token::RBRACE) {
Expect(i::Token::COMMA, CHECK_OK); Expect(Token::COMMA, CHECK_OK);
} }
continue; // restart the while continue; // restart the while
} }
checker.CheckProperty(next, kValueProperty, CHECK_OK); checker.CheckProperty(next, kValueProperty, CHECK_OK);
break; break;
} }
case i::Token::STRING: case Token::STRING:
Consume(next); Consume(next);
checker.CheckProperty(next, kValueProperty, CHECK_OK); checker.CheckProperty(next, kValueProperty, CHECK_OK);
GetStringSymbol(); GetStringSymbol();
break; break;
case i::Token::NUMBER: case Token::NUMBER:
Consume(next); Consume(next);
checker.CheckProperty(next, kValueProperty, CHECK_OK); checker.CheckProperty(next, kValueProperty, CHECK_OK);
break; break;
default: default:
if (i::Token::IsKeyword(next)) { if (Token::IsKeyword(next)) {
Consume(next); Consume(next);
checker.CheckProperty(next, kValueProperty, CHECK_OK); checker.CheckProperty(next, kValueProperty, CHECK_OK);
} else { } else {
...@@ -1275,13 +1275,13 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { ...@@ -1275,13 +1275,13 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) {
} }
} }
Expect(i::Token::COLON, CHECK_OK); Expect(Token::COLON, CHECK_OK);
ParseAssignmentExpression(true, CHECK_OK); ParseAssignmentExpression(true, CHECK_OK);
// TODO(1240767): Consider allowing trailing comma. // TODO(1240767): Consider allowing trailing comma.
if (peek() != i::Token::RBRACE) Expect(i::Token::COMMA, CHECK_OK); if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK);
} }
Expect(i::Token::RBRACE, CHECK_OK); Expect(Token::RBRACE, CHECK_OK);
scope_->NextMaterializedLiteralIndex(); scope_->NextMaterializedLiteralIndex();
return Expression::Default(); return Expression::Default();
...@@ -1314,21 +1314,21 @@ PreParser::Arguments PreParser::ParseArguments(bool* ok) { ...@@ -1314,21 +1314,21 @@ PreParser::Arguments PreParser::ParseArguments(bool* ok) {
// Arguments :: // Arguments ::
// '(' (AssignmentExpression)*[','] ')' // '(' (AssignmentExpression)*[','] ')'
Expect(i::Token::LPAREN, ok); Expect(Token::LPAREN, ok);
if (!*ok) return -1; if (!*ok) return -1;
bool done = (peek() == i::Token::RPAREN); bool done = (peek() == Token::RPAREN);
int argc = 0; int argc = 0;
while (!done) { while (!done) {
ParseAssignmentExpression(true, ok); ParseAssignmentExpression(true, ok);
if (!*ok) return -1; if (!*ok) return -1;
argc++; argc++;
done = (peek() == i::Token::RPAREN); done = (peek() == Token::RPAREN);
if (!done) { if (!done) {
Expect(i::Token::COMMA, ok); Expect(Token::COMMA, ok);
if (!*ok) return -1; if (!*ok) return -1;
} }
} }
Expect(i::Token::RPAREN, ok); Expect(Token::RPAREN, ok);
return argc; return argc;
} }
...@@ -1345,10 +1345,10 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator, ...@@ -1345,10 +1345,10 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator,
function_scope.set_is_generator(is_generator); function_scope.set_is_generator(is_generator);
// FormalParameterList :: // FormalParameterList ::
// '(' (Identifier)*[','] ')' // '(' (Identifier)*[','] ')'
Expect(i::Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
int start_position = position(); int start_position = position();
bool done = (peek() == i::Token::RPAREN); bool done = (peek() == Token::RPAREN);
i::DuplicateFinder duplicate_finder(scanner()->unicode_cache()); DuplicateFinder duplicate_finder(scanner()->unicode_cache());
while (!done) { while (!done) {
Identifier id = ParseIdentifier(CHECK_OK); Identifier id = ParseIdentifier(CHECK_OK);
if (!id.IsValidStrictVariable()) { if (!id.IsValidStrictVariable()) {
...@@ -1371,12 +1371,12 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator, ...@@ -1371,12 +1371,12 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator,
"strict_param_dupe", "strict_param_dupe",
CHECK_OK); CHECK_OK);
} }
done = (peek() == i::Token::RPAREN); done = (peek() == Token::RPAREN);
if (!done) { if (!done) {
Expect(i::Token::COMMA, CHECK_OK); Expect(Token::COMMA, CHECK_OK);
} }
} }
Expect(i::Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
// Determine if the function will be lazily compiled. // Determine if the function will be lazily compiled.
// Currently only happens to top-level functions. // Currently only happens to top-level functions.
...@@ -1386,13 +1386,13 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator, ...@@ -1386,13 +1386,13 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator,
!parenthesized_function_); !parenthesized_function_);
parenthesized_function_ = false; parenthesized_function_ = false;
Expect(i::Token::LBRACE, CHECK_OK); Expect(Token::LBRACE, CHECK_OK);
if (is_lazily_compiled) { if (is_lazily_compiled) {
ParseLazyFunctionLiteralBody(CHECK_OK); ParseLazyFunctionLiteralBody(CHECK_OK);
} else { } else {
ParseSourceElements(i::Token::RBRACE, ok); ParseSourceElements(Token::RBRACE, ok);
} }
Expect(i::Token::RBRACE, CHECK_OK); Expect(Token::RBRACE, CHECK_OK);
if (!is_classic_mode()) { if (!is_classic_mode()) {
int end_position = scanner()->location().end_pos; int end_position = scanner()->location().end_pos;
...@@ -1408,12 +1408,12 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator, ...@@ -1408,12 +1408,12 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator,
void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
int body_start = position(); int body_start = position();
log_->PauseRecording(); log_->PauseRecording();
ParseSourceElements(i::Token::RBRACE, ok); ParseSourceElements(Token::RBRACE, ok);
log_->ResumeRecording(); log_->ResumeRecording();
if (!*ok) return; if (!*ok) return;
// Position right after terminal '}'. // Position right after terminal '}'.
ASSERT_EQ(i::Token::RBRACE, scanner()->peek()); ASSERT_EQ(Token::RBRACE, scanner()->peek());
int body_end = scanner()->peek_location().end_pos; int body_end = scanner()->peek_location().end_pos;
log_->LogFunction(body_start, body_end, log_->LogFunction(body_start, body_end,
scope_->materialized_literal_count(), scope_->materialized_literal_count(),
...@@ -1425,7 +1425,7 @@ void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { ...@@ -1425,7 +1425,7 @@ void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) {
// CallRuntime :: // CallRuntime ::
// '%' Identifier Arguments // '%' Identifier Arguments
Expect(i::Token::MOD, CHECK_OK); Expect(Token::MOD, CHECK_OK);
if (!allow_natives_syntax()) { if (!allow_natives_syntax()) {
*ok = false; *ok = false;
return Expression::Default(); return Expression::Default();
...@@ -1466,12 +1466,12 @@ PreParser::Expression PreParser::GetStringSymbol() { ...@@ -1466,12 +1466,12 @@ PreParser::Expression PreParser::GetStringSymbol() {
PreParser::Identifier PreParser::GetIdentifierSymbol() { PreParser::Identifier PreParser::GetIdentifierSymbol() {
LogSymbol(); LogSymbol();
if (scanner()->current_token() == i::Token::FUTURE_RESERVED_WORD) { if (scanner()->current_token() == Token::FUTURE_RESERVED_WORD) {
return Identifier::FutureReserved(); return Identifier::FutureReserved();
} else if (scanner()->current_token() == } else if (scanner()->current_token() ==
i::Token::FUTURE_STRICT_RESERVED_WORD) { Token::FUTURE_STRICT_RESERVED_WORD) {
return Identifier::FutureStrictReserved(); return Identifier::FutureStrictReserved();
} else if (scanner()->current_token() == i::Token::YIELD) { } else if (scanner()->current_token() == Token::YIELD) {
return Identifier::Yield(); return Identifier::Yield();
} }
if (scanner()->is_literal_ascii()) { if (scanner()->is_literal_ascii()) {
...@@ -1490,16 +1490,16 @@ PreParser::Identifier PreParser::GetIdentifierSymbol() { ...@@ -1490,16 +1490,16 @@ PreParser::Identifier PreParser::GetIdentifierSymbol() {
PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
i::Token::Value next = Next(); Token::Value next = Next();
switch (next) { switch (next) {
case i::Token::FUTURE_RESERVED_WORD: { case Token::FUTURE_RESERVED_WORD: {
i::Scanner::Location location = scanner()->location(); Scanner::Location location = scanner()->location();
ReportMessageAt(location.beg_pos, location.end_pos, ReportMessageAt(location.beg_pos, location.end_pos,
"reserved_word", NULL); "reserved_word", NULL);
*ok = false; *ok = false;
return GetIdentifierSymbol(); return GetIdentifierSymbol();
} }
case i::Token::YIELD: case Token::YIELD:
if (scope_->is_generator()) { if (scope_->is_generator()) {
// 'yield' in a generator is only valid as part of a YieldExpression. // 'yield' in a generator is only valid as part of a YieldExpression.
ReportMessageAt(scanner()->location(), "unexpected_token", "yield"); ReportMessageAt(scanner()->location(), "unexpected_token", "yield");
...@@ -1507,15 +1507,15 @@ PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { ...@@ -1507,15 +1507,15 @@ PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
return Identifier::Yield(); return Identifier::Yield();
} }
// FALLTHROUGH // FALLTHROUGH
case i::Token::FUTURE_STRICT_RESERVED_WORD: case Token::FUTURE_STRICT_RESERVED_WORD:
if (!is_classic_mode()) { if (!is_classic_mode()) {
i::Scanner::Location location = scanner()->location(); Scanner::Location location = scanner()->location();
ReportMessageAt(location.beg_pos, location.end_pos, ReportMessageAt(location.beg_pos, location.end_pos,
"strict_reserved_word", NULL); "strict_reserved_word", NULL);
*ok = false; *ok = false;
} }
// FALLTHROUGH // FALLTHROUGH
case i::Token::IDENTIFIER: case Token::IDENTIFIER:
return GetIdentifierSymbol(); return GetIdentifierSymbol();
default: default:
*ok = false; *ok = false;
...@@ -1524,7 +1524,7 @@ PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { ...@@ -1524,7 +1524,7 @@ PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
} }
void PreParser::SetStrictModeViolation(i::Scanner::Location location, void PreParser::SetStrictModeViolation(Scanner::Location location,
const char* type, const char* type,
bool* ok) { bool* ok) {
if (!is_classic_mode()) { if (!is_classic_mode()) {
...@@ -1548,7 +1548,7 @@ void PreParser::SetStrictModeViolation(i::Scanner::Location location, ...@@ -1548,7 +1548,7 @@ void PreParser::SetStrictModeViolation(i::Scanner::Location location,
void PreParser::CheckDelayedStrictModeViolation(int beg_pos, void PreParser::CheckDelayedStrictModeViolation(int beg_pos,
int end_pos, int end_pos,
bool* ok) { bool* ok) {
i::Scanner::Location location = strict_mode_violation_location_; Scanner::Location location = strict_mode_violation_location_;
if (location.IsValid() && if (location.IsValid() &&
location.beg_pos > beg_pos && location.end_pos < end_pos) { location.beg_pos > beg_pos && location.end_pos < end_pos) {
ReportMessageAt(location, strict_mode_violation_type_, NULL); ReportMessageAt(location, strict_mode_violation_type_, NULL);
...@@ -1557,7 +1557,7 @@ void PreParser::CheckDelayedStrictModeViolation(int beg_pos, ...@@ -1557,7 +1557,7 @@ void PreParser::CheckDelayedStrictModeViolation(int beg_pos,
} }
void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location, void PreParser::StrictModeIdentifierViolation(Scanner::Location location,
const char* eval_args_type, const char* eval_args_type,
Identifier identifier, Identifier identifier,
bool* ok) { bool* ok) {
...@@ -1578,17 +1578,16 @@ void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location, ...@@ -1578,17 +1578,16 @@ void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location,
PreParser::Identifier PreParser::ParseIdentifierName(bool* ok) { PreParser::Identifier PreParser::ParseIdentifierName(bool* ok) {
i::Token::Value next = Next(); Token::Value next = Next();
if (i::Token::IsKeyword(next)) { if (Token::IsKeyword(next)) {
int pos = position(); int pos = position();
const char* keyword = i::Token::String(next); const char* keyword = Token::String(next);
log_->LogAsciiSymbol(pos, i::Vector<const char>(keyword, log_->LogAsciiSymbol(pos, Vector<const char>(keyword, StrLength(keyword)));
i::StrLength(keyword)));
return Identifier::Default(); return Identifier::Default();
} }
if (next == i::Token::IDENTIFIER || if (next == Token::IDENTIFIER ||
next == i::Token::FUTURE_RESERVED_WORD || next == Token::FUTURE_RESERVED_WORD ||
next == i::Token::FUTURE_STRICT_RESERVED_WORD) { next == Token::FUTURE_STRICT_RESERVED_WORD) {
return GetIdentifierSymbol(); return GetIdentifierSymbol();
} }
*ok = false; *ok = false;
......
...@@ -218,10 +218,6 @@ class ParserBase { ...@@ -218,10 +218,6 @@ class ParserBase {
// rather it is to speed up properly written and correct programs. // rather it is to speed up properly written and correct programs.
// That means that contextual checks (like a label being declared where // That means that contextual checks (like a label being declared where
// it is used) are generally omitted. // it is used) are generally omitted.
typedef uint8_t byte;
namespace i = v8::internal;
class PreParser : public ParserBase { class PreParser : public ParserBase {
public: public:
enum PreParseResult { enum PreParseResult {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment