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

Side by Side Diff: src/parser.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 | « no previous file | src/preparser.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/parser.h" 5 #include "src/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 !scanner()->HasAnyLineTerminatorBeforeNext() && expr != NULL && 2706 !scanner()->HasAnyLineTerminatorBeforeNext() && expr != NULL &&
2707 expr->AsVariableProxy() != NULL && 2707 expr->AsVariableProxy() != NULL &&
2708 expr->AsVariableProxy()->raw_name() == 2708 expr->AsVariableProxy()->raw_name() ==
2709 ast_value_factory()->native_string() && 2709 ast_value_factory()->native_string() &&
2710 !scanner()->literal_contains_escapes()) { 2710 !scanner()->literal_contains_escapes()) {
2711 return ParseNativeDeclaration(ok); 2711 return ParseNativeDeclaration(ok);
2712 } 2712 }
2713 2713
2714 // Parsed expression statement, followed by semicolon. 2714 // Parsed expression statement, followed by semicolon.
2715 // Detect attempts at 'let' declarations in sloppy mode. 2715 // Detect attempts at 'let' declarations in sloppy mode.
2716 if (peek() == Token::IDENTIFIER && expr->AsVariableProxy() != NULL && 2716 if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
2717 expr->AsVariableProxy() != NULL &&
2717 expr->AsVariableProxy()->raw_name() == 2718 expr->AsVariableProxy()->raw_name() ==
2718 ast_value_factory()->let_string()) { 2719 ast_value_factory()->let_string()) {
2719 ReportMessage(MessageTemplate::kSloppyLexical, NULL); 2720 ReportMessage(MessageTemplate::kSloppyLexical, NULL);
2720 *ok = false; 2721 *ok = false;
2721 return NULL; 2722 return NULL;
2722 } 2723 }
2723 ExpectSemicolon(CHECK_OK); 2724 ExpectSemicolon(CHECK_OK);
2724 return factory()->NewExpressionStatement(expr, pos); 2725 return factory()->NewExpressionStatement(expr, pos);
2725 } 2726 }
2726 2727
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 } 3786 }
3786 } 3787 }
3787 } 3788 }
3788 3789
3789 // Standard 'for' loop 3790 // Standard 'for' loop
3790 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos); 3791 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos);
3791 Target target(&this->target_stack_, loop); 3792 Target target(&this->target_stack_, loop);
3792 3793
3793 // Parsed initializer at this point. 3794 // Parsed initializer at this point.
3794 // Detect attempts at 'let' declarations in sloppy mode. 3795 // Detect attempts at 'let' declarations in sloppy mode.
3795 if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && 3796 if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
3796 is_let_identifier_expression) { 3797 is_sloppy(language_mode()) && is_let_identifier_expression) {
3797 ReportMessage(MessageTemplate::kSloppyLexical, NULL); 3798 ReportMessage(MessageTemplate::kSloppyLexical, NULL);
3798 *ok = false; 3799 *ok = false;
3799 return NULL; 3800 return NULL;
3800 } 3801 }
3801 Expect(Token::SEMICOLON, CHECK_OK); 3802 Expect(Token::SEMICOLON, CHECK_OK);
3802 3803
3803 // If there are let bindings, then condition and the next statement of the 3804 // If there are let bindings, then condition and the next statement of the
3804 // for loop must be parsed in a new scope. 3805 // for loop must be parsed in a new scope.
3805 Scope* inner_scope = NULL; 3806 Scope* inner_scope = NULL;
3806 if (lexical_bindings.length() > 0) { 3807 if (lexical_bindings.length() > 0) {
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
6243 6244
6244 Expression* Parser::SpreadCallNew(Expression* function, 6245 Expression* Parser::SpreadCallNew(Expression* function,
6245 ZoneList<v8::internal::Expression*>* args, 6246 ZoneList<v8::internal::Expression*>* args,
6246 int pos) { 6247 int pos) {
6247 args->InsertAt(0, function, zone()); 6248 args->InsertAt(0, function, zone());
6248 6249
6249 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6250 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6250 } 6251 }
6251 } // namespace internal 6252 } // namespace internal
6252 } // namespace v8 6253 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698