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_AST_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2197 Type* combined_type_; | 2197 Type* combined_type_; |
2198 }; | 2198 }; |
2199 | 2199 |
2200 | 2200 |
2201 class Spread final : public Expression { | 2201 class Spread final : public Expression { |
2202 public: | 2202 public: |
2203 DECLARE_NODE_TYPE(Spread) | 2203 DECLARE_NODE_TYPE(Spread) |
2204 | 2204 |
2205 Expression* expression() const { return expression_; } | 2205 Expression* expression() const { return expression_; } |
2206 | 2206 |
2207 int literal_index() const { | |
2208 DCHECK(literal_index_ >= 0); | |
2209 return literal_index_; | |
2210 } | |
2211 | |
2207 static int num_ids() { return parent_num_ids(); } | 2212 static int num_ids() { return parent_num_ids(); } |
2208 | 2213 |
2209 protected: | 2214 protected: |
2210 Spread(Zone* zone, Expression* expression, int pos) | 2215 Spread(Zone* zone, Expression* expression, int literal_index, int pos) |
2211 : Expression(zone, pos), expression_(expression) {} | 2216 : Expression(zone, pos), |
2217 literal_index_(literal_index), | |
2218 expression_(expression) {} | |
2212 static int parent_num_ids() { return Expression::num_ids(); } | 2219 static int parent_num_ids() { return Expression::num_ids(); } |
2213 | 2220 |
2214 private: | 2221 private: |
2215 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2222 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2216 | 2223 |
2224 // Literal index is only used when Spread is renterpreted as a pattern. | |
rossberg
2015/05/20 12:57:35
Nit: typo
Dmitry Lomov (no reviews)
2015/05/20 14:22:02
Undid this change.
| |
2225 int literal_index_; | |
2226 | |
2217 Expression* expression_; | 2227 Expression* expression_; |
2218 }; | 2228 }; |
2219 | 2229 |
2220 | 2230 |
2221 class Conditional final : public Expression { | 2231 class Conditional final : public Expression { |
2222 public: | 2232 public: |
2223 DECLARE_NODE_TYPE(Conditional) | 2233 DECLARE_NODE_TYPE(Conditional) |
2224 | 2234 |
2225 Expression* condition() const { return condition_; } | 2235 Expression* condition() const { return condition_; } |
2226 Expression* then_expression() const { return then_expression_; } | 2236 Expression* then_expression() const { return then_expression_; } |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3417 return new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); | 3427 return new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); |
3418 } | 3428 } |
3419 | 3429 |
3420 CompareOperation* NewCompareOperation(Token::Value op, | 3430 CompareOperation* NewCompareOperation(Token::Value op, |
3421 Expression* left, | 3431 Expression* left, |
3422 Expression* right, | 3432 Expression* right, |
3423 int pos) { | 3433 int pos) { |
3424 return new (zone_) CompareOperation(zone_, op, left, right, pos); | 3434 return new (zone_) CompareOperation(zone_, op, left, right, pos); |
3425 } | 3435 } |
3426 | 3436 |
3427 Spread* NewSpread(Expression* expression, int pos) { | 3437 Spread* NewSpread(Expression* expression, int literal_index, int pos) { |
3428 return new (zone_) Spread(zone_, expression, pos); | 3438 return new (zone_) Spread(zone_, expression, literal_index, pos); |
3429 } | 3439 } |
3430 | 3440 |
3431 Conditional* NewConditional(Expression* condition, | 3441 Conditional* NewConditional(Expression* condition, |
3432 Expression* then_expression, | 3442 Expression* then_expression, |
3433 Expression* else_expression, | 3443 Expression* else_expression, |
3434 int position) { | 3444 int position) { |
3435 return new (zone_) Conditional(zone_, condition, then_expression, | 3445 return new (zone_) Conditional(zone_, condition, then_expression, |
3436 else_expression, position); | 3446 else_expression, position); |
3437 } | 3447 } |
3438 | 3448 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3505 | 3515 |
3506 private: | 3516 private: |
3507 Zone* zone_; | 3517 Zone* zone_; |
3508 AstValueFactory* ast_value_factory_; | 3518 AstValueFactory* ast_value_factory_; |
3509 }; | 3519 }; |
3510 | 3520 |
3511 | 3521 |
3512 } } // namespace v8::internal | 3522 } } // namespace v8::internal |
3513 | 3523 |
3514 #endif // V8_AST_H_ | 3524 #endif // V8_AST_H_ |
OLD | NEW |