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

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

Issue 2175033002: [cleanup] Remove unused ExpressionClassifier args in ParserBase (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 bool* is_strict_reserved, 1008 bool* is_strict_reserved,
1009 bool* ok); 1009 bool* ok);
1010 IdentifierT ParseIdentifierOrStrictReservedWord(bool* is_strict_reserved, 1010 IdentifierT ParseIdentifierOrStrictReservedWord(bool* is_strict_reserved,
1011 bool* ok) { 1011 bool* ok) {
1012 return ParseIdentifierOrStrictReservedWord(this->is_generator(), 1012 return ParseIdentifierOrStrictReservedWord(this->is_generator(),
1013 is_strict_reserved, ok); 1013 is_strict_reserved, ok);
1014 } 1014 }
1015 1015
1016 IdentifierT ParseIdentifierName(bool* ok); 1016 IdentifierT ParseIdentifierName(bool* ok);
1017 1017
1018 ExpressionT ParseRegExpLiteral(bool seen_equal, 1018 ExpressionT ParseRegExpLiteral(bool seen_equal, bool* ok);
1019 ExpressionClassifier* classifier, bool* ok);
1020 1019
1021 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, 1020 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier,
1022 bool* is_async, bool* ok); 1021 bool* is_async, bool* ok);
1023 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, 1022 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier,
1024 bool* ok) { 1023 bool* ok) {
1025 bool is_async; 1024 bool is_async;
1026 return ParsePrimaryExpression(classifier, &is_async, ok); 1025 return ParsePrimaryExpression(classifier, &is_async, ok);
1027 } 1026 }
1028 ExpressionT ParseExpression(bool accept_IN, bool* ok); 1027 ExpressionT ParseExpression(bool accept_IN, bool* ok);
1029 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier, 1028 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier, 1070 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier,
1072 bool* ok); 1071 bool* ok);
1073 ExpressionT ParseArrowFunctionLiteral(bool accept_IN, 1072 ExpressionT ParseArrowFunctionLiteral(bool accept_IN,
1074 const FormalParametersT& parameters, 1073 const FormalParametersT& parameters,
1075 bool is_async, 1074 bool is_async,
1076 const ExpressionClassifier& classifier, 1075 const ExpressionClassifier& classifier,
1077 bool* ok); 1076 bool* ok);
1078 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, 1077 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start,
1079 ExpressionClassifier* classifier, bool* ok); 1078 ExpressionClassifier* classifier, bool* ok);
1080 void AddTemplateExpression(ExpressionT); 1079 void AddTemplateExpression(ExpressionT);
1081 ExpressionT ParseSuperExpression(bool is_new, 1080 ExpressionT ParseSuperExpression(bool is_new, bool* ok);
1082 ExpressionClassifier* classifier, bool* ok);
1083 ExpressionT ParseNewTargetExpression(bool* ok); 1081 ExpressionT ParseNewTargetExpression(bool* ok);
1084 1082
1085 void ParseFormalParameter(FormalParametersT* parameters, 1083 void ParseFormalParameter(FormalParametersT* parameters,
1086 ExpressionClassifier* classifier, bool* ok); 1084 ExpressionClassifier* classifier, bool* ok);
1087 void ParseFormalParameterList(FormalParametersT* parameters, 1085 void ParseFormalParameterList(FormalParametersT* parameters,
1088 ExpressionClassifier* classifier, bool* ok); 1086 ExpressionClassifier* classifier, bool* ok);
1089 void CheckArityRestrictions(int param_count, FunctionKind function_type, 1087 void CheckArityRestrictions(int param_count, FunctionKind function_type,
1090 bool has_rest, int formals_start_pos, 1088 bool has_rest, int formals_start_pos,
1091 int formals_end_pos, bool* ok); 1089 int formals_end_pos, bool* ok);
1092 1090
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 this->ReportUnexpectedToken(next); 1450 this->ReportUnexpectedToken(next);
1453 *ok = false; 1451 *ok = false;
1454 return Traits::EmptyIdentifier(); 1452 return Traits::EmptyIdentifier();
1455 } 1453 }
1456 1454
1457 IdentifierT name = this->GetSymbol(scanner()); 1455 IdentifierT name = this->GetSymbol(scanner());
1458 if (this->IsArguments(name)) scope()->RecordArgumentsUsage(); 1456 if (this->IsArguments(name)) scope()->RecordArgumentsUsage();
1459 return name; 1457 return name;
1460 } 1458 }
1461 1459
1462
1463 template <class Traits> 1460 template <class Traits>
1464 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( 1461 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral(
1465 bool seen_equal, ExpressionClassifier* classifier, bool* ok) { 1462 bool seen_equal, bool* ok) {
1466 int pos = peek_position(); 1463 int pos = peek_position();
1467 if (!scanner()->ScanRegExpPattern(seen_equal)) { 1464 if (!scanner()->ScanRegExpPattern(seen_equal)) {
1468 Next(); 1465 Next();
1469 ReportMessage(MessageTemplate::kUnterminatedRegExp); 1466 ReportMessage(MessageTemplate::kUnterminatedRegExp);
1470 *ok = false; 1467 *ok = false;
1471 return Traits::EmptyExpression(); 1468 return Traits::EmptyExpression();
1472 } 1469 }
1473 1470
1474 int literal_index = function_state_->NextMaterializedLiteralIndex(); 1471 int literal_index = function_state_->NextMaterializedLiteralIndex();
1475 1472
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 1548
1552 case Token::STRING: { 1549 case Token::STRING: {
1553 BindingPatternUnexpectedToken(classifier); 1550 BindingPatternUnexpectedToken(classifier);
1554 Consume(Token::STRING); 1551 Consume(Token::STRING);
1555 return this->ExpressionFromString(beg_pos, scanner(), factory()); 1552 return this->ExpressionFromString(beg_pos, scanner(), factory());
1556 } 1553 }
1557 1554
1558 case Token::ASSIGN_DIV: 1555 case Token::ASSIGN_DIV:
1559 classifier->RecordBindingPatternError( 1556 classifier->RecordBindingPatternError(
1560 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); 1557 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp);
1561 return this->ParseRegExpLiteral(true, classifier, ok); 1558 return this->ParseRegExpLiteral(true, ok);
1562 1559
1563 case Token::DIV: 1560 case Token::DIV:
1564 classifier->RecordBindingPatternError( 1561 classifier->RecordBindingPatternError(
1565 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); 1562 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp);
1566 return this->ParseRegExpLiteral(false, classifier, ok); 1563 return this->ParseRegExpLiteral(false, ok);
1567 1564
1568 case Token::LBRACK: 1565 case Token::LBRACK:
1569 return this->ParseArrayLiteral(classifier, ok); 1566 return this->ParseArrayLiteral(classifier, ok);
1570 1567
1571 case Token::LBRACE: 1568 case Token::LBRACE:
1572 return this->ParseObjectLiteral(classifier, ok); 1569 return this->ParseObjectLiteral(classifier, ok);
1573 1570
1574 case Token::LPAREN: { 1571 case Token::LPAREN: {
1575 // Arrow function formal parameters are either a single identifier or a 1572 // Arrow function formal parameters are either a single identifier or a
1576 // list of BindingPattern productions enclosed in parentheses. 1573 // list of BindingPattern productions enclosed in parentheses.
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 // new new foo().bar().baz means (new (new foo()).bar()).baz 2943 // new new foo().bar().baz means (new (new foo()).bar()).baz
2947 2944
2948 if (peek() == Token::NEW) { 2945 if (peek() == Token::NEW) {
2949 BindingPatternUnexpectedToken(classifier); 2946 BindingPatternUnexpectedToken(classifier);
2950 ArrowFormalParametersUnexpectedToken(classifier); 2947 ArrowFormalParametersUnexpectedToken(classifier);
2951 Consume(Token::NEW); 2948 Consume(Token::NEW);
2952 int new_pos = position(); 2949 int new_pos = position();
2953 ExpressionT result; 2950 ExpressionT result;
2954 if (peek() == Token::SUPER) { 2951 if (peek() == Token::SUPER) {
2955 const bool is_new = true; 2952 const bool is_new = true;
2956 result = ParseSuperExpression(is_new, classifier, CHECK_OK); 2953 result = ParseSuperExpression(is_new, CHECK_OK);
2957 } else if (peek() == Token::PERIOD) { 2954 } else if (peek() == Token::PERIOD) {
2958 return ParseNewTargetExpression(CHECK_OK); 2955 return ParseNewTargetExpression(CHECK_OK);
2959 } else { 2956 } else {
2960 result = this->ParseMemberWithNewPrefixesExpression(classifier, is_async, 2957 result = this->ParseMemberWithNewPrefixesExpression(classifier, is_async,
2961 CHECK_OK); 2958 CHECK_OK);
2962 } 2959 }
2963 Traits::RewriteNonPattern(classifier, CHECK_OK); 2960 Traits::RewriteNonPattern(classifier, CHECK_OK);
2964 if (peek() == Token::LPAREN) { 2961 if (peek() == Token::LPAREN) {
2965 // NewExpression with arguments. 2962 // NewExpression with arguments.
2966 Scanner::Location spread_pos; 2963 Scanner::Location spread_pos;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 } 3034 }
3038 result = this->ParseFunctionLiteral( 3035 result = this->ParseFunctionLiteral(
3039 name, function_name_location, 3036 name, function_name_location,
3040 is_strict_reserved_name ? kFunctionNameIsStrictReserved 3037 is_strict_reserved_name ? kFunctionNameIsStrictReserved
3041 : kFunctionNameValidityUnknown, 3038 : kFunctionNameValidityUnknown,
3042 is_generator ? FunctionKind::kGeneratorFunction 3039 is_generator ? FunctionKind::kGeneratorFunction
3043 : FunctionKind::kNormalFunction, 3040 : FunctionKind::kNormalFunction,
3044 function_token_position, function_type, language_mode(), CHECK_OK); 3041 function_token_position, function_type, language_mode(), CHECK_OK);
3045 } else if (peek() == Token::SUPER) { 3042 } else if (peek() == Token::SUPER) {
3046 const bool is_new = false; 3043 const bool is_new = false;
3047 result = ParseSuperExpression(is_new, classifier, CHECK_OK); 3044 result = ParseSuperExpression(is_new, CHECK_OK);
3048 } else { 3045 } else {
3049 result = ParsePrimaryExpression(classifier, is_async, CHECK_OK); 3046 result = ParsePrimaryExpression(classifier, is_async, CHECK_OK);
3050 } 3047 }
3051 3048
3052 result = 3049 result =
3053 ParseMemberExpressionContinuation(result, is_async, classifier, CHECK_OK); 3050 ParseMemberExpressionContinuation(result, is_async, classifier, CHECK_OK);
3054 return result; 3051 return result;
3055 } 3052 }
3056 3053
3057
3058 template <class Traits> 3054 template <class Traits>
3059 typename ParserBase<Traits>::ExpressionT 3055 typename ParserBase<Traits>::ExpressionT
3060 ParserBase<Traits>::ParseSuperExpression(bool is_new, 3056 ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) {
3061 ExpressionClassifier* classifier,
3062 bool* ok) {
3063 Expect(Token::SUPER, CHECK_OK); 3057 Expect(Token::SUPER, CHECK_OK);
3064 int pos = position(); 3058 int pos = position();
3065 3059
3066 Scope* scope = this->scope()->ReceiverScope(); 3060 Scope* scope = this->scope()->ReceiverScope();
3067 FunctionKind kind = scope->function_kind(); 3061 FunctionKind kind = scope->function_kind();
3068 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || 3062 if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
3069 IsClassConstructor(kind)) { 3063 IsClassConstructor(kind)) {
3070 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { 3064 if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
3071 scope->RecordSuperPropertyUsage(); 3065 scope->RecordSuperPropertyUsage();
3072 return this->NewSuperPropertyReference(this->scope(), factory(), pos); 3066 return this->NewSuperPropertyReference(this->scope(), factory(), pos);
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 has_seen_constructor_ = true; 3654 has_seen_constructor_ = true;
3661 return; 3655 return;
3662 } 3656 }
3663 } 3657 }
3664 3658
3665 3659
3666 } // namespace internal 3660 } // namespace internal
3667 } // namespace v8 3661 } // namespace v8
3668 3662
3669 #endif // V8_PARSING_PARSER_BASE_H 3663 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698