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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 template <class Traits> | 2095 template <class Traits> |
2096 typename ParserBase<Traits>::ExpressionT | 2096 typename ParserBase<Traits>::ExpressionT |
2097 ParserBase<Traits>::ParseYieldExpression(bool* ok) { | 2097 ParserBase<Traits>::ParseYieldExpression(bool* ok) { |
2098 // YieldExpression :: | 2098 // YieldExpression :: |
2099 // 'yield' ([no line terminator] '*'? AssignmentExpression)? | 2099 // 'yield' ([no line terminator] '*'? AssignmentExpression)? |
2100 int pos = peek_position(); | 2100 int pos = peek_position(); |
2101 Expect(Token::YIELD, CHECK_OK); | 2101 Expect(Token::YIELD, CHECK_OK); |
2102 ExpressionT generator_object = | 2102 ExpressionT generator_object = |
2103 factory()->NewVariableProxy(function_state_->generator_object_variable()); | 2103 factory()->NewVariableProxy(function_state_->generator_object_variable()); |
2104 ExpressionT expression = Traits::EmptyExpression(); | 2104 ExpressionT expression = Traits::EmptyExpression(); |
2105 Yield::Kind kind = Yield::SUSPEND; | 2105 Yield::Kind kind = Yield::kSuspend; |
2106 if (!scanner()->HasAnyLineTerminatorBeforeNext()) { | 2106 if (!scanner()->HasAnyLineTerminatorBeforeNext()) { |
2107 if (Check(Token::MUL)) kind = Yield::DELEGATING; | 2107 if (Check(Token::MUL)) kind = Yield::kDelegating; |
2108 switch (peek()) { | 2108 switch (peek()) { |
2109 case Token::EOS: | 2109 case Token::EOS: |
2110 case Token::SEMICOLON: | 2110 case Token::SEMICOLON: |
2111 case Token::RBRACE: | 2111 case Token::RBRACE: |
2112 case Token::RBRACK: | 2112 case Token::RBRACK: |
2113 case Token::RPAREN: | 2113 case Token::RPAREN: |
2114 case Token::COLON: | 2114 case Token::COLON: |
2115 case Token::COMMA: | 2115 case Token::COMMA: |
2116 // The above set of tokens is the complete set of tokens that can appear | 2116 // The above set of tokens is the complete set of tokens that can appear |
2117 // after an AssignmentExpression, and none of them can start an | 2117 // after an AssignmentExpression, and none of them can start an |
2118 // AssignmentExpression. This allows us to avoid looking for an RHS for | 2118 // AssignmentExpression. This allows us to avoid looking for an RHS for |
2119 // a Yield::SUSPEND operation, given only one look-ahead token. | 2119 // a Yield::kSuspend operation, given only one look-ahead token. |
2120 if (kind == Yield::SUSPEND) | 2120 if (kind == Yield::kSuspend) |
2121 break; | 2121 break; |
2122 DCHECK(kind == Yield::DELEGATING); | 2122 DCHECK_EQ(Yield::kDelegating, kind); |
2123 // Delegating yields require an RHS; fall through. | 2123 // Delegating yields require an RHS; fall through. |
2124 default: | 2124 default: |
2125 expression = ParseAssignmentExpression(false, CHECK_OK); | 2125 expression = ParseAssignmentExpression(false, CHECK_OK); |
2126 break; | 2126 break; |
2127 } | 2127 } |
2128 } | 2128 } |
2129 if (kind == Yield::DELEGATING) { | 2129 if (kind == Yield::kDelegating) { |
2130 // var iterator = subject[Symbol.iterator](); | 2130 // var iterator = subject[Symbol.iterator](); |
2131 expression = this->GetIterator(expression, factory()); | 2131 expression = this->GetIterator(expression, factory()); |
2132 } | 2132 } |
2133 typename Traits::Type::YieldExpression yield = | 2133 typename Traits::Type::YieldExpression yield = |
2134 factory()->NewYield(generator_object, expression, kind, pos); | 2134 factory()->NewYield(generator_object, expression, kind, pos); |
2135 if (kind == Yield::DELEGATING) { | 2135 if (kind == Yield::kDelegating) { |
2136 yield->set_index(function_state_->NextHandlerIndex()); | 2136 yield->set_index(function_state_->NextHandlerIndex()); |
2137 } | 2137 } |
2138 return yield; | 2138 return yield; |
2139 } | 2139 } |
2140 | 2140 |
2141 | 2141 |
2142 // Precedence = 3 | 2142 // Precedence = 3 |
2143 template <class Traits> | 2143 template <class Traits> |
2144 typename ParserBase<Traits>::ExpressionT | 2144 typename ParserBase<Traits>::ExpressionT |
2145 ParserBase<Traits>::ParseConditionalExpression(bool accept_IN, bool* ok) { | 2145 ParserBase<Traits>::ParseConditionalExpression(bool accept_IN, bool* ok) { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2661 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2661 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2662 // Both accessors of the same type. | 2662 // Both accessors of the same type. |
2663 parser()->ReportMessage("accessor_get_set"); | 2663 parser()->ReportMessage("accessor_get_set"); |
2664 } | 2664 } |
2665 *ok = false; | 2665 *ok = false; |
2666 } | 2666 } |
2667 } | 2667 } |
2668 } } // v8::internal | 2668 } } // v8::internal |
2669 | 2669 |
2670 #endif // V8_PREPARSER_H | 2670 #endif // V8_PREPARSER_H |
OLD | NEW |