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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 V(BinaryOperation) \ | 98 V(BinaryOperation) \ |
99 V(CompareOperation) \ | 99 V(CompareOperation) \ |
100 V(Spread) \ | 100 V(Spread) \ |
101 V(ThisFunction) \ | 101 V(ThisFunction) \ |
102 V(SuperPropertyReference) \ | 102 V(SuperPropertyReference) \ |
103 V(SuperCallReference) \ | 103 V(SuperCallReference) \ |
104 V(CaseClause) \ | 104 V(CaseClause) \ |
105 V(EmptyParentheses) \ | 105 V(EmptyParentheses) \ |
106 V(GetIterator) \ | 106 V(GetIterator) \ |
107 V(DoExpression) \ | 107 V(DoExpression) \ |
108 V(RewritableExpression) | 108 V(RewritableExpression) \ |
| 109 V(ImportCallExpression) |
109 | 110 |
110 #define AST_NODE_LIST(V) \ | 111 #define AST_NODE_LIST(V) \ |
111 DECLARATION_NODE_LIST(V) \ | 112 DECLARATION_NODE_LIST(V) \ |
112 STATEMENT_NODE_LIST(V) \ | 113 STATEMENT_NODE_LIST(V) \ |
113 EXPRESSION_NODE_LIST(V) | 114 EXPRESSION_NODE_LIST(V) |
114 | 115 |
115 // Forward declarations | 116 // Forward declarations |
116 class AstNodeFactory; | 117 class AstNodeFactory; |
117 class Declaration; | 118 class Declaration; |
118 class Module; | 119 class Module; |
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 DCHECK(this_var->is_this()); | 2967 DCHECK(this_var->is_this()); |
2967 DCHECK(new_target_var->raw_name()->IsOneByteEqualTo(".new.target")); | 2968 DCHECK(new_target_var->raw_name()->IsOneByteEqualTo(".new.target")); |
2968 DCHECK(this_function_var->raw_name()->IsOneByteEqualTo(".this_function")); | 2969 DCHECK(this_function_var->raw_name()->IsOneByteEqualTo(".this_function")); |
2969 } | 2970 } |
2970 | 2971 |
2971 VariableProxy* this_var_; | 2972 VariableProxy* this_var_; |
2972 VariableProxy* new_target_var_; | 2973 VariableProxy* new_target_var_; |
2973 VariableProxy* this_function_var_; | 2974 VariableProxy* this_function_var_; |
2974 }; | 2975 }; |
2975 | 2976 |
| 2977 // This AST Node is used to represent a dynamic import call -- |
| 2978 // import(argument). |
| 2979 class ImportCallExpression final : public Expression { |
| 2980 public: |
| 2981 Expression* argument() const { return argument_; } |
| 2982 void set_argument(Expression* argument) { argument_ = argument; } |
| 2983 |
| 2984 private: |
| 2985 friend class AstNodeFactory; |
| 2986 |
| 2987 ImportCallExpression(Expression* argument, int pos) |
| 2988 : Expression(pos, kImportCallExpression), argument_(argument) {} |
| 2989 |
| 2990 Expression* argument_; |
| 2991 }; |
2976 | 2992 |
2977 // This class is produced when parsing the () in arrow functions without any | 2993 // This class is produced when parsing the () in arrow functions without any |
2978 // arguments and is not actually a valid expression. | 2994 // arguments and is not actually a valid expression. |
2979 class EmptyParentheses final : public Expression { | 2995 class EmptyParentheses final : public Expression { |
2980 private: | 2996 private: |
2981 friend class AstNodeFactory; | 2997 friend class AstNodeFactory; |
2982 | 2998 |
2983 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} | 2999 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} |
2984 }; | 3000 }; |
2985 | 3001 |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 | 3632 |
3617 EmptyParentheses* NewEmptyParentheses(int pos) { | 3633 EmptyParentheses* NewEmptyParentheses(int pos) { |
3618 return new (zone_) EmptyParentheses(pos); | 3634 return new (zone_) EmptyParentheses(pos); |
3619 } | 3635 } |
3620 | 3636 |
3621 GetIterator* NewGetIterator(Expression* iterable, IteratorType hint, | 3637 GetIterator* NewGetIterator(Expression* iterable, IteratorType hint, |
3622 int pos) { | 3638 int pos) { |
3623 return new (zone_) GetIterator(iterable, hint, pos); | 3639 return new (zone_) GetIterator(iterable, hint, pos); |
3624 } | 3640 } |
3625 | 3641 |
| 3642 ImportCallExpression* NewImportCallExpression(Expression* args, int pos) { |
| 3643 return new (zone_) ImportCallExpression(args, pos); |
| 3644 } |
| 3645 |
3626 Zone* zone() const { return zone_; } | 3646 Zone* zone() const { return zone_; } |
3627 void set_zone(Zone* zone) { zone_ = zone; } | 3647 void set_zone(Zone* zone) { zone_ = zone; } |
3628 | 3648 |
3629 // Handles use of temporary zones when parsing inner function bodies. | 3649 // Handles use of temporary zones when parsing inner function bodies. |
3630 class BodyScope { | 3650 class BodyScope { |
3631 public: | 3651 public: |
3632 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) | 3652 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
3633 : factory_(factory), prev_zone_(factory->zone_) { | 3653 : factory_(factory), prev_zone_(factory->zone_) { |
3634 if (use_temp_zone) { | 3654 if (use_temp_zone) { |
3635 factory->zone_ = temp_zone; | 3655 factory->zone_ = temp_zone; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3691 : NULL; \ | 3711 : NULL; \ |
3692 } | 3712 } |
3693 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3713 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3694 #undef DECLARE_NODE_FUNCTIONS | 3714 #undef DECLARE_NODE_FUNCTIONS |
3695 | 3715 |
3696 | 3716 |
3697 } // namespace internal | 3717 } // namespace internal |
3698 } // namespace v8 | 3718 } // namespace v8 |
3699 | 3719 |
3700 #endif // V8_AST_AST_H_ | 3720 #endif // V8_AST_AST_H_ |
OLD | NEW |