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

Side by Side Diff: src/parsing/parser.cc

Issue 2271063002: Centralize and standardize logic for ExpressionClassifier accumulation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 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
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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 4716 matching lines...) Expand 10 before | Expand all | Expand 10 after
4727 } 4727 }
4728 4728
4729 Expression* extends = nullptr; 4729 Expression* extends = nullptr;
4730 if (Check(Token::EXTENDS)) { 4730 if (Check(Token::EXTENDS)) {
4731 block_state.set_start_position(scanner()->location().end_pos); 4731 block_state.set_start_position(scanner()->location().end_pos);
4732 ExpressionClassifier extends_classifier(this); 4732 ExpressionClassifier extends_classifier(this);
4733 extends = ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); 4733 extends = ParseLeftHandSideExpression(&extends_classifier, CHECK_OK);
4734 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); 4734 CheckNoTailCallExpressions(&extends_classifier, CHECK_OK);
4735 RewriteNonPattern(&extends_classifier, CHECK_OK); 4735 RewriteNonPattern(&extends_classifier, CHECK_OK);
4736 if (classifier != nullptr) { 4736 if (classifier != nullptr) {
4737 classifier->Accumulate(&extends_classifier, 4737 classifier->AccumulateFormalParameterContainmentErrors(
4738 ExpressionClassifier::ExpressionProductions); 4738 &extends_classifier);
4739 } 4739 }
4740 } else { 4740 } else {
4741 block_state.set_start_position(scanner()->location().end_pos); 4741 block_state.set_start_position(scanner()->location().end_pos);
4742 } 4742 }
4743 4743
4744 4744
4745 ClassLiteralChecker checker(this); 4745 ClassLiteralChecker checker(this);
4746 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); 4746 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone());
4747 FunctionLiteral* constructor = nullptr; 4747 FunctionLiteral* constructor = nullptr;
4748 bool has_seen_constructor = false; 4748 bool has_seen_constructor = false;
4749 4749
4750 Expect(Token::LBRACE, CHECK_OK); 4750 Expect(Token::LBRACE, CHECK_OK);
4751 4751
4752 const bool has_extends = extends != nullptr; 4752 const bool has_extends = extends != nullptr;
4753 while (peek() != Token::RBRACE) { 4753 while (peek() != Token::RBRACE) {
4754 if (Check(Token::SEMICOLON)) continue; 4754 if (Check(Token::SEMICOLON)) continue;
4755 FuncNameInferrer::State fni_state(fni_); 4755 FuncNameInferrer::State fni_state(fni_);
4756 const bool in_class = true; 4756 const bool in_class = true;
4757 bool is_computed_name = false; // Classes do not care about computed 4757 bool is_computed_name = false; // Classes do not care about computed
4758 // property names here. 4758 // property names here.
4759 ExpressionClassifier property_classifier(this); 4759 ExpressionClassifier property_classifier(this);
4760 const AstRawString* property_name = nullptr; 4760 const AstRawString* property_name = nullptr;
4761 ObjectLiteral::Property* property = ParsePropertyDefinition( 4761 ObjectLiteral::Property* property = ParsePropertyDefinition(
4762 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name, 4762 &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name,
4763 &has_seen_constructor, &property_classifier, &property_name, CHECK_OK); 4763 &has_seen_constructor, &property_classifier, &property_name, CHECK_OK);
4764 RewriteNonPattern(&property_classifier, CHECK_OK); 4764 RewriteNonPattern(&property_classifier, CHECK_OK);
4765 if (classifier != nullptr) { 4765 if (classifier != nullptr) {
4766 classifier->Accumulate(&property_classifier, 4766 classifier->AccumulateFormalParameterContainmentErrors(
4767 ExpressionClassifier::ExpressionProductions); 4767 &property_classifier);
4768 } 4768 }
4769 4769
4770 if (has_seen_constructor && constructor == nullptr) { 4770 if (has_seen_constructor && constructor == nullptr) {
4771 constructor = GetPropertyValue(property)->AsFunctionLiteral(); 4771 constructor = GetPropertyValue(property)->AsFunctionLiteral();
4772 DCHECK_NOT_NULL(constructor); 4772 DCHECK_NOT_NULL(constructor);
4773 constructor->set_raw_name( 4773 constructor->set_raw_name(
4774 name != nullptr ? name : ast_value_factory()->empty_string()); 4774 name != nullptr ? name : ast_value_factory()->empty_string());
4775 } else { 4775 } else {
4776 properties->Add(property, zone()); 4776 properties->Add(property, zone());
4777 } 4777 }
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after
6723 node->Print(Isolate::Current()); 6723 node->Print(Isolate::Current());
6724 } 6724 }
6725 #endif // DEBUG 6725 #endif // DEBUG
6726 6726
6727 #undef CHECK_OK 6727 #undef CHECK_OK
6728 #undef CHECK_OK_VOID 6728 #undef CHECK_OK_VOID
6729 #undef CHECK_FAILED 6729 #undef CHECK_FAILED
6730 6730
6731 } // namespace internal 6731 } // namespace internal
6732 } // namespace v8 6732 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698