OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_AST_H_ | 5 #ifndef VM_AST_H_ |
6 #define VM_AST_H_ | 6 #define VM_AST_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 #undef DEFINE_VISITOR_FUNCTION | 85 #undef DEFINE_VISITOR_FUNCTION |
86 | 86 |
87 private: | 87 private: |
88 DISALLOW_COPY_AND_ASSIGN(AstNodeVisitor); | 88 DISALLOW_COPY_AND_ASSIGN(AstNodeVisitor); |
89 }; | 89 }; |
90 | 90 |
91 | 91 |
92 #define DECLARE_COMMON_NODE_FUNCTIONS(type) \ | 92 #define DECLARE_COMMON_NODE_FUNCTIONS(type) \ |
93 virtual void Visit(AstNodeVisitor* visitor); \ | 93 virtual void Visit(AstNodeVisitor* visitor); \ |
94 virtual const char* PrettyName() const; \ | 94 virtual const char* PrettyName() const; \ |
95 virtual bool Is##type() const { return true; } \ | |
96 virtual type* As##type() { return this; } | 95 virtual type* As##type() { return this; } |
97 | 96 |
98 | 97 |
99 class AstNode : public ZoneAllocated { | 98 class AstNode : public ZoneAllocated { |
100 public: | 99 public: |
101 explicit AstNode(intptr_t token_pos) | 100 explicit AstNode(intptr_t token_pos) |
102 : token_pos_(token_pos) { | 101 : token_pos_(token_pos) { |
103 ASSERT(token_pos_ >= 0); | 102 ASSERT(token_pos_ >= 0); |
104 } | 103 } |
105 virtual ~AstNode() { } | 104 virtual ~AstNode() { } |
106 | 105 |
107 intptr_t token_pos() const { return token_pos_; } | 106 intptr_t token_pos() const { return token_pos_; } |
108 | 107 |
109 #define AST_TYPE_CHECK(BaseName) \ | 108 #define AST_TYPE_CHECK(BaseName) \ |
110 virtual bool Is##BaseName##Node() const { return false; } \ | 109 bool Is##BaseName##Node() { return As##BaseName##Node() != NULL; } \ |
111 virtual BaseName##Node* As##BaseName##Node() { return NULL; } | 110 virtual BaseName##Node* As##BaseName##Node() { return NULL; } |
112 | 111 |
113 FOR_EACH_NODE(AST_TYPE_CHECK) | 112 FOR_EACH_NODE(AST_TYPE_CHECK) |
114 #undef AST_TYPE_CHECK | 113 #undef AST_TYPE_CHECK |
115 | 114 |
116 virtual void Visit(AstNodeVisitor* visitor) = 0; | 115 virtual void Visit(AstNodeVisitor* visitor) = 0; |
117 virtual void VisitChildren(AstNodeVisitor* visitor) const = 0; | 116 virtual void VisitChildren(AstNodeVisitor* visitor) const = 0; |
118 virtual const char* PrettyName() const = 0; | 117 virtual const char* PrettyName() const = 0; |
119 | 118 |
120 // Convert the node into an assignment node using the rhs which is passed in, | 119 // Convert the node into an assignment node using the rhs which is passed in, |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 const intptr_t try_index_; | 2019 const intptr_t try_index_; |
2021 | 2020 |
2022 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 2021 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
2023 }; | 2022 }; |
2024 | 2023 |
2025 } // namespace dart | 2024 } // namespace dart |
2026 | 2025 |
2027 #undef DECLARE_COMMON_NODE_FUNCTIONS | 2026 #undef DECLARE_COMMON_NODE_FUNCTIONS |
2028 | 2027 |
2029 #endif // VM_AST_H_ | 2028 #endif // VM_AST_H_ |
OLD | NEW |