| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestNode); | 262 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestNode); |
| 263 }; | 263 }; |
| 264 | 264 |
| 265 | 265 |
| 266 class ArrayNode : public AstNode { | 266 class ArrayNode : public AstNode { |
| 267 public: | 267 public: |
| 268 ArrayNode(intptr_t token_pos, const AbstractType& type) | 268 ArrayNode(intptr_t token_pos, const AbstractType& type) |
| 269 : AstNode(token_pos), | 269 : AstNode(token_pos), |
| 270 type_(type), | 270 type_(type), |
| 271 elements_() { | 271 elements_() { |
| 272 ASSERT(type_.IsZoneHandle()); | 272 CheckFields(); |
| 273 ASSERT(!type_.IsNull()); | 273 } |
| 274 ASSERT(type_.IsFinalized()); | 274 ArrayNode(intptr_t token_pos, |
| 275 // Type may be uninstantiated when creating a generic list literal. | 275 const AbstractType& type, |
| 276 ASSERT((type.arguments() == AbstractTypeArguments::null()) || | 276 const GrowableArray<AstNode*>& elements) |
| 277 ((AbstractTypeArguments::Handle(type.arguments()).Length() == 1))); | 277 : AstNode(token_pos), |
| 278 type_(type), |
| 279 elements_(elements.length()) { |
| 280 CheckFields(); |
| 281 for (intptr_t i = 0; i < elements.length(); i++) { |
| 282 elements_.Add(elements[i]); |
| 283 } |
| 278 } | 284 } |
| 279 | 285 |
| 280 void VisitChildren(AstNodeVisitor* visitor) const; | 286 void VisitChildren(AstNodeVisitor* visitor) const; |
| 281 | 287 |
| 282 intptr_t length() const { return elements_.length(); } | 288 intptr_t length() const { return elements_.length(); } |
| 283 | 289 |
| 284 AstNode* ElementAt(intptr_t index) const { return elements_[index]; } | 290 AstNode* ElementAt(intptr_t index) const { return elements_[index]; } |
| 285 void SetElementAt(intptr_t index, AstNode* value) { | 291 void SetElementAt(intptr_t index, AstNode* value) { |
| 286 elements_[index] = value; | 292 elements_[index] = value; |
| 287 } | 293 } |
| 288 void AddElement(AstNode* expr) { elements_.Add(expr); } | 294 void AddElement(AstNode* expr) { elements_.Add(expr); } |
| 289 | 295 |
| 290 const AbstractType& type() const { return type_; } | 296 const AbstractType& type() const { return type_; } |
| 291 | 297 |
| 292 DECLARE_COMMON_NODE_FUNCTIONS(ArrayNode); | 298 DECLARE_COMMON_NODE_FUNCTIONS(ArrayNode); |
| 293 | 299 |
| 294 private: | 300 private: |
| 295 const AbstractType& type_; | 301 const AbstractType& type_; |
| 296 GrowableArray<AstNode*> elements_; | 302 GrowableArray<AstNode*> elements_; |
| 297 | 303 |
| 304 void CheckFields() { |
| 305 ASSERT(type_.IsZoneHandle()); |
| 306 ASSERT(!type_.IsNull()); |
| 307 ASSERT(type_.IsFinalized()); |
| 308 // Type may be uninstantiated when creating a generic list literal. |
| 309 ASSERT((type_.arguments() == AbstractTypeArguments::null()) || |
| 310 ((AbstractTypeArguments::Handle(type_.arguments()).Length() == 1))); |
| 311 } |
| 312 |
| 298 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode); | 313 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode); |
| 299 }; | 314 }; |
| 300 | 315 |
| 301 | 316 |
| 302 class LiteralNode : public AstNode { | 317 class LiteralNode : public AstNode { |
| 303 public: | 318 public: |
| 304 LiteralNode(intptr_t token_pos, const Instance& literal) | 319 LiteralNode(intptr_t token_pos, const Instance& literal) |
| 305 : AstNode(token_pos), literal_(literal) { | 320 : AstNode(token_pos), literal_(literal) { |
| 306 ASSERT(literal_.IsNotTemporaryScopedHandle()); | 321 ASSERT(literal_.IsNotTemporaryScopedHandle()); |
| 307 ASSERT(literal_.IsSmi() || literal_.IsOld()); | 322 ASSERT(literal_.IsSmi() || literal_.IsOld()); |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 const LocalVariable& context_var_; | 1723 const LocalVariable& context_var_; |
| 1709 | 1724 |
| 1710 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1725 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1711 }; | 1726 }; |
| 1712 | 1727 |
| 1713 } // namespace dart | 1728 } // namespace dart |
| 1714 | 1729 |
| 1715 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1730 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1716 | 1731 |
| 1717 #endif // VM_AST_H_ | 1732 #endif // VM_AST_H_ |
| OLD | NEW |