Chromium Code Reviews| 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 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2914 | 2915 |
| 2915 // This class is produced when parsing the () in arrow functions without any | 2916 // This class is produced when parsing the () in arrow functions without any |
| 2916 // arguments and is not actually a valid expression. | 2917 // arguments and is not actually a valid expression. |
| 2917 class EmptyParentheses final : public Expression { | 2918 class EmptyParentheses final : public Expression { |
| 2918 private: | 2919 private: |
| 2919 friend class AstNodeFactory; | 2920 friend class AstNodeFactory; |
| 2920 | 2921 |
| 2921 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} | 2922 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} |
| 2922 }; | 2923 }; |
| 2923 | 2924 |
| 2925 // "Property" with additional semantics. | |
|
adamk
2016/12/06 18:49:05
This could use a little more detail for readers no
caitp
2016/12/06 19:00:44
Acknowledged.
| |
| 2926 class GetIterator final : public Expression { | |
| 2927 public: | |
| 2928 Expression* iterable() const { return iterable_; } | |
| 2929 void set_iterable(Expression* iterable) { iterable_ = iterable; } | |
| 2924 | 2930 |
| 2931 static int num_ids() { return parent_num_ids(); } | |
| 2932 | |
| 2933 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | |
| 2934 FeedbackVectorSlotCache* cache) { | |
| 2935 iterator_property_feedback_slot_ = | |
| 2936 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); | |
| 2937 iterator_call_feedback_slot_ = | |
| 2938 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); | |
| 2939 } | |
| 2940 | |
| 2941 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { | |
| 2942 return iterator_property_feedback_slot_; | |
| 2943 } | |
| 2944 | |
| 2945 FeedbackVectorSlot IteratorCallFeedbackSlot() const { | |
| 2946 return iterator_call_feedback_slot_; | |
| 2947 } | |
| 2948 | |
| 2949 private: | |
| 2950 friend class AstNodeFactory; | |
| 2951 | |
| 2952 explicit GetIterator(Expression* iterable, int pos) | |
| 2953 : Expression(pos, kGetIterator), iterable_(iterable) {} | |
| 2954 | |
| 2955 Expression* iterable_; | |
| 2956 FeedbackVectorSlot iterator_property_feedback_slot_; | |
| 2957 FeedbackVectorSlot iterator_call_feedback_slot_; | |
| 2958 }; | |
| 2925 | 2959 |
| 2926 // ---------------------------------------------------------------------------- | 2960 // ---------------------------------------------------------------------------- |
| 2927 // Basic visitor | 2961 // Basic visitor |
| 2928 // Sub-class should parametrize AstVisitor with itself, e.g.: | 2962 // Sub-class should parametrize AstVisitor with itself, e.g.: |
| 2929 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } | 2963 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } |
| 2930 | 2964 |
| 2931 template <class Subclass> | 2965 template <class Subclass> |
| 2932 class AstVisitor BASE_EMBEDDED { | 2966 class AstVisitor BASE_EMBEDDED { |
| 2933 public: | 2967 public: |
| 2934 void Visit(AstNode* node) { impl()->Visit(node); } | 2968 void Visit(AstNode* node) { impl()->Visit(node); } |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3494 VariableProxy* this_function_var, | 3528 VariableProxy* this_function_var, |
| 3495 int pos) { | 3529 int pos) { |
| 3496 return new (zone_) | 3530 return new (zone_) |
| 3497 SuperCallReference(this_var, new_target_var, this_function_var, pos); | 3531 SuperCallReference(this_var, new_target_var, this_function_var, pos); |
| 3498 } | 3532 } |
| 3499 | 3533 |
| 3500 EmptyParentheses* NewEmptyParentheses(int pos) { | 3534 EmptyParentheses* NewEmptyParentheses(int pos) { |
| 3501 return new (zone_) EmptyParentheses(pos); | 3535 return new (zone_) EmptyParentheses(pos); |
| 3502 } | 3536 } |
| 3503 | 3537 |
| 3538 GetIterator* NewGetIterator(Expression* iterable, int pos) { | |
| 3539 return new (zone_) GetIterator(iterable, pos); | |
| 3540 } | |
| 3541 | |
| 3504 Zone* zone() const { return zone_; } | 3542 Zone* zone() const { return zone_; } |
| 3505 void set_zone(Zone* zone) { zone_ = zone; } | 3543 void set_zone(Zone* zone) { zone_ = zone; } |
| 3506 | 3544 |
| 3507 // Handles use of temporary zones when parsing inner function bodies. | 3545 // Handles use of temporary zones when parsing inner function bodies. |
| 3508 class BodyScope { | 3546 class BodyScope { |
| 3509 public: | 3547 public: |
| 3510 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) | 3548 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
| 3511 : factory_(factory), prev_zone_(factory->zone_) { | 3549 : factory_(factory), prev_zone_(factory->zone_) { |
| 3512 if (use_temp_zone) { | 3550 if (use_temp_zone) { |
| 3513 factory->zone_ = temp_zone; | 3551 factory->zone_ = temp_zone; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3569 : NULL; \ | 3607 : NULL; \ |
| 3570 } | 3608 } |
| 3571 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3609 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3572 #undef DECLARE_NODE_FUNCTIONS | 3610 #undef DECLARE_NODE_FUNCTIONS |
| 3573 | 3611 |
| 3574 | 3612 |
| 3575 } // namespace internal | 3613 } // namespace internal |
| 3576 } // namespace v8 | 3614 } // namespace v8 |
| 3577 | 3615 |
| 3578 #endif // V8_AST_AST_H_ | 3616 #endif // V8_AST_AST_H_ |
| OLD | NEW |