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

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

Issue 1751613004: Get rid of the different kinds of yield in the AST & full-codegen. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Do an inline call. Created 4 years, 9 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/preparser.h » ('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/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 // YieldExpression :: 2122 // YieldExpression ::
2123 // 'yield' ([no line terminator] '*'? AssignmentExpression)? 2123 // 'yield' ([no line terminator] '*'? AssignmentExpression)?
2124 int pos = peek_position(); 2124 int pos = peek_position();
2125 classifier->RecordPatternError(scanner()->peek_location(), 2125 classifier->RecordPatternError(scanner()->peek_location(),
2126 MessageTemplate::kInvalidDestructuringTarget); 2126 MessageTemplate::kInvalidDestructuringTarget);
2127 FormalParameterInitializerUnexpectedToken(classifier); 2127 FormalParameterInitializerUnexpectedToken(classifier);
2128 Expect(Token::YIELD, CHECK_OK); 2128 Expect(Token::YIELD, CHECK_OK);
2129 ExpressionT generator_object = 2129 ExpressionT generator_object =
2130 factory()->NewVariableProxy(function_state_->generator_object_variable()); 2130 factory()->NewVariableProxy(function_state_->generator_object_variable());
2131 ExpressionT expression = Traits::EmptyExpression(); 2131 ExpressionT expression = Traits::EmptyExpression();
2132 Yield::Kind kind = Yield::kSuspend; 2132 bool delegating = false; // yield*
2133 if (!scanner()->HasAnyLineTerminatorBeforeNext()) { 2133 if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
2134 if (Check(Token::MUL)) kind = Yield::kDelegating; 2134 if (Check(Token::MUL)) delegating = true;
2135 switch (peek()) { 2135 switch (peek()) {
2136 case Token::EOS: 2136 case Token::EOS:
2137 case Token::SEMICOLON: 2137 case Token::SEMICOLON:
2138 case Token::RBRACE: 2138 case Token::RBRACE:
2139 case Token::RBRACK: 2139 case Token::RBRACK:
2140 case Token::RPAREN: 2140 case Token::RPAREN:
2141 case Token::COLON: 2141 case Token::COLON:
2142 case Token::COMMA: 2142 case Token::COMMA:
2143 // The above set of tokens is the complete set of tokens that can appear 2143 // The above set of tokens is the complete set of tokens that can appear
2144 // after an AssignmentExpression, and none of them can start an 2144 // after an AssignmentExpression, and none of them can start an
2145 // AssignmentExpression. This allows us to avoid looking for an RHS for 2145 // AssignmentExpression. This allows us to avoid looking for an RHS for
2146 // a Yield::kSuspend operation, given only one look-ahead token. 2146 // a regular yield, given only one look-ahead token.
2147 if (kind == Yield::kSuspend) 2147 if (!delegating) break;
2148 break;
2149 DCHECK_EQ(Yield::kDelegating, kind);
2150 // Delegating yields require an RHS; fall through. 2148 // Delegating yields require an RHS; fall through.
2151 default: 2149 default:
2152 expression = ParseAssignmentExpression(false, classifier, CHECK_OK); 2150 expression = ParseAssignmentExpression(false, classifier, CHECK_OK);
2153 Traits::RewriteNonPattern(classifier, CHECK_OK); 2151 Traits::RewriteNonPattern(classifier, CHECK_OK);
2154 break; 2152 break;
2155 } 2153 }
2156 } 2154 }
2157 if (kind == Yield::kDelegating) { 2155
2156 if (delegating) {
2158 return Traits::RewriteYieldStar(generator_object, expression, pos); 2157 return Traits::RewriteYieldStar(generator_object, expression, pos);
2159 } 2158 }
2159
2160 expression = Traits::BuildIteratorResult(expression, false);
2160 // Hackily disambiguate o from o.next and o [Symbol.iterator](). 2161 // Hackily disambiguate o from o.next and o [Symbol.iterator]().
2161 // TODO(verwaest): Come up with a better solution. 2162 // TODO(verwaest): Come up with a better solution.
2162 typename Traits::Type::YieldExpression yield = 2163 typename Traits::Type::YieldExpression yield =
2163 factory()->NewYield(generator_object, expression, kind, pos); 2164 factory()->NewYield(generator_object, expression, pos);
2164 return yield; 2165 return yield;
2165 } 2166 }
2166 2167
2167 2168
2168 // Precedence = 3 2169 // Precedence = 3
2169 template <class Traits> 2170 template <class Traits>
2170 typename ParserBase<Traits>::ExpressionT 2171 typename ParserBase<Traits>::ExpressionT
2171 ParserBase<Traits>::ParseConditionalExpression(bool accept_IN, 2172 ParserBase<Traits>::ParseConditionalExpression(bool accept_IN,
2172 ExpressionClassifier* classifier, 2173 ExpressionClassifier* classifier,
2173 bool* ok) { 2174 bool* ok) {
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3369 has_seen_constructor_ = true; 3370 has_seen_constructor_ = true;
3370 return; 3371 return;
3371 } 3372 }
3372 } 3373 }
3373 3374
3374 3375
3375 } // namespace internal 3376 } // namespace internal
3376 } // namespace v8 3377 } // namespace v8
3377 3378
3378 #endif // V8_PARSING_PARSER_BASE_H 3379 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698