| OLD | NEW | 
|---|
| 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 4659 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4670   } | 4670   } | 
| 4671 | 4671 | 
| 4672   Expression* extends = nullptr; | 4672   Expression* extends = nullptr; | 
| 4673   if (Check(Token::EXTENDS)) { | 4673   if (Check(Token::EXTENDS)) { | 
| 4674     block_state.set_start_position(scanner()->location().end_pos); | 4674     block_state.set_start_position(scanner()->location().end_pos); | 
| 4675     ExpressionClassifier extends_classifier(this); | 4675     ExpressionClassifier extends_classifier(this); | 
| 4676     extends = ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); | 4676     extends = ParseLeftHandSideExpression(&extends_classifier, CHECK_OK); | 
| 4677     CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); | 4677     CheckNoTailCallExpressions(&extends_classifier, CHECK_OK); | 
| 4678     RewriteNonPattern(&extends_classifier, CHECK_OK); | 4678     RewriteNonPattern(&extends_classifier, CHECK_OK); | 
| 4679     if (classifier != nullptr) { | 4679     if (classifier != nullptr) { | 
| 4680       classifier->Accumulate(&extends_classifier, | 4680       classifier->AccumulateFormalParameterContainmentErrors( | 
| 4681                              ExpressionClassifier::ExpressionProductions); | 4681           &extends_classifier); | 
| 4682     } | 4682     } | 
| 4683   } else { | 4683   } else { | 
| 4684     block_state.set_start_position(scanner()->location().end_pos); | 4684     block_state.set_start_position(scanner()->location().end_pos); | 
| 4685   } | 4685   } | 
| 4686 | 4686 | 
| 4687 | 4687 | 
| 4688   ClassLiteralChecker checker(this); | 4688   ClassLiteralChecker checker(this); | 
| 4689   ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4); | 4689   ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4); | 
| 4690   FunctionLiteral* constructor = nullptr; | 4690   FunctionLiteral* constructor = nullptr; | 
| 4691   bool has_seen_constructor = false; | 4691   bool has_seen_constructor = false; | 
| 4692 | 4692 | 
| 4693   Expect(Token::LBRACE, CHECK_OK); | 4693   Expect(Token::LBRACE, CHECK_OK); | 
| 4694 | 4694 | 
| 4695   const bool has_extends = extends != nullptr; | 4695   const bool has_extends = extends != nullptr; | 
| 4696   while (peek() != Token::RBRACE) { | 4696   while (peek() != Token::RBRACE) { | 
| 4697     if (Check(Token::SEMICOLON)) continue; | 4697     if (Check(Token::SEMICOLON)) continue; | 
| 4698     FuncNameInferrer::State fni_state(fni_); | 4698     FuncNameInferrer::State fni_state(fni_); | 
| 4699     const bool in_class = true; | 4699     const bool in_class = true; | 
| 4700     bool is_computed_name = false;  // Classes do not care about computed | 4700     bool is_computed_name = false;  // Classes do not care about computed | 
| 4701                                     // property names here. | 4701                                     // property names here. | 
| 4702     ExpressionClassifier property_classifier(this); | 4702     ExpressionClassifier property_classifier(this); | 
| 4703     const AstRawString* property_name = nullptr; | 4703     const AstRawString* property_name = nullptr; | 
| 4704     ObjectLiteral::Property* property = ParsePropertyDefinition( | 4704     ObjectLiteral::Property* property = ParsePropertyDefinition( | 
| 4705         &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name, | 4705         &checker, in_class, has_extends, MethodKind::kNormal, &is_computed_name, | 
| 4706         &has_seen_constructor, &property_classifier, &property_name, CHECK_OK); | 4706         &has_seen_constructor, &property_classifier, &property_name, CHECK_OK); | 
| 4707     RewriteNonPattern(&property_classifier, CHECK_OK); | 4707     RewriteNonPattern(&property_classifier, CHECK_OK); | 
| 4708     if (classifier != nullptr) { | 4708     if (classifier != nullptr) { | 
| 4709       classifier->Accumulate(&property_classifier, | 4709       classifier->AccumulateFormalParameterContainmentErrors( | 
| 4710                              ExpressionClassifier::ExpressionProductions); | 4710           &property_classifier); | 
| 4711     } | 4711     } | 
| 4712 | 4712 | 
| 4713     if (has_seen_constructor && constructor == nullptr) { | 4713     if (has_seen_constructor && constructor == nullptr) { | 
| 4714       constructor = GetPropertyValue(property)->AsFunctionLiteral(); | 4714       constructor = GetPropertyValue(property)->AsFunctionLiteral(); | 
| 4715       DCHECK_NOT_NULL(constructor); | 4715       DCHECK_NOT_NULL(constructor); | 
| 4716       constructor->set_raw_name( | 4716       constructor->set_raw_name( | 
| 4717           name != nullptr ? name : ast_value_factory()->empty_string()); | 4717           name != nullptr ? name : ast_value_factory()->empty_string()); | 
| 4718     } else { | 4718     } else { | 
| 4719       properties->Add(property, zone()); | 4719       properties->Add(property, zone()); | 
| 4720     } | 4720     } | 
| (...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6649   node->Print(Isolate::Current()); | 6649   node->Print(Isolate::Current()); | 
| 6650 } | 6650 } | 
| 6651 #endif  // DEBUG | 6651 #endif  // DEBUG | 
| 6652 | 6652 | 
| 6653 #undef CHECK_OK | 6653 #undef CHECK_OK | 
| 6654 #undef CHECK_OK_VOID | 6654 #undef CHECK_OK_VOID | 
| 6655 #undef CHECK_FAILED | 6655 #undef CHECK_FAILED | 
| 6656 | 6656 | 
| 6657 }  // namespace internal | 6657 }  // namespace internal | 
| 6658 }  // namespace v8 | 6658 }  // namespace v8 | 
| OLD | NEW | 
|---|