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 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken); | 903 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken); |
904 | 904 |
905 void ReportClassifierError( | 905 void ReportClassifierError( |
906 const typename ExpressionClassifier::Error& error) { | 906 const typename ExpressionClassifier::Error& error) { |
907 Traits::ReportMessageAt(error.location, error.message, error.arg, | 907 Traits::ReportMessageAt(error.location, error.message, error.arg, |
908 error.type); | 908 error.type); |
909 } | 909 } |
910 | 910 |
911 void ValidateExpression(const ExpressionClassifier* classifier, bool* ok) { | 911 void ValidateExpression(const ExpressionClassifier* classifier, bool* ok) { |
912 if (!classifier->is_valid_expression() || | 912 if (!classifier->is_valid_expression() || |
913 classifier->has_cover_initialized_name()) { | 913 classifier->has_object_literal_error()) { |
914 const Scanner::Location& a = classifier->expression_error().location; | 914 const Scanner::Location& a = classifier->expression_error().location; |
915 const Scanner::Location& b = | 915 const Scanner::Location& b = |
916 classifier->cover_initialized_name_error().location; | 916 classifier->object_literal_error().location; |
917 if (a.beg_pos < 0 || (b.beg_pos >= 0 && a.beg_pos > b.beg_pos)) { | 917 if (a.beg_pos < 0 || (b.beg_pos >= 0 && a.beg_pos > b.beg_pos)) { |
918 ReportClassifierError(classifier->cover_initialized_name_error()); | 918 ReportClassifierError(classifier->object_literal_error()); |
919 } else { | 919 } else { |
920 ReportClassifierError(classifier->expression_error()); | 920 ReportClassifierError(classifier->expression_error()); |
921 } | 921 } |
922 *ok = false; | 922 *ok = false; |
923 } | 923 } |
924 } | 924 } |
925 | 925 |
926 void ValidateFormalParameterInitializer( | 926 void ValidateFormalParameterInitializer( |
927 const ExpressionClassifier* classifier, bool* ok) { | 927 const ExpressionClassifier* classifier, bool* ok) { |
928 if (!classifier->is_valid_formal_parameter_initializer()) { | 928 if (!classifier->is_valid_formal_parameter_initializer()) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 kAccessorProperty, | 1195 kAccessorProperty, |
1196 kValueProperty, | 1196 kValueProperty, |
1197 kMethodProperty | 1197 kMethodProperty |
1198 }; | 1198 }; |
1199 | 1199 |
1200 class ObjectLiteralCheckerBase { | 1200 class ObjectLiteralCheckerBase { |
1201 public: | 1201 public: |
1202 explicit ObjectLiteralCheckerBase(ParserBase* parser) : parser_(parser) {} | 1202 explicit ObjectLiteralCheckerBase(ParserBase* parser) : parser_(parser) {} |
1203 | 1203 |
1204 virtual void CheckProperty(Token::Value property, PropertyKind type, | 1204 virtual void CheckProperty(Token::Value property, PropertyKind type, |
1205 MethodKind method_type, bool* ok) = 0; | 1205 MethodKind method_type, |
| 1206 ExpressionClassifier* classifier, bool* ok) = 0; |
1206 | 1207 |
1207 virtual ~ObjectLiteralCheckerBase() {} | 1208 virtual ~ObjectLiteralCheckerBase() {} |
1208 | 1209 |
1209 protected: | 1210 protected: |
1210 ParserBase* parser() const { return parser_; } | 1211 ParserBase* parser() const { return parser_; } |
1211 Scanner* scanner() const { return parser_->scanner(); } | 1212 Scanner* scanner() const { return parser_->scanner(); } |
1212 | 1213 |
1213 private: | 1214 private: |
1214 ParserBase* parser_; | 1215 ParserBase* parser_; |
1215 }; | 1216 }; |
1216 | 1217 |
1217 // Validation per ES6 object literals. | 1218 // Validation per ES6 object literals. |
1218 class ObjectLiteralChecker : public ObjectLiteralCheckerBase { | 1219 class ObjectLiteralChecker : public ObjectLiteralCheckerBase { |
1219 public: | 1220 public: |
1220 explicit ObjectLiteralChecker(ParserBase* parser) | 1221 explicit ObjectLiteralChecker(ParserBase* parser) |
1221 : ObjectLiteralCheckerBase(parser), has_seen_proto_(false) {} | 1222 : ObjectLiteralCheckerBase(parser), has_seen_proto_(false) {} |
1222 | 1223 |
1223 void CheckProperty(Token::Value property, PropertyKind type, | 1224 void CheckProperty(Token::Value property, PropertyKind type, |
1224 MethodKind method_type, bool* ok) override; | 1225 MethodKind method_type, ExpressionClassifier* classifier, |
| 1226 bool* ok) override; |
1225 | 1227 |
1226 private: | 1228 private: |
1227 bool IsProto() { return this->scanner()->LiteralMatches("__proto__", 9); } | 1229 bool IsProto() { return this->scanner()->LiteralMatches("__proto__", 9); } |
1228 | 1230 |
1229 bool has_seen_proto_; | 1231 bool has_seen_proto_; |
1230 }; | 1232 }; |
1231 | 1233 |
1232 // Validation per ES6 class literals. | 1234 // Validation per ES6 class literals. |
1233 class ClassLiteralChecker : public ObjectLiteralCheckerBase { | 1235 class ClassLiteralChecker : public ObjectLiteralCheckerBase { |
1234 public: | 1236 public: |
1235 explicit ClassLiteralChecker(ParserBase* parser) | 1237 explicit ClassLiteralChecker(ParserBase* parser) |
1236 : ObjectLiteralCheckerBase(parser), has_seen_constructor_(false) {} | 1238 : ObjectLiteralCheckerBase(parser), has_seen_constructor_(false) {} |
1237 | 1239 |
1238 void CheckProperty(Token::Value property, PropertyKind type, | 1240 void CheckProperty(Token::Value property, PropertyKind type, |
1239 MethodKind method_type, bool* ok) override; | 1241 MethodKind method_type, ExpressionClassifier* classifier, |
| 1242 bool* ok) override; |
1240 | 1243 |
1241 private: | 1244 private: |
1242 bool IsConstructor() { | 1245 bool IsConstructor() { |
1243 return this->scanner()->LiteralMatches("constructor", 11); | 1246 return this->scanner()->LiteralMatches("constructor", 11); |
1244 } | 1247 } |
1245 bool IsPrototype() { | 1248 bool IsPrototype() { |
1246 return this->scanner()->LiteralMatches("prototype", 9); | 1249 return this->scanner()->LiteralMatches("prototype", 9); |
1247 } | 1250 } |
1248 | 1251 |
1249 bool has_seen_constructor_; | 1252 bool has_seen_constructor_; |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 this->PushLiteralName(fni_, *name); | 1976 this->PushLiteralName(fni_, *name); |
1974 } | 1977 } |
1975 | 1978 |
1976 if (!in_class && !is_generator) { | 1979 if (!in_class && !is_generator) { |
1977 DCHECK(!IsStaticMethod(method_kind)); | 1980 DCHECK(!IsStaticMethod(method_kind)); |
1978 if (peek() == Token::COLON) { | 1981 if (peek() == Token::COLON) { |
1979 // PropertyDefinition | 1982 // PropertyDefinition |
1980 // PropertyName ':' AssignmentExpression | 1983 // PropertyName ':' AssignmentExpression |
1981 if (!*is_computed_name) { | 1984 if (!*is_computed_name) { |
1982 checker->CheckProperty(name_token, kValueProperty, MethodKind::kNormal, | 1985 checker->CheckProperty(name_token, kValueProperty, MethodKind::kNormal, |
| 1986 classifier, |
1983 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1987 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
1984 } | 1988 } |
1985 Consume(Token::COLON); | 1989 Consume(Token::COLON); |
1986 int beg_pos = peek_position(); | 1990 int beg_pos = peek_position(); |
1987 ExpressionT value = this->ParseAssignmentExpression( | 1991 ExpressionT value = this->ParseAssignmentExpression( |
1988 true, classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1992 true, classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
1989 CheckDestructuringElement(value, classifier, beg_pos, | 1993 CheckDestructuringElement(value, classifier, beg_pos, |
1990 scanner()->location().end_pos); | 1994 scanner()->location().end_pos); |
1991 | 1995 |
1992 return factory()->NewObjectLiteralProperty(name_expression, value, | 1996 return factory()->NewObjectLiteralProperty(name_expression, value, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 Consume(Token::ASSIGN); | 2041 Consume(Token::ASSIGN); |
2038 ExpressionClassifier rhs_classifier(this); | 2042 ExpressionClassifier rhs_classifier(this); |
2039 ExpressionT rhs = this->ParseAssignmentExpression( | 2043 ExpressionT rhs = this->ParseAssignmentExpression( |
2040 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2044 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2041 Traits::RewriteNonPattern(&rhs_classifier, | 2045 Traits::RewriteNonPattern(&rhs_classifier, |
2042 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2046 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2043 classifier->Accumulate(&rhs_classifier, | 2047 classifier->Accumulate(&rhs_classifier, |
2044 ExpressionClassifier::ExpressionProductions); | 2048 ExpressionClassifier::ExpressionProductions); |
2045 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, | 2049 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, |
2046 kNoSourcePosition); | 2050 kNoSourcePosition); |
2047 classifier->RecordCoverInitializedNameError( | 2051 classifier->RecordObjectLiteralError( |
2048 Scanner::Location(next_beg_pos, scanner()->location().end_pos), | 2052 Scanner::Location(next_beg_pos, scanner()->location().end_pos), |
2049 MessageTemplate::kInvalidCoverInitializedName); | 2053 MessageTemplate::kInvalidCoverInitializedName); |
2050 | 2054 |
2051 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs); | 2055 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs); |
2052 } else { | 2056 } else { |
2053 value = lhs; | 2057 value = lhs; |
2054 } | 2058 } |
2055 | 2059 |
2056 return factory()->NewObjectLiteralProperty( | 2060 return factory()->NewObjectLiteralProperty( |
2057 name_expression, value, ObjectLiteralProperty::COMPUTED, is_static, | 2061 name_expression, value, ObjectLiteralProperty::COMPUTED, is_static, |
(...skipping 15 matching lines...) Expand all Loading... |
2073 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2077 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2074 method_kind |= MethodKind::kAsync; | 2078 method_kind |= MethodKind::kAsync; |
2075 } | 2079 } |
2076 | 2080 |
2077 if (is_generator || peek() == Token::LPAREN) { | 2081 if (is_generator || peek() == Token::LPAREN) { |
2078 // MethodDefinition | 2082 // MethodDefinition |
2079 // PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}' | 2083 // PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}' |
2080 // '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}' | 2084 // '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}' |
2081 if (!*is_computed_name) { | 2085 if (!*is_computed_name) { |
2082 checker->CheckProperty(name_token, kMethodProperty, method_kind, | 2086 checker->CheckProperty(name_token, kMethodProperty, method_kind, |
| 2087 classifier, |
2083 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2088 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2084 } | 2089 } |
2085 | 2090 |
2086 FunctionKind kind = is_generator | 2091 FunctionKind kind = is_generator |
2087 ? FunctionKind::kConciseGeneratorMethod | 2092 ? FunctionKind::kConciseGeneratorMethod |
2088 : is_async ? FunctionKind::kAsyncConciseMethod | 2093 : is_async ? FunctionKind::kAsyncConciseMethod |
2089 : FunctionKind::kConciseMethod; | 2094 : FunctionKind::kConciseMethod; |
2090 | 2095 |
2091 if (in_class && !IsStaticMethod(method_kind) && | 2096 if (in_class && !IsStaticMethod(method_kind) && |
2092 this->IsConstructor(*name)) { | 2097 this->IsConstructor(*name)) { |
(...skipping 30 matching lines...) Expand all Loading... |
2123 *name = this->EmptyIdentifier(); | 2128 *name = this->EmptyIdentifier(); |
2124 bool dont_care = false; | 2129 bool dont_care = false; |
2125 name_token = peek(); | 2130 name_token = peek(); |
2126 | 2131 |
2127 name_expression = ParsePropertyName( | 2132 name_expression = ParsePropertyName( |
2128 name, &dont_care, &dont_care, &dont_care, is_computed_name, classifier, | 2133 name, &dont_care, &dont_care, &dont_care, is_computed_name, classifier, |
2129 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2134 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2130 | 2135 |
2131 if (!*is_computed_name) { | 2136 if (!*is_computed_name) { |
2132 checker->CheckProperty(name_token, kAccessorProperty, method_kind, | 2137 checker->CheckProperty(name_token, kAccessorProperty, method_kind, |
| 2138 classifier, |
2133 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2139 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2134 } | 2140 } |
2135 | 2141 |
2136 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( | 2142 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( |
2137 *name, scanner()->location(), kSkipFunctionNameCheck, | 2143 *name, scanner()->location(), kSkipFunctionNameCheck, |
2138 is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, | 2144 is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, |
2139 kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(), | 2145 kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(), |
2140 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2146 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2141 | 2147 |
2142 // Make sure the name expression is a string since we need a Name for | 2148 // Make sure the name expression is a string since we need a Name for |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 } | 2415 } |
2410 | 2416 |
2411 // "expression" was not itself an arrow function parameter list, but it might | 2417 // "expression" was not itself an arrow function parameter list, but it might |
2412 // form part of one. Propagate speculative formal parameter error locations. | 2418 // form part of one. Propagate speculative formal parameter error locations. |
2413 // Do not merge pending non-pattern expressions yet! | 2419 // Do not merge pending non-pattern expressions yet! |
2414 classifier->Accumulate( | 2420 classifier->Accumulate( |
2415 &arrow_formals_classifier, | 2421 &arrow_formals_classifier, |
2416 ExpressionClassifier::ExpressionProductions | | 2422 ExpressionClassifier::ExpressionProductions | |
2417 ExpressionClassifier::PatternProductions | | 2423 ExpressionClassifier::PatternProductions | |
2418 ExpressionClassifier::FormalParametersProductions | | 2424 ExpressionClassifier::FormalParametersProductions | |
2419 ExpressionClassifier::CoverInitializedNameProduction | | 2425 ExpressionClassifier::ObjectLiteralProduction | |
2420 ExpressionClassifier::AsyncArrowFormalParametersProduction, | 2426 ExpressionClassifier::AsyncArrowFormalParametersProduction, |
2421 false); | 2427 false); |
2422 | 2428 |
2423 if (!Token::IsAssignmentOp(peek())) { | 2429 if (!Token::IsAssignmentOp(peek())) { |
2424 // Parsed conditional expression only (no assignment). | 2430 // Parsed conditional expression only (no assignment). |
2425 // Now pending non-pattern expressions must be merged. | 2431 // Now pending non-pattern expressions must be merged. |
2426 classifier->MergeNonPatterns(&arrow_formals_classifier); | 2432 classifier->MergeNonPatterns(&arrow_formals_classifier); |
2427 return expression; | 2433 return expression; |
2428 } | 2434 } |
2429 | 2435 |
2430 // Now pending non-pattern expressions must be discarded. | 2436 // Now pending non-pattern expressions must be discarded. |
2431 arrow_formals_classifier.Discard(); | 2437 arrow_formals_classifier.Discard(); |
2432 | 2438 |
2433 CheckNoTailCallExpressions(classifier, CHECK_OK); | 2439 CheckNoTailCallExpressions(classifier, CHECK_OK); |
2434 | 2440 |
2435 if (IsValidPattern(expression) && peek() == Token::ASSIGN) { | 2441 if (IsValidPattern(expression) && peek() == Token::ASSIGN) { |
2436 classifier->ForgiveCoverInitializedNameError(); | 2442 classifier->ForgiveObjectLiteralError(); |
2437 ValidateAssignmentPattern(classifier, CHECK_OK); | 2443 ValidateAssignmentPattern(classifier, CHECK_OK); |
2438 is_destructuring_assignment = true; | 2444 is_destructuring_assignment = true; |
2439 } else { | 2445 } else { |
2440 expression = this->CheckAndRewriteReferenceExpression( | 2446 expression = this->CheckAndRewriteReferenceExpression( |
2441 expression, lhs_beg_pos, scanner()->location().end_pos, | 2447 expression, lhs_beg_pos, scanner()->location().end_pos, |
2442 MessageTemplate::kInvalidLhsInAssignment, CHECK_OK); | 2448 MessageTemplate::kInvalidLhsInAssignment, CHECK_OK); |
2443 } | 2449 } |
2444 | 2450 |
2445 expression = this->MarkExpressionAsAssigned(expression); | 2451 expression = this->MarkExpressionAsAssigned(expression); |
2446 | 2452 |
2447 Token::Value op = Next(); // Get assignment operator. | 2453 Token::Value op = Next(); // Get assignment operator. |
2448 if (op != Token::ASSIGN) { | 2454 if (op != Token::ASSIGN) { |
2449 classifier->RecordPatternError(scanner()->location(), | 2455 classifier->RecordPatternError(scanner()->location(), |
2450 MessageTemplate::kUnexpectedToken, | 2456 MessageTemplate::kUnexpectedToken, |
2451 Token::String(op)); | 2457 Token::String(op)); |
2452 } | 2458 } |
2453 int pos = position(); | 2459 int pos = position(); |
2454 | 2460 |
2455 ExpressionClassifier rhs_classifier(this); | 2461 ExpressionClassifier rhs_classifier(this); |
2456 | 2462 |
2457 ExpressionT right = | 2463 ExpressionT right = |
2458 this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK); | 2464 this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK); |
2459 CheckNoTailCallExpressions(&rhs_classifier, CHECK_OK); | 2465 CheckNoTailCallExpressions(&rhs_classifier, CHECK_OK); |
2460 Traits::RewriteNonPattern(&rhs_classifier, CHECK_OK); | 2466 Traits::RewriteNonPattern(&rhs_classifier, CHECK_OK); |
2461 classifier->Accumulate( | 2467 classifier->Accumulate( |
2462 &rhs_classifier, | 2468 &rhs_classifier, |
2463 ExpressionClassifier::ExpressionProductions | | 2469 ExpressionClassifier::ExpressionProductions | |
2464 ExpressionClassifier::CoverInitializedNameProduction | | 2470 ExpressionClassifier::ObjectLiteralProduction | |
2465 ExpressionClassifier::AsyncArrowFormalParametersProduction); | 2471 ExpressionClassifier::AsyncArrowFormalParametersProduction); |
2466 | 2472 |
2467 // TODO(1231235): We try to estimate the set of properties set by | 2473 // TODO(1231235): We try to estimate the set of properties set by |
2468 // constructors. We define a new property whenever there is an | 2474 // constructors. We define a new property whenever there is an |
2469 // assignment to a property of 'this'. We should probably only add | 2475 // assignment to a property of 'this'. We should probably only add |
2470 // properties if we haven't seen them before. Otherwise we'll | 2476 // properties if we haven't seen them before. Otherwise we'll |
2471 // probably overestimate the number of properties. | 2477 // probably overestimate the number of properties. |
2472 if (op == Token::ASSIGN && this->IsThisProperty(expression)) { | 2478 if (op == Token::ASSIGN && this->IsThisProperty(expression)) { |
2473 function_state_->AddProperty(); | 2479 function_state_->AddProperty(); |
2474 } | 2480 } |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3695 } | 3701 } |
3696 } | 3702 } |
3697 | 3703 |
3698 | 3704 |
3699 #undef CHECK_OK | 3705 #undef CHECK_OK |
3700 #undef CHECK_OK_CUSTOM | 3706 #undef CHECK_OK_CUSTOM |
3701 | 3707 |
3702 template <typename Traits> | 3708 template <typename Traits> |
3703 void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( | 3709 void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( |
3704 Token::Value property, PropertyKind type, MethodKind method_type, | 3710 Token::Value property, PropertyKind type, MethodKind method_type, |
3705 bool* ok) { | 3711 ExpressionClassifier* classifier, bool* ok) { |
3706 DCHECK(!IsStaticMethod(method_type)); | 3712 DCHECK(!IsStaticMethod(method_type)); |
3707 DCHECK(!IsSpecialMethod(method_type) || type == kMethodProperty); | 3713 DCHECK(!IsSpecialMethod(method_type) || type == kMethodProperty); |
3708 | 3714 |
3709 if (property == Token::SMI || property == Token::NUMBER) return; | 3715 if (property == Token::SMI || property == Token::NUMBER) return; |
3710 | 3716 |
3711 if (type == kValueProperty && IsProto()) { | 3717 if (type == kValueProperty && IsProto()) { |
3712 if (has_seen_proto_) { | 3718 if (has_seen_proto_) { |
3713 this->parser()->ReportMessage(MessageTemplate::kDuplicateProto); | 3719 classifier->RecordObjectLiteralError( |
3714 *ok = false; | 3720 this->scanner()->location(), MessageTemplate::kDuplicateProto); |
3715 return; | 3721 return; |
3716 } | 3722 } |
3717 has_seen_proto_ = true; | 3723 has_seen_proto_ = true; |
3718 return; | |
3719 } | 3724 } |
3720 } | 3725 } |
3721 | 3726 |
3722 template <typename Traits> | 3727 template <typename Traits> |
3723 void ParserBase<Traits>::ClassLiteralChecker::CheckProperty( | 3728 void ParserBase<Traits>::ClassLiteralChecker::CheckProperty( |
3724 Token::Value property, PropertyKind type, MethodKind method_type, | 3729 Token::Value property, PropertyKind type, MethodKind method_type, |
3725 bool* ok) { | 3730 ExpressionClassifier* classifier, bool* ok) { |
3726 DCHECK(type == kMethodProperty || type == kAccessorProperty); | 3731 DCHECK(type == kMethodProperty || type == kAccessorProperty); |
3727 | 3732 |
3728 if (property == Token::SMI || property == Token::NUMBER) return; | 3733 if (property == Token::SMI || property == Token::NUMBER) return; |
3729 | 3734 |
3730 if (IsStaticMethod(method_type)) { | 3735 if (IsStaticMethod(method_type)) { |
3731 if (IsPrototype()) { | 3736 if (IsPrototype()) { |
3732 this->parser()->ReportMessage(MessageTemplate::kStaticPrototype); | 3737 this->parser()->ReportMessage(MessageTemplate::kStaticPrototype); |
3733 *ok = false; | 3738 *ok = false; |
3734 return; | 3739 return; |
3735 } | 3740 } |
(...skipping 17 matching lines...) Expand all Loading... |
3753 has_seen_constructor_ = true; | 3758 has_seen_constructor_ = true; |
3754 return; | 3759 return; |
3755 } | 3760 } |
3756 } | 3761 } |
3757 | 3762 |
3758 | 3763 |
3759 } // namespace internal | 3764 } // namespace internal |
3760 } // namespace v8 | 3765 } // namespace v8 |
3761 | 3766 |
3762 #endif // V8_PARSING_PARSER_BASE_H | 3767 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |