Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Unified Diff: src/preparser.cc

Issue 1218803006: Add a flag for legacy const semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add message tests Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index cfb8a3e3d53525ac0255bbb68e4738ac75185411..08d322b7d9a2b4ceb577667ad874ef54b322d134 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -192,15 +192,19 @@ PreParser::Statement PreParser::ParseStatementListItem(bool* ok) {
case Token::CLASS:
return ParseClassDeclaration(ok);
case Token::CONST:
- return ParseVariableStatement(kStatementListItem, ok);
+ if (allow_const()) {
+ return ParseVariableStatement(kStatementListItem, ok);
+ }
+ break;
case Token::LET:
if (is_strict(language_mode())) {
return ParseVariableStatement(kStatementListItem, ok);
}
- // Fall through.
+ break;
default:
- return ParseStatement(ok);
+ break;
}
+ return ParseStatement(ok);
}
@@ -392,7 +396,7 @@ PreParser::Statement PreParser::ParseSubStatement(bool* ok) {
// In ES6 CONST is not allowed as a Statement, only as a
// LexicalDeclaration, however we continue to allow it in sloppy mode for
// backwards compatibility.
- if (is_sloppy(language_mode())) {
+ if (is_sloppy(language_mode()) && allow_legacy_const()) {
return ParseVariableStatement(kStatement, ok);
}
@@ -508,7 +512,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
return Statement::Default();
}
Consume(Token::VAR);
- } else if (peek() == Token::CONST) {
+ } else if (peek() == Token::CONST && allow_const()) {
// TODO(ES6): The ES6 Draft Rev4 section 12.2.2 reads:
//
// ConstDeclaration : const ConstBinding (',' ConstBinding)* ';'
@@ -864,7 +868,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
bool is_let_identifier_expression = false;
if (peek() != Token::SEMICOLON) {
ForEachStatement::VisitMode mode;
- if (peek() == Token::VAR || peek() == Token::CONST ||
+ if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
(peek() == Token::LET && is_strict(language_mode()))) {
int decl_count;
Scanner::Location first_initializer_loc = Scanner::Location::invalid();
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698