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

Side by Side Diff: src/preparser.cc

Issue 1356783002: Stop emitting kSloppyLexical errors when --harmony-sloppy-let is enabled (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/parser.cc ('k') | no next file » | 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 !IsFutureStrictReserved(expr.AsIdentifier())); 693 !IsFutureStrictReserved(expr.AsIdentifier()));
694 Consume(Token::COLON); 694 Consume(Token::COLON);
695 Statement statement = ParseStatement(ok); 695 Statement statement = ParseStatement(ok);
696 return statement.IsJumpStatement() ? Statement::Default() : statement; 696 return statement.IsJumpStatement() ? Statement::Default() : statement;
697 // Preparsing is disabled for extensions (because the extension details 697 // Preparsing is disabled for extensions (because the extension details
698 // aren't passed to lazily compiled functions), so we don't 698 // aren't passed to lazily compiled functions), so we don't
699 // accept "native function" in the preparser. 699 // accept "native function" in the preparser.
700 } 700 }
701 // Parsed expression statement. 701 // Parsed expression statement.
702 // Detect attempts at 'let' declarations in sloppy mode. 702 // Detect attempts at 'let' declarations in sloppy mode.
703 if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && 703 if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
704 expr.IsIdentifier() && expr.AsIdentifier().IsLet()) { 704 is_sloppy(language_mode()) && expr.IsIdentifier() &&
705 expr.AsIdentifier().IsLet()) {
705 ReportMessage(MessageTemplate::kSloppyLexical, NULL); 706 ReportMessage(MessageTemplate::kSloppyLexical, NULL);
706 *ok = false; 707 *ok = false;
707 return Statement::Default(); 708 return Statement::Default();
708 } 709 }
709 ExpectSemicolon(CHECK_OK); 710 ExpectSemicolon(CHECK_OK);
710 return Statement::ExpressionStatement(expr); 711 return Statement::ExpressionStatement(expr);
711 } 712 }
712 713
713 714
714 PreParser::Statement PreParser::ParseIfStatement(bool* ok) { 715 PreParser::Statement PreParser::ParseIfStatement(bool* ok) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 ParseExpression(true, CHECK_OK); 954 ParseExpression(true, CHECK_OK);
954 Expect(Token::RPAREN, CHECK_OK); 955 Expect(Token::RPAREN, CHECK_OK);
955 ParseSubStatement(CHECK_OK); 956 ParseSubStatement(CHECK_OK);
956 return Statement::Default(); 957 return Statement::Default();
957 } 958 }
958 } 959 }
959 } 960 }
960 961
961 // Parsed initializer at this point. 962 // Parsed initializer at this point.
962 // Detect attempts at 'let' declarations in sloppy mode. 963 // Detect attempts at 'let' declarations in sloppy mode.
963 if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && 964 if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
964 is_let_identifier_expression) { 965 is_sloppy(language_mode()) && is_let_identifier_expression) {
965 ReportMessage(MessageTemplate::kSloppyLexical, NULL); 966 ReportMessage(MessageTemplate::kSloppyLexical, NULL);
966 *ok = false; 967 *ok = false;
967 return Statement::Default(); 968 return Statement::Default();
968 } 969 }
969 Expect(Token::SEMICOLON, CHECK_OK); 970 Expect(Token::SEMICOLON, CHECK_OK);
970 971
971 if (peek() != Token::SEMICOLON) { 972 if (peek() != Token::SEMICOLON) {
972 ParseExpression(true, CHECK_OK); 973 ParseExpression(true, CHECK_OK);
973 } 974 }
974 Expect(Token::SEMICOLON, CHECK_OK); 975 Expect(Token::SEMICOLON, CHECK_OK);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 1232
1232 DCHECK(!spread_pos.IsValid()); 1233 DCHECK(!spread_pos.IsValid());
1233 1234
1234 return Expression::Default(); 1235 return Expression::Default();
1235 } 1236 }
1236 1237
1237 #undef CHECK_OK 1238 #undef CHECK_OK
1238 1239
1239 1240
1240 } } // v8::internal 1241 } } // v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698