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

Side by Side Diff: src/preparser.cc

Issue 1007783002: Remove --harmony-scoping flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CR feedback Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/preparser.h ('k') | src/scanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // LetOrConst BindingList[?In, ?Yield] ; 167 // LetOrConst BindingList[?In, ?Yield] ;
168 168
169 switch (peek()) { 169 switch (peek()) {
170 case Token::FUNCTION: 170 case Token::FUNCTION:
171 return ParseFunctionDeclaration(ok); 171 return ParseFunctionDeclaration(ok);
172 case Token::CLASS: 172 case Token::CLASS:
173 return ParseClassDeclaration(ok); 173 return ParseClassDeclaration(ok);
174 case Token::CONST: 174 case Token::CONST:
175 return ParseVariableStatement(kStatementListItem, ok); 175 return ParseVariableStatement(kStatementListItem, ok);
176 case Token::LET: 176 case Token::LET:
177 DCHECK(allow_harmony_scoping());
178 if (is_strict(language_mode())) { 177 if (is_strict(language_mode())) {
179 return ParseVariableStatement(kStatementListItem, ok); 178 return ParseVariableStatement(kStatementListItem, ok);
180 } 179 }
181 // Fall through. 180 // Fall through.
182 default: 181 default:
183 return ParseStatement(ok); 182 return ParseStatement(ok);
184 } 183 }
185 } 184 }
186 185
187 186
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 375
377 PreParser::Statement PreParser::ParseBlock(bool* ok) { 376 PreParser::Statement PreParser::ParseBlock(bool* ok) {
378 // Block :: 377 // Block ::
379 // '{' Statement* '}' 378 // '{' Statement* '}'
380 379
381 // Note that a Block does not introduce a new execution scope! 380 // Note that a Block does not introduce a new execution scope!
382 // (ECMA-262, 3rd, 12.2) 381 // (ECMA-262, 3rd, 12.2)
383 // 382 //
384 Expect(Token::LBRACE, CHECK_OK); 383 Expect(Token::LBRACE, CHECK_OK);
385 while (peek() != Token::RBRACE) { 384 while (peek() != Token::RBRACE) {
386 if (allow_harmony_scoping() && is_strict(language_mode())) { 385 if (is_strict(language_mode())) {
387 ParseStatementListItem(CHECK_OK); 386 ParseStatementListItem(CHECK_OK);
388 } else { 387 } else {
389 ParseStatement(CHECK_OK); 388 ParseStatement(CHECK_OK);
390 } 389 }
391 } 390 }
392 Expect(Token::RBRACE, ok); 391 Expect(Token::RBRACE, ok);
393 return Statement::Default(); 392 return Statement::Default();
394 } 393 }
395 394
396 395
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // 448 //
450 // * It is a Syntax Error if the code that matches this production is not 449 // * It is a Syntax Error if the code that matches this production is not
451 // contained in extended code. 450 // contained in extended code.
452 // 451 //
453 // However disallowing const in sloppy mode will break compatibility with 452 // However disallowing const in sloppy mode will break compatibility with
454 // existing pages. Therefore we keep allowing const with the old 453 // existing pages. Therefore we keep allowing const with the old
455 // non-harmony semantics in sloppy mode. 454 // non-harmony semantics in sloppy mode.
456 Consume(Token::CONST); 455 Consume(Token::CONST);
457 if (is_strict(language_mode())) { 456 if (is_strict(language_mode())) {
458 DCHECK(var_context != kStatement); 457 DCHECK(var_context != kStatement);
459 if (!allow_harmony_scoping()) {
460 Scanner::Location location = scanner()->peek_location();
461 ReportMessageAt(location, "strict_const");
462 *ok = false;
463 return Statement::Default();
464 }
465 is_strict_const = true; 458 is_strict_const = true;
466 require_initializer = var_context != kForStatement; 459 require_initializer = var_context != kForStatement;
467 } 460 }
468 } else if (peek() == Token::LET && is_strict(language_mode())) { 461 } else if (peek() == Token::LET && is_strict(language_mode())) {
469 Consume(Token::LET); 462 Consume(Token::LET);
470 DCHECK(var_context != kStatement); 463 DCHECK(var_context != kStatement);
471 } else { 464 } else {
472 *ok = false; 465 *ok = false;
473 return Statement::Default(); 466 return Statement::Default();
474 } 467 }
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 1016 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
1024 ParseArguments(ok); 1017 ParseArguments(ok);
1025 1018
1026 return Expression::Default(); 1019 return Expression::Default();
1027 } 1020 }
1028 1021
1029 #undef CHECK_OK 1022 #undef CHECK_OK
1030 1023
1031 1024
1032 } } // v8::internal 1025 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698