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_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 V(CallRuntime) \ | 95 V(CallRuntime) \ |
96 V(UnaryOperation) \ | 96 V(UnaryOperation) \ |
97 V(BinaryOperation) \ | 97 V(BinaryOperation) \ |
98 V(CompareOperation) \ | 98 V(CompareOperation) \ |
99 V(Spread) \ | 99 V(Spread) \ |
100 V(ThisFunction) \ | 100 V(ThisFunction) \ |
101 V(SuperPropertyReference) \ | 101 V(SuperPropertyReference) \ |
102 V(SuperCallReference) \ | 102 V(SuperCallReference) \ |
103 V(CaseClause) \ | 103 V(CaseClause) \ |
104 V(EmptyParentheses) \ | 104 V(EmptyParentheses) \ |
| 105 V(GetIterator) \ |
105 V(DoExpression) \ | 106 V(DoExpression) \ |
106 V(RewritableExpression) | 107 V(RewritableExpression) |
107 | 108 |
108 #define AST_NODE_LIST(V) \ | 109 #define AST_NODE_LIST(V) \ |
109 DECLARATION_NODE_LIST(V) \ | 110 DECLARATION_NODE_LIST(V) \ |
110 STATEMENT_NODE_LIST(V) \ | 111 STATEMENT_NODE_LIST(V) \ |
111 EXPRESSION_NODE_LIST(V) | 112 EXPRESSION_NODE_LIST(V) |
112 | 113 |
113 // Forward declarations | 114 // Forward declarations |
114 class AstNodeFactory; | 115 class AstNodeFactory; |
(...skipping 2814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 | 2930 |
2930 // This class is produced when parsing the () in arrow functions without any | 2931 // This class is produced when parsing the () in arrow functions without any |
2931 // arguments and is not actually a valid expression. | 2932 // arguments and is not actually a valid expression. |
2932 class EmptyParentheses final : public Expression { | 2933 class EmptyParentheses final : public Expression { |
2933 private: | 2934 private: |
2934 friend class AstNodeFactory; | 2935 friend class AstNodeFactory; |
2935 | 2936 |
2936 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} | 2937 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} |
2937 }; | 2938 }; |
2938 | 2939 |
| 2940 // Represents the spec operation `GetIterator()` |
| 2941 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition |
| 2942 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to |
| 2943 // validate return value of the Symbol.iterator() call. |
| 2944 class GetIterator final : public Expression { |
| 2945 public: |
| 2946 Expression* iterable() const { return iterable_; } |
| 2947 void set_iterable(Expression* iterable) { iterable_ = iterable; } |
2939 | 2948 |
| 2949 static int num_ids() { return parent_num_ids(); } |
| 2950 |
| 2951 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2952 FeedbackVectorSlotCache* cache) { |
| 2953 iterator_property_feedback_slot_ = |
| 2954 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); |
| 2955 iterator_call_feedback_slot_ = |
| 2956 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); |
| 2957 } |
| 2958 |
| 2959 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { |
| 2960 return iterator_property_feedback_slot_; |
| 2961 } |
| 2962 |
| 2963 FeedbackVectorSlot IteratorCallFeedbackSlot() const { |
| 2964 return iterator_call_feedback_slot_; |
| 2965 } |
| 2966 |
| 2967 private: |
| 2968 friend class AstNodeFactory; |
| 2969 |
| 2970 explicit GetIterator(Expression* iterable, int pos) |
| 2971 : Expression(pos, kGetIterator), iterable_(iterable) {} |
| 2972 |
| 2973 Expression* iterable_; |
| 2974 FeedbackVectorSlot iterator_property_feedback_slot_; |
| 2975 FeedbackVectorSlot iterator_call_feedback_slot_; |
| 2976 }; |
2940 | 2977 |
2941 // ---------------------------------------------------------------------------- | 2978 // ---------------------------------------------------------------------------- |
2942 // Basic visitor | 2979 // Basic visitor |
2943 // Sub-class should parametrize AstVisitor with itself, e.g.: | 2980 // Sub-class should parametrize AstVisitor with itself, e.g.: |
2944 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } | 2981 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } |
2945 | 2982 |
2946 template <class Subclass> | 2983 template <class Subclass> |
2947 class AstVisitor BASE_EMBEDDED { | 2984 class AstVisitor BASE_EMBEDDED { |
2948 public: | 2985 public: |
2949 void Visit(AstNode* node) { impl()->Visit(node); } | 2986 void Visit(AstNode* node) { impl()->Visit(node); } |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3512 VariableProxy* this_function_var, | 3549 VariableProxy* this_function_var, |
3513 int pos) { | 3550 int pos) { |
3514 return new (zone_) | 3551 return new (zone_) |
3515 SuperCallReference(this_var, new_target_var, this_function_var, pos); | 3552 SuperCallReference(this_var, new_target_var, this_function_var, pos); |
3516 } | 3553 } |
3517 | 3554 |
3518 EmptyParentheses* NewEmptyParentheses(int pos) { | 3555 EmptyParentheses* NewEmptyParentheses(int pos) { |
3519 return new (zone_) EmptyParentheses(pos); | 3556 return new (zone_) EmptyParentheses(pos); |
3520 } | 3557 } |
3521 | 3558 |
| 3559 GetIterator* NewGetIterator(Expression* iterable, int pos) { |
| 3560 return new (zone_) GetIterator(iterable, pos); |
| 3561 } |
| 3562 |
3522 Zone* zone() const { return zone_; } | 3563 Zone* zone() const { return zone_; } |
3523 void set_zone(Zone* zone) { zone_ = zone; } | 3564 void set_zone(Zone* zone) { zone_ = zone; } |
3524 | 3565 |
3525 // Handles use of temporary zones when parsing inner function bodies. | 3566 // Handles use of temporary zones when parsing inner function bodies. |
3526 class BodyScope { | 3567 class BodyScope { |
3527 public: | 3568 public: |
3528 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) | 3569 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
3529 : factory_(factory), prev_zone_(factory->zone_) { | 3570 : factory_(factory), prev_zone_(factory->zone_) { |
3530 if (use_temp_zone) { | 3571 if (use_temp_zone) { |
3531 factory->zone_ = temp_zone; | 3572 factory->zone_ = temp_zone; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3587 : NULL; \ | 3628 : NULL; \ |
3588 } | 3629 } |
3589 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3630 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3590 #undef DECLARE_NODE_FUNCTIONS | 3631 #undef DECLARE_NODE_FUNCTIONS |
3591 | 3632 |
3592 | 3633 |
3593 } // namespace internal | 3634 } // namespace internal |
3594 } // namespace v8 | 3635 } // namespace v8 |
3595 | 3636 |
3596 #endif // V8_AST_AST_H_ | 3637 #endif // V8_AST_AST_H_ |
OLD | NEW |