| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assert.h" | 9 #include "vm/assert.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 V(IfNode, "if") \ | 31 V(IfNode, "if") \ |
| 32 V(SwitchNode, "switch") \ | 32 V(SwitchNode, "switch") \ |
| 33 V(CaseNode, "case") \ | 33 V(CaseNode, "case") \ |
| 34 V(WhileNode, "while") \ | 34 V(WhileNode, "while") \ |
| 35 V(DoWhileNode, "dowhile") \ | 35 V(DoWhileNode, "dowhile") \ |
| 36 V(ForNode, "for") \ | 36 V(ForNode, "for") \ |
| 37 V(JumpNode, "jump") \ | 37 V(JumpNode, "jump") \ |
| 38 V(ArgumentListNode, "args") \ | 38 V(ArgumentListNode, "args") \ |
| 39 V(ArrayNode, "array") \ | 39 V(ArrayNode, "array") \ |
| 40 V(ClosureNode, "closure") \ | 40 V(ClosureNode, "closure") \ |
| 41 V(ImplicitInstanceClosureNode, "implicit instance closure") \ | |
| 42 V(ImplicitStaticClosureNode, "implicit static closure") \ | |
| 43 V(InstanceCallNode, "instance call") \ | 41 V(InstanceCallNode, "instance call") \ |
| 44 V(StaticCallNode, "static call") \ | 42 V(StaticCallNode, "static call") \ |
| 45 V(ClosureCallNode, "closure call") \ | 43 V(ClosureCallNode, "closure call") \ |
| 46 V(ConstructorCallNode, "constructor call") \ | 44 V(ConstructorCallNode, "constructor call") \ |
| 47 V(InstanceGetterNode, "instance getter call") \ | 45 V(InstanceGetterNode, "instance getter call") \ |
| 48 V(InstanceSetterNode, "instance setter call") \ | 46 V(InstanceSetterNode, "instance setter call") \ |
| 49 V(StaticGetterNode, "static getter") \ | 47 V(StaticGetterNode, "static getter") \ |
| 50 V(StaticSetterNode, "static setter") \ | 48 V(StaticSetterNode, "static setter") \ |
| 51 V(NativeBodyNode, "native body") \ | 49 V(NativeBodyNode, "native body") \ |
| 52 V(PrimaryNode, "primary") \ | 50 V(PrimaryNode, "primary") \ |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 354 |
| 357 private: | 355 private: |
| 358 const Type& type_; | 356 const Type& type_; |
| 359 | 357 |
| 360 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeNode); | 358 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeNode); |
| 361 }; | 359 }; |
| 362 | 360 |
| 363 | 361 |
| 364 class ClosureNode : public AstNode { | 362 class ClosureNode : public AstNode { |
| 365 public: | 363 public: |
| 366 ClosureNode(intptr_t token_index, const Function& function, LocalScope* scope) | 364 ClosureNode(intptr_t token_index, |
| 367 : AstNode(token_index), function_(function), scope_(scope) { | 365 const Function& function, |
| 366 AstNode* receiver, // Non-null for implicit instance closures. |
| 367 LocalScope* scope) // Null for implicit closures. |
| 368 : AstNode(token_index), |
| 369 function_(function), |
| 370 receiver_(receiver), |
| 371 scope_(scope) { |
| 368 ASSERT(function.IsZoneHandle()); | 372 ASSERT(function.IsZoneHandle()); |
| 369 ASSERT(function.IsNonImplicitClosureFunction()); | 373 ASSERT((function.IsNonImplicitClosureFunction() && |
| 370 ASSERT(scope_ != NULL); | 374 (receiver_ == NULL) && (scope_ != NULL)) || |
| 371 } | 375 (function.IsImplicitInstanceClosureFunction() && |
| 372 | 376 (receiver_ != NULL) && (scope_ == NULL)) || |
| 373 const Function& function() const { return function_; } | 377 (function.IsImplicitStaticClosureFunction() && |
| 374 LocalScope* scope() const { return scope_; } | 378 (receiver_ == NULL) && (scope_ == NULL))); |
| 375 | |
| 376 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | |
| 377 | |
| 378 DECLARE_COMMON_NODE_FUNCTIONS(ClosureNode); | |
| 379 | |
| 380 private: | |
| 381 const Function& function_; | |
| 382 LocalScope* scope_; | |
| 383 | |
| 384 DISALLOW_IMPLICIT_CONSTRUCTORS(ClosureNode); | |
| 385 }; | |
| 386 | |
| 387 | |
| 388 class ImplicitStaticClosureNode : public AstNode { | |
| 389 public: | |
| 390 ImplicitStaticClosureNode(intptr_t token_index, const Function& function) | |
| 391 : AstNode(token_index), function_(function) { | |
| 392 ASSERT(function.IsZoneHandle()); | |
| 393 ASSERT(function.IsImplicitStaticClosureFunction()); | |
| 394 } | |
| 395 | |
| 396 const Function& function() const { return function_; } | |
| 397 | |
| 398 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | |
| 399 | |
| 400 DECLARE_COMMON_NODE_FUNCTIONS(ImplicitStaticClosureNode); | |
| 401 | |
| 402 private: | |
| 403 const Function& function_; | |
| 404 | |
| 405 DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitStaticClosureNode); | |
| 406 }; | |
| 407 | |
| 408 | |
| 409 class ImplicitInstanceClosureNode : public AstNode { | |
| 410 public: | |
| 411 ImplicitInstanceClosureNode(intptr_t token_index, | |
| 412 const Function& function, | |
| 413 AstNode* receiver) | |
| 414 : AstNode(token_index), function_(function), receiver_(receiver) { | |
| 415 ASSERT(function.IsZoneHandle()); | |
| 416 ASSERT(function.IsImplicitInstanceClosureFunction()); | |
| 417 } | 379 } |
| 418 | 380 |
| 419 const Function& function() const { return function_; } | 381 const Function& function() const { return function_; } |
| 420 AstNode* receiver() const { return receiver_; } | 382 AstNode* receiver() const { return receiver_; } |
| 383 LocalScope* scope() const { return scope_; } |
| 421 | 384 |
| 422 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 385 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 423 if (receiver() != NULL) { | 386 if (receiver() != NULL) { |
| 424 receiver()->Visit(visitor); | 387 receiver()->Visit(visitor); |
| 425 } | 388 } |
| 426 } | 389 } |
| 427 | 390 |
| 428 DECLARE_COMMON_NODE_FUNCTIONS(ImplicitInstanceClosureNode); | 391 DECLARE_COMMON_NODE_FUNCTIONS(ClosureNode); |
| 429 | 392 |
| 430 private: | 393 private: |
| 431 const Function& function_; | 394 const Function& function_; |
| 432 AstNode* receiver_; | 395 AstNode* receiver_; |
| 396 LocalScope* scope_; |
| 433 | 397 |
| 434 DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitInstanceClosureNode); | 398 DISALLOW_IMPLICIT_CONSTRUCTORS(ClosureNode); |
| 435 }; | 399 }; |
| 436 | 400 |
| 437 | 401 |
| 438 // Primary nodes hold identifiers or values (library, class or function) | 402 // Primary nodes hold identifiers or values (library, class or function) |
| 439 // resolved from an identifier. Primary nodes should not ever make it to the | 403 // resolved from an identifier. Primary nodes should not ever make it to the |
| 440 // code generation phase as they will be transformed into the correct call or | 404 // code generation phase as they will be transformed into the correct call or |
| 441 // field access nodes. | 405 // field access nodes. |
| 442 class PrimaryNode : public AstNode { | 406 class PrimaryNode : public AstNode { |
| 443 public: | 407 public: |
| 444 PrimaryNode(intptr_t token_index, const Object& primary) | 408 PrimaryNode(intptr_t token_index, const Object& primary) |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 const LocalVariable& context_var_; | 1876 const LocalVariable& context_var_; |
| 1913 | 1877 |
| 1914 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1878 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1915 }; | 1879 }; |
| 1916 | 1880 |
| 1917 } // namespace dart | 1881 } // namespace dart |
| 1918 | 1882 |
| 1919 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1883 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1920 | 1884 |
| 1921 #endif // VM_AST_H_ | 1885 #endif // VM_AST_H_ |
| OLD | NEW |