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

Side by Side Diff: src/parsing/parser-base.h

Issue 2268173005: Merge ExpressionClassifier::ObjectLiteralProduction into ExpressionProduction (Closed)
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
« no previous file with comments | « src/parsing/expression-classifier.h ('k') | no next file » | 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 #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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 Scanner::Location location, Token::Value token, 918 Scanner::Location location, Token::Value token,
919 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken); 919 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken);
920 920
921 void ReportClassifierError( 921 void ReportClassifierError(
922 const typename ExpressionClassifier::Error& error) { 922 const typename ExpressionClassifier::Error& error) {
923 impl()->ReportMessageAt(error.location, error.message, error.arg, 923 impl()->ReportMessageAt(error.location, error.message, error.arg,
924 error.type); 924 error.type);
925 } 925 }
926 926
927 void ValidateExpression(const ExpressionClassifier* classifier, bool* ok) { 927 void ValidateExpression(const ExpressionClassifier* classifier, bool* ok) {
928 if (!classifier->is_valid_expression() || 928 if (!classifier->is_valid_expression()) {
929 classifier->has_object_literal_error()) { 929 ReportClassifierError(classifier->expression_error());
930 const Scanner::Location& a = classifier->expression_error().location;
931 const Scanner::Location& b =
932 classifier->object_literal_error().location;
933 if (a.beg_pos < 0 || (b.beg_pos >= 0 && a.beg_pos > b.beg_pos)) {
934 ReportClassifierError(classifier->object_literal_error());
935 } else {
936 ReportClassifierError(classifier->expression_error());
937 }
938 *ok = false; 930 *ok = false;
939 } 931 }
940 } 932 }
941 933
942 void ValidateFormalParameterInitializer( 934 void ValidateFormalParameterInitializer(
943 const ExpressionClassifier* classifier, bool* ok) { 935 const ExpressionClassifier* classifier, bool* ok) {
944 if (!classifier->is_valid_formal_parameter_initializer()) { 936 if (!classifier->is_valid_formal_parameter_initializer()) {
945 ReportClassifierError(classifier->formal_parameter_initializer_error()); 937 ReportClassifierError(classifier->formal_parameter_initializer_error());
946 *ok = false; 938 *ok = false;
947 } 939 }
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 if (peek() == Token::ASSIGN) { 2020 if (peek() == Token::ASSIGN) {
2029 Consume(Token::ASSIGN); 2021 Consume(Token::ASSIGN);
2030 ExpressionClassifier rhs_classifier(this); 2022 ExpressionClassifier rhs_classifier(this);
2031 ExpressionT rhs = ParseAssignmentExpression( 2023 ExpressionT rhs = ParseAssignmentExpression(
2032 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2024 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2033 impl()->RewriteNonPattern(&rhs_classifier, 2025 impl()->RewriteNonPattern(&rhs_classifier,
2034 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2026 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2035 classifier->AccumulateFormalParameterContainmentErrors(&rhs_classifier); 2027 classifier->AccumulateFormalParameterContainmentErrors(&rhs_classifier);
2036 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, 2028 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
2037 kNoSourcePosition); 2029 kNoSourcePosition);
2038 classifier->RecordObjectLiteralError( 2030 classifier->RecordExpressionError(
2039 Scanner::Location(next_beg_pos, scanner()->location().end_pos), 2031 Scanner::Location(next_beg_pos, scanner()->location().end_pos),
2040 MessageTemplate::kInvalidCoverInitializedName); 2032 MessageTemplate::kInvalidCoverInitializedName);
2041 2033
2042 impl()->SetFunctionNameFromIdentifierRef(rhs, lhs); 2034 impl()->SetFunctionNameFromIdentifierRef(rhs, lhs);
2043 } else { 2035 } else {
2044 value = lhs; 2036 value = lhs;
2045 } 2037 }
2046 2038
2047 return factory()->NewObjectLiteralProperty( 2039 return factory()->NewObjectLiteralProperty(
2048 name_expression, value, ObjectLiteralProperty::COMPUTED, is_static, 2040 name_expression, value, ObjectLiteralProperty::COMPUTED, is_static,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 if (IsValidReferenceExpression(expression)) { 2401 if (IsValidReferenceExpression(expression)) {
2410 productions &= ~ExpressionClassifier::AssignmentPatternProduction; 2402 productions &= ~ExpressionClassifier::AssignmentPatternProduction;
2411 } 2403 }
2412 2404
2413 const bool is_destructuring_assignment = 2405 const bool is_destructuring_assignment =
2414 IsValidPattern(expression) && peek() == Token::ASSIGN; 2406 IsValidPattern(expression) && peek() == Token::ASSIGN;
2415 if (is_destructuring_assignment) { 2407 if (is_destructuring_assignment) {
2416 // This is definitely not an expression so don't accumulate 2408 // This is definitely not an expression so don't accumulate
2417 // expression-related errors. 2409 // expression-related errors.
2418 productions &= ~(ExpressionClassifier::ExpressionProduction | 2410 productions &= ~(ExpressionClassifier::ExpressionProduction |
2419 ExpressionClassifier::ObjectLiteralProduction |
2420 ExpressionClassifier::TailCallExpressionProduction); 2411 ExpressionClassifier::TailCallExpressionProduction);
2421 } 2412 }
2422 2413
2423 classifier->Accumulate(&arrow_formals_classifier, productions, false); 2414 classifier->Accumulate(&arrow_formals_classifier, productions, false);
2424 2415
2425 if (!Token::IsAssignmentOp(peek())) { 2416 if (!Token::IsAssignmentOp(peek())) {
2426 // Parsed conditional expression only (no assignment). 2417 // Parsed conditional expression only (no assignment).
2427 // Now pending non-pattern expressions must be merged. 2418 // Now pending non-pattern expressions must be merged.
2428 classifier->MergeNonPatterns(&arrow_formals_classifier); 2419 classifier->MergeNonPatterns(&arrow_formals_classifier);
2429 return expression; 2420 return expression;
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3661 void ParserBase<Impl>::ObjectLiteralChecker::CheckProperty( 3652 void ParserBase<Impl>::ObjectLiteralChecker::CheckProperty(
3662 Token::Value property, PropertyKind type, MethodKind method_type, 3653 Token::Value property, PropertyKind type, MethodKind method_type,
3663 ExpressionClassifier* classifier, bool* ok) { 3654 ExpressionClassifier* classifier, bool* ok) {
3664 DCHECK(!IsStaticMethod(method_type)); 3655 DCHECK(!IsStaticMethod(method_type));
3665 DCHECK(!IsSpecialMethod(method_type) || type == kMethodProperty); 3656 DCHECK(!IsSpecialMethod(method_type) || type == kMethodProperty);
3666 3657
3667 if (property == Token::SMI || property == Token::NUMBER) return; 3658 if (property == Token::SMI || property == Token::NUMBER) return;
3668 3659
3669 if (type == kValueProperty && IsProto()) { 3660 if (type == kValueProperty && IsProto()) {
3670 if (has_seen_proto_) { 3661 if (has_seen_proto_) {
3671 classifier->RecordObjectLiteralError( 3662 classifier->RecordExpressionError(this->scanner()->location(),
3672 this->scanner()->location(), MessageTemplate::kDuplicateProto); 3663 MessageTemplate::kDuplicateProto);
3673 return; 3664 return;
3674 } 3665 }
3675 has_seen_proto_ = true; 3666 has_seen_proto_ = true;
3676 } 3667 }
3677 } 3668 }
3678 3669
3679 template <typename Impl> 3670 template <typename Impl>
3680 void ParserBase<Impl>::ClassLiteralChecker::CheckProperty( 3671 void ParserBase<Impl>::ClassLiteralChecker::CheckProperty(
3681 Token::Value property, PropertyKind type, MethodKind method_type, 3672 Token::Value property, PropertyKind type, MethodKind method_type,
3682 ExpressionClassifier* classifier, bool* ok) { 3673 ExpressionClassifier* classifier, bool* ok) {
(...skipping 27 matching lines...) Expand all
3710 has_seen_constructor_ = true; 3701 has_seen_constructor_ = true;
3711 return; 3702 return;
3712 } 3703 }
3713 } 3704 }
3714 3705
3715 3706
3716 } // namespace internal 3707 } // namespace internal
3717 } // namespace v8 3708 } // namespace v8
3718 3709
3719 #endif // V8_PARSING_PARSER_BASE_H 3710 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/expression-classifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698