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

Unified Diff: src/parser.cc

Issue 672193002: Revert "harmony-scoping: Allow 'const' iteration variables in strict mode." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « no previous file | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index b63d76d5ad8e0f90539fb1739b55af8cc5c45381..bec0a4bd571e29dda80149b669062641c40b81e1 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2156,7 +2156,6 @@ Block* Parser::ParseVariableDeclarations(
Block* block = factory()->NewBlock(NULL, 1, true, pos);
int nvars = 0; // the number of variables declared
const AstRawString* name = NULL;
- bool is_for_iteration_variable;
do {
if (fni_ != NULL) fni_->Enter();
@@ -2180,13 +2179,6 @@ Block* Parser::ParseVariableDeclarations(
// For let/const declarations in harmony mode, we can also immediately
// pre-resolve the proxy because it resides in the same scope as the
// declaration.
- is_for_iteration_variable =
- var_context == kForStatement &&
- (peek() == Token::IN || PeekContextualKeyword(CStrVector("of")));
- if (is_for_iteration_variable && mode == CONST) {
- needs_init = false;
- }
-
Interface* interface =
is_const ? Interface::NewConst() : Interface::NewValue();
VariableProxy* proxy = NewUnresolved(name, mode, interface);
@@ -2232,8 +2224,7 @@ Block* Parser::ParseVariableDeclarations(
Expression* value = NULL;
int pos = -1;
// Harmony consts have non-optional initializers.
- if (peek() == Token::ASSIGN ||
- (mode == CONST && !is_for_iteration_variable)) {
+ if (peek() == Token::ASSIGN || mode == CONST) {
Expect(Token::ASSIGN, CHECK_OK);
pos = position();
value = ParseAssignmentExpression(var_context != kForStatement, CHECK_OK);
@@ -2366,7 +2357,7 @@ Block* Parser::ParseVariableDeclarations(
// If there was a single non-const declaration, return it in the output
// parameter for possible use by for/in.
- if (nvars == 1 && (!is_const || is_for_iteration_variable)) {
+ if (nvars == 1 && !is_const) {
*out = name;
}
@@ -3103,8 +3094,7 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
Expect(Token::LPAREN, CHECK_OK);
for_scope->set_start_position(scanner()->location().beg_pos);
if (peek() != Token::SEMICOLON) {
- if (peek() == Token::VAR ||
- (peek() == Token::CONST && strict_mode() == SLOPPY)) {
+ if (peek() == Token::VAR || peek() == Token::CONST) {
bool is_const = peek() == Token::CONST;
const AstRawString* name = NULL;
VariableDeclarationProperties decl_props = kHasNoInitializers;
@@ -3141,10 +3131,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
} else {
init = variable_statement;
}
- } else if ((peek() == Token::LET || peek() == Token::CONST) &&
- strict_mode() == STRICT) {
+ } else if (peek() == Token::LET && strict_mode() == STRICT) {
DCHECK(allow_harmony_scoping());
- bool is_const = peek() == Token::CONST;
const AstRawString* name = NULL;
VariableDeclarationProperties decl_props = kHasNoInitializers;
Block* variable_statement =
@@ -3157,13 +3145,13 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
if (accept_IN && CheckInOrOf(accept_OF, &mode)) {
// Rewrite a for-in statement of the form
//
- // for (let/const x in e) b
+ // for (let x in e) b
//
// into
//
// <let x' be a temporary variable>
// for (x' in e) {
- // let/const x;
+ // let x;
// x = x';
// b;
// }
@@ -3183,13 +3171,13 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
scope_ = for_scope;
Expect(Token::RPAREN, CHECK_OK);
- VariableProxy* each = scope_->NewUnresolved(factory(), name);
+ VariableProxy* each =
+ scope_->NewUnresolved(factory(), name, Interface::NewValue());
Statement* body = ParseStatement(NULL, CHECK_OK);
Block* body_block =
factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition);
- Token::Value init_op = is_const ? Token::INIT_CONST : Token::ASSIGN;
Assignment* assignment = factory()->NewAssignment(
- init_op, each, temp_proxy, RelocInfo::kNoPosition);
+ Token::ASSIGN, each, temp_proxy, RelocInfo::kNoPosition);
Statement* assignment_statement = factory()->NewExpressionStatement(
assignment, RelocInfo::kNoPosition);
body_block->AddStatement(variable_statement, zone());
« no previous file with comments | « no previous file | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698