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

Side by Side Diff: src/parser.cc

Issue 1292393002: [parser] make kInvalidLhsInFor a SyntaxError (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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.h ('k') | src/preparser.h » ('j') | src/preparser.h » ('J')
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } 651 }
652 652
653 653
654 Expression* ParserTraits::NewThrowSyntaxError(MessageTemplate::Template message, 654 Expression* ParserTraits::NewThrowSyntaxError(MessageTemplate::Template message,
655 const AstRawString* arg, 655 const AstRawString* arg,
656 int pos) { 656 int pos) {
657 return NewThrowError(Runtime::kNewSyntaxError, message, arg, pos); 657 return NewThrowError(Runtime::kNewSyntaxError, message, arg, pos);
658 } 658 }
659 659
660 660
661 Expression* ParserTraits::NewThrowSyntaxError(MessageTemplate::Template message,
662 int pos) {
663 return NewThrowError(Runtime::kNewSyntaxError, message,
664 parser_->ast_value_factory()->empty_string(), pos);
665 }
666
667
661 Expression* ParserTraits::NewThrowTypeError(MessageTemplate::Template message, 668 Expression* ParserTraits::NewThrowTypeError(MessageTemplate::Template message,
662 const AstRawString* arg, int pos) { 669 const AstRawString* arg, int pos) {
663 return NewThrowError(Runtime::kNewTypeError, message, arg, pos); 670 return NewThrowError(Runtime::kNewTypeError, message, arg, pos);
664 } 671 }
665 672
666 673
667 Expression* ParserTraits::NewThrowError(Runtime::FunctionId id, 674 Expression* ParserTraits::NewThrowError(Runtime::FunctionId id,
668 MessageTemplate::Template message, 675 MessageTemplate::Template message,
669 const AstRawString* arg, int pos) { 676 const AstRawString* arg, int pos) {
670 Zone* zone = parser_->zone(); 677 Zone* zone = parser_->zone();
(...skipping 3015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3686 bool accept_OF = expression->IsVariableProxy(); 3693 bool accept_OF = expression->IsVariableProxy();
3687 is_let_identifier_expression = 3694 is_let_identifier_expression =
3688 expression->IsVariableProxy() && 3695 expression->IsVariableProxy() &&
3689 expression->AsVariableProxy()->raw_name() == 3696 expression->AsVariableProxy()->raw_name() ==
3690 ast_value_factory()->let_string(); 3697 ast_value_factory()->let_string();
3691 3698
3692 if (CheckInOrOf(accept_OF, &mode, ok)) { 3699 if (CheckInOrOf(accept_OF, &mode, ok)) {
3693 if (!*ok) return nullptr; 3700 if (!*ok) return nullptr;
3694 expression = this->CheckAndRewriteReferenceExpression( 3701 expression = this->CheckAndRewriteReferenceExpression(
3695 expression, lhs_beg_pos, lhs_end_pos, 3702 expression, lhs_beg_pos, lhs_end_pos,
3696 MessageTemplate::kInvalidLhsInFor, CHECK_OK); 3703 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK);
3697 3704
3698 ForEachStatement* loop = 3705 ForEachStatement* loop =
3699 factory()->NewForEachStatement(mode, labels, stmt_pos); 3706 factory()->NewForEachStatement(mode, labels, stmt_pos);
3700 Target target(&this->target_stack_, loop); 3707 Target target(&this->target_stack_, loop);
3701 3708
3702 Expression* enumerable = ParseExpression(true, CHECK_OK); 3709 Expression* enumerable = ParseExpression(true, CHECK_OK);
3703 Expect(Token::RPAREN, CHECK_OK); 3710 Expect(Token::RPAREN, CHECK_OK);
3704 3711
3705 Statement* body = ParseSubStatement(NULL, CHECK_OK); 3712 Statement* body = ParseSubStatement(NULL, CHECK_OK);
3706 InitializeForEachStatement(loop, expression, enumerable, body); 3713 InitializeForEachStatement(loop, expression, enumerable, body);
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
6015 Expression* Parser::SpreadCallNew(Expression* function, 6022 Expression* Parser::SpreadCallNew(Expression* function,
6016 ZoneList<v8::internal::Expression*>* args, 6023 ZoneList<v8::internal::Expression*>* args,
6017 int pos) { 6024 int pos) {
6018 args->InsertAt(0, function, zone()); 6025 args->InsertAt(0, function, zone());
6019 6026
6020 return factory()->NewCallRuntime( 6027 return factory()->NewCallRuntime(
6021 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 6028 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
6022 } 6029 }
6023 } // namespace internal 6030 } // namespace internal
6024 } // namespace v8 6031 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698