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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Analyzes an expression to determine whether it is a compile time | 166 // Analyzes an expression to determine whether it is a compile time |
167 // constant or not. Returns NULL if the expression is not a compile time | 167 // constant or not. Returns NULL if the expression is not a compile time |
168 // constant. Otherwise, the return value is an approximation of the | 168 // constant. Otherwise, the return value is an approximation of the |
169 // actual value of the const expression. The type of the returned value | 169 // actual value of the const expression. The type of the returned value |
170 // corresponds to the type of the const expression and is either | 170 // corresponds to the type of the const expression and is either |
171 // Number, Integer, String, Bool, or anything else (not a subtype of | 171 // Number, Integer, String, Bool, or anything else (not a subtype of |
172 // the former). | 172 // the former). |
173 virtual const Instance* EvalConstExpr() const { return NULL; } | 173 virtual const Instance* EvalConstExpr() const { return NULL; } |
174 | 174 |
175 protected: | 175 protected: |
| 176 friend class ParsedFunction; |
| 177 |
176 const ICData& ic_data() const { return ic_data_; } | 178 const ICData& ic_data() const { return ic_data_; } |
177 void set_ic_data(const ICData& value) { | 179 void set_ic_data(const ICData& value) { |
178 ic_data_ = value.raw(); | 180 ic_data_ = value.raw(); |
179 } | 181 } |
180 | 182 |
181 static intptr_t GetNextId() { | 183 static intptr_t GetNextId() { |
182 Isolate* isolate = Isolate::Current(); | 184 Isolate* isolate = Isolate::Current(); |
183 intptr_t tmp = isolate->ast_node_id(); | 185 intptr_t tmp = isolate->ast_node_id(); |
184 isolate->set_ast_node_id(tmp + 1); | 186 isolate->set_ast_node_id(tmp + 1); |
185 return tmp; | 187 return tmp; |
(...skipping 10 matching lines...) Expand all Loading... |
196 DISALLOW_COPY_AND_ASSIGN(AstNode); | 198 DISALLOW_COPY_AND_ASSIGN(AstNode); |
197 }; | 199 }; |
198 | 200 |
199 | 201 |
200 class SequenceNode : public AstNode { | 202 class SequenceNode : public AstNode { |
201 public: | 203 public: |
202 SequenceNode(intptr_t token_index, LocalScope* scope) | 204 SequenceNode(intptr_t token_index, LocalScope* scope) |
203 : AstNode(token_index), | 205 : AstNode(token_index), |
204 scope_(scope), | 206 scope_(scope), |
205 nodes_(4), | 207 nodes_(4), |
206 label_(NULL) { | 208 label_(NULL), |
| 209 first_parameter_id_(AstNode::kNoId), |
| 210 last_parameter_id_(AstNode::kNoId) { |
207 } | 211 } |
208 | 212 |
209 LocalScope* scope() const { return scope_; } | 213 LocalScope* scope() const { return scope_; } |
210 | 214 |
211 SourceLabel* label() const { return label_; } | 215 SourceLabel* label() const { return label_; } |
212 void set_label(SourceLabel* value) { label_ = value; } | 216 void set_label(SourceLabel* value) { label_ = value; } |
213 | 217 |
214 void VisitChildren(AstNodeVisitor* visitor) const; | 218 void VisitChildren(AstNodeVisitor* visitor) const; |
215 | 219 |
216 void Add(AstNode* node) { nodes_.Add(node); } | 220 void Add(AstNode* node) { nodes_.Add(node); } |
217 intptr_t length() const { return nodes_.length(); } | 221 intptr_t length() const { return nodes_.length(); } |
218 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } | 222 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } |
219 | 223 |
| 224 void set_first_parameter_id(intptr_t value) { first_parameter_id_ = value; } |
| 225 void set_last_parameter_id(intptr_t value) { last_parameter_id_ = value; } |
| 226 intptr_t ParameterIdAt(intptr_t param_pos) const { |
| 227 ASSERT(first_parameter_id_ != AstNode::kNoId); |
| 228 ASSERT(last_parameter_id_ != AstNode::kNoId); |
| 229 ASSERT(param_pos <= (last_parameter_id_ - first_parameter_id_)); |
| 230 return first_parameter_id_ + param_pos; |
| 231 } |
| 232 |
220 DECLARE_COMMON_NODE_FUNCTIONS(SequenceNode); | 233 DECLARE_COMMON_NODE_FUNCTIONS(SequenceNode); |
221 | 234 |
222 // Collects all nodes accessible from this sequence node into array 'nodes'. | 235 // Collects all nodes accessible from this sequence node into array 'nodes'. |
223 void CollectAllNodes(GrowableArray<AstNode*>* nodes); | 236 void CollectAllNodes(GrowableArray<AstNode*>* nodes); |
224 | 237 |
225 private: | 238 private: |
226 LocalScope* scope_; | 239 LocalScope* scope_; |
227 GrowableArray<AstNode*> nodes_; | 240 GrowableArray<AstNode*> nodes_; |
228 SourceLabel* label_; | 241 SourceLabel* label_; |
| 242 intptr_t first_parameter_id_; |
| 243 intptr_t last_parameter_id_; |
229 | 244 |
230 DISALLOW_COPY_AND_ASSIGN(SequenceNode); | 245 DISALLOW_COPY_AND_ASSIGN(SequenceNode); |
231 }; | 246 }; |
232 | 247 |
233 | 248 |
234 class CloneContextNode : public AstNode { | 249 class CloneContextNode : public AstNode { |
235 public: | 250 public: |
236 explicit CloneContextNode(intptr_t token_index) | 251 explicit CloneContextNode(intptr_t token_index) |
237 : AstNode(token_index) { | 252 : AstNode(token_index) { |
238 } | 253 } |
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 const LocalVariable& context_var_; | 1874 const LocalVariable& context_var_; |
1860 | 1875 |
1861 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1876 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
1862 }; | 1877 }; |
1863 | 1878 |
1864 } // namespace dart | 1879 } // namespace dart |
1865 | 1880 |
1866 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1881 #undef DECLARE_COMMON_NODE_FUNCTIONS |
1867 | 1882 |
1868 #endif // VM_AST_H_ | 1883 #endif // VM_AST_H_ |
OLD | NEW |