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

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

Issue 2233473002: Redirect most NewUnresolved calls over Parser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 4 years, 4 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/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | 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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 // '(' Expression ')' 1543 // '(' Expression ')'
1544 // TemplateLiteral 1544 // TemplateLiteral
1545 // do Block 1545 // do Block
1546 // AsyncFunctionExpression 1546 // AsyncFunctionExpression
1547 1547
1548 int beg_pos = peek_position(); 1548 int beg_pos = peek_position();
1549 switch (peek()) { 1549 switch (peek()) {
1550 case Token::THIS: { 1550 case Token::THIS: {
1551 BindingPatternUnexpectedToken(classifier); 1551 BindingPatternUnexpectedToken(classifier);
1552 Consume(Token::THIS); 1552 Consume(Token::THIS);
1553 return this->ThisExpression(factory(), beg_pos); 1553 return this->ThisExpression(beg_pos);
1554 } 1554 }
1555 1555
1556 case Token::NULL_LITERAL: 1556 case Token::NULL_LITERAL:
1557 case Token::TRUE_LITERAL: 1557 case Token::TRUE_LITERAL:
1558 case Token::FALSE_LITERAL: 1558 case Token::FALSE_LITERAL:
1559 BindingPatternUnexpectedToken(classifier); 1559 BindingPatternUnexpectedToken(classifier);
1560 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory()); 1560 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory());
1561 case Token::SMI: 1561 case Token::SMI:
1562 case Token::NUMBER: 1562 case Token::NUMBER:
1563 BindingPatternUnexpectedToken(classifier); 1563 BindingPatternUnexpectedToken(classifier);
(...skipping 11 matching lines...) Expand all
1575 /* falls through */ 1575 /* falls through */
1576 case Token::IDENTIFIER: 1576 case Token::IDENTIFIER:
1577 case Token::LET: 1577 case Token::LET:
1578 case Token::STATIC: 1578 case Token::STATIC:
1579 case Token::YIELD: 1579 case Token::YIELD:
1580 case Token::AWAIT: 1580 case Token::AWAIT:
1581 case Token::ESCAPED_STRICT_RESERVED_WORD: 1581 case Token::ESCAPED_STRICT_RESERVED_WORD:
1582 case Token::FUTURE_STRICT_RESERVED_WORD: { 1582 case Token::FUTURE_STRICT_RESERVED_WORD: {
1583 // Using eval or arguments in this context is OK even in strict mode. 1583 // Using eval or arguments in this context is OK even in strict mode.
1584 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK); 1584 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK);
1585 return this->ExpressionFromIdentifier( 1585 return this->ExpressionFromIdentifier(name, beg_pos,
1586 name, beg_pos, scanner()->location().end_pos, factory()); 1586 scanner()->location().end_pos);
1587 } 1587 }
1588 1588
1589 case Token::STRING: { 1589 case Token::STRING: {
1590 BindingPatternUnexpectedToken(classifier); 1590 BindingPatternUnexpectedToken(classifier);
1591 Consume(Token::STRING); 1591 Consume(Token::STRING);
1592 return this->ExpressionFromString(beg_pos, scanner(), factory()); 1592 return this->ExpressionFromString(beg_pos, scanner(), factory());
1593 } 1593 }
1594 1594
1595 case Token::ASSIGN_DIV: 1595 case Token::ASSIGN_DIV:
1596 classifier->RecordBindingPatternError( 1596 classifier->RecordBindingPatternError(
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 if (is_async_function()) { 2000 if (is_async_function()) {
2001 classifier->RecordPatternError( 2001 classifier->RecordPatternError(
2002 Scanner::Location(next_beg_pos, next_end_pos), 2002 Scanner::Location(next_beg_pos, next_end_pos),
2003 MessageTemplate::kAwaitBindingIdentifier); 2003 MessageTemplate::kAwaitBindingIdentifier);
2004 } else { 2004 } else {
2005 classifier->RecordAsyncArrowFormalParametersError( 2005 classifier->RecordAsyncArrowFormalParametersError(
2006 Scanner::Location(next_beg_pos, next_end_pos), 2006 Scanner::Location(next_beg_pos, next_end_pos),
2007 MessageTemplate::kAwaitBindingIdentifier); 2007 MessageTemplate::kAwaitBindingIdentifier);
2008 } 2008 }
2009 } 2009 }
2010 ExpressionT lhs = this->ExpressionFromIdentifier(*name, next_beg_pos, 2010 ExpressionT lhs =
2011 next_end_pos, factory()); 2011 this->ExpressionFromIdentifier(*name, next_beg_pos, next_end_pos);
2012 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos); 2012 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
2013 2013
2014 ExpressionT value; 2014 ExpressionT value;
2015 if (peek() == Token::ASSIGN) { 2015 if (peek() == Token::ASSIGN) {
2016 Consume(Token::ASSIGN); 2016 Consume(Token::ASSIGN);
2017 ExpressionClassifier rhs_classifier(this); 2017 ExpressionClassifier rhs_classifier(this);
2018 ExpressionT rhs = this->ParseAssignmentExpression( 2018 ExpressionT rhs = this->ParseAssignmentExpression(
2019 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2019 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2020 Traits::RewriteNonPattern(&rhs_classifier, 2020 Traits::RewriteNonPattern(&rhs_classifier,
2021 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2021 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 if (!is_async && !parenthesized_formals) { 2310 if (!is_async && !parenthesized_formals) {
2311 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); 2311 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier);
2312 } 2312 }
2313 ExpressionT expression = this->ParseConditionalExpression( 2313 ExpressionT expression = this->ParseConditionalExpression(
2314 accept_IN, &arrow_formals_classifier, CHECK_OK); 2314 accept_IN, &arrow_formals_classifier, CHECK_OK);
2315 2315
2316 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) { 2316 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) {
2317 // async Identifier => AsyncConciseBody 2317 // async Identifier => AsyncConciseBody
2318 IdentifierT name = 2318 IdentifierT name =
2319 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK); 2319 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK);
2320 expression = this->ExpressionFromIdentifier( 2320 expression = this->ExpressionFromIdentifier(name, position(),
2321 name, position(), scanner()->location().end_pos, factory()); 2321 scanner()->location().end_pos);
2322 } 2322 }
2323 2323
2324 if (peek() == Token::ARROW) { 2324 if (peek() == Token::ARROW) {
2325 Scanner::Location arrow_loc = scanner()->peek_location(); 2325 Scanner::Location arrow_loc = scanner()->peek_location();
2326 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, 2326 ValidateArrowFormalParameters(&arrow_formals_classifier, expression,
2327 parenthesized_formals, is_async, CHECK_OK); 2327 parenthesized_formals, is_async, CHECK_OK);
2328 // This reads strangely, but is correct: it checks whether any 2328 // This reads strangely, but is correct: it checks whether any
2329 // sub-expression of the parameter list failed to be a valid formal 2329 // sub-expression of the parameter list failed to be a valid formal
2330 // parameter initializer. Since YieldExpressions are banned anywhere 2330 // parameter initializer. Since YieldExpressions are banned anywhere
2331 // in an arrow parameter list, this is correct. 2331 // in an arrow parameter list, this is correct.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 2755
2756 // Possibly async arrow formals --- record ExpressionError just in case. 2756 // Possibly async arrow formals --- record ExpressionError just in case.
2757 ExpressionUnexpectedToken(classifier); 2757 ExpressionUnexpectedToken(classifier);
2758 classifier->RecordAsyncBindingPatternError( 2758 classifier->RecordAsyncBindingPatternError(
2759 Scanner::Location(beg_pos, scanner()->location().end_pos), 2759 Scanner::Location(beg_pos, scanner()->location().end_pos),
2760 MessageTemplate::kAwaitBindingIdentifier); 2760 MessageTemplate::kAwaitBindingIdentifier);
2761 classifier->RecordAsyncArrowFormalParametersError( 2761 classifier->RecordAsyncArrowFormalParametersError(
2762 Scanner::Location(beg_pos, scanner()->location().end_pos), 2762 Scanner::Location(beg_pos, scanner()->location().end_pos),
2763 MessageTemplate::kAwaitBindingIdentifier); 2763 MessageTemplate::kAwaitBindingIdentifier);
2764 2764
2765 return this->ExpressionFromIdentifier( 2765 return this->ExpressionFromIdentifier(name, beg_pos,
2766 name, beg_pos, scanner()->location().end_pos, factory()); 2766 scanner()->location().end_pos);
2767 } 2767 }
2768 default: 2768 default:
2769 break; 2769 break;
2770 } 2770 }
2771 2771
2772 int await_pos = peek_position(); 2772 int await_pos = peek_position();
2773 Consume(Token::AWAIT); 2773 Consume(Token::AWAIT);
2774 2774
2775 ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK); 2775 ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK);
2776 2776
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 if (spread_pos.IsValid()) { 2914 if (spread_pos.IsValid()) {
2915 args = Traits::PrepareSpreadArguments(args); 2915 args = Traits::PrepareSpreadArguments(args);
2916 result = Traits::SpreadCall(result, args, pos); 2916 result = Traits::SpreadCall(result, args, pos);
2917 } else { 2917 } else {
2918 result = factory()->NewCall(result, args, pos); 2918 result = factory()->NewCall(result, args, pos);
2919 } 2919 }
2920 2920
2921 // Explicit calls to the super constructor using super() perform an 2921 // Explicit calls to the super constructor using super() perform an
2922 // implicit binding assignment to the 'this' variable. 2922 // implicit binding assignment to the 'this' variable.
2923 if (is_super_call) { 2923 if (is_super_call) {
2924 ExpressionT this_expr = this->ThisExpression(factory(), pos); 2924 ExpressionT this_expr = this->ThisExpression(pos);
2925 result = 2925 result =
2926 factory()->NewAssignment(Token::INIT, this_expr, result, pos); 2926 factory()->NewAssignment(Token::INIT, this_expr, result, pos);
2927 } 2927 }
2928 2928
2929 if (fni_ != NULL) fni_->RemoveLastFunction(); 2929 if (fni_ != NULL) fni_->RemoveLastFunction();
2930 break; 2930 break;
2931 } 2931 }
2932 2932
2933 case Token::PERIOD: { 2933 case Token::PERIOD: {
2934 CheckNoTailCallExpressions(classifier, CHECK_OK); 2934 CheckNoTailCallExpressions(classifier, CHECK_OK);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 int pos = position(); 3141 int pos = position();
3142 ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK); 3142 ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK);
3143 3143
3144 if (!GetReceiverScope()->is_function_scope()) { 3144 if (!GetReceiverScope()->is_function_scope()) {
3145 ReportMessageAt(scanner()->location(), 3145 ReportMessageAt(scanner()->location(),
3146 MessageTemplate::kUnexpectedNewTarget); 3146 MessageTemplate::kUnexpectedNewTarget);
3147 *ok = false; 3147 *ok = false;
3148 return this->EmptyExpression(); 3148 return this->EmptyExpression();
3149 } 3149 }
3150 3150
3151 return this->NewTargetExpression(factory(), pos); 3151 return this->NewTargetExpression(pos);
3152 } 3152 }
3153 3153
3154 template <class Traits> 3154 template <class Traits>
3155 typename ParserBase<Traits>::ExpressionT 3155 typename ParserBase<Traits>::ExpressionT
3156 ParserBase<Traits>::ParseMemberExpressionContinuation( 3156 ParserBase<Traits>::ParseMemberExpressionContinuation(
3157 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier, 3157 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier,
3158 bool* ok) { 3158 bool* ok) {
3159 // Parses this part of MemberExpression: 3159 // Parses this part of MemberExpression:
3160 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)* 3160 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
3161 while (true) { 3161 while (true) {
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 has_seen_constructor_ = true; 3696 has_seen_constructor_ = true;
3697 return; 3697 return;
3698 } 3698 }
3699 } 3699 }
3700 3700
3701 3701
3702 } // namespace internal 3702 } // namespace internal
3703 } // namespace v8 3703 } // namespace v8
3704 3704
3705 #endif // V8_PARSING_PARSER_BASE_H 3705 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698