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 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 // the instantiator is the receiver of this function. In order to instantiate T | 1425 // the instantiator is the receiver of this function. In order to instantiate T |
1426 // in the example above (which could for example be the first type parameter of | 1426 // in the example above (which could for example be the first type parameter of |
1427 // the class of the caller), the code at run time extracts the type arguments of | 1427 // the class of the caller), the code at run time extracts the type arguments of |
1428 // the receiver at an offset in the receiver specified by the provided | 1428 // the receiver at an offset in the receiver specified by the provided |
1429 // instantiator_class. | 1429 // instantiator_class. |
1430 // | 1430 // |
1431 // If the caller to the constructor or to the factory is a factory, then the | 1431 // If the caller to the constructor or to the factory is a factory, then the |
1432 // instantiator is the first parameter of this factory, which is already a | 1432 // instantiator is the first parameter of this factory, which is already a |
1433 // type argument vector. This case is identified by a null and unneeded | 1433 // type argument vector. This case is identified by a null and unneeded |
1434 // instantiator_class. | 1434 // instantiator_class. |
| 1435 // |
| 1436 // A temporary local is needed to hold the allocated value while the |
| 1437 // constructor is being called. |
1435 class ConstructorCallNode : public AstNode { | 1438 class ConstructorCallNode : public AstNode { |
1436 public: | 1439 public: |
1437 ConstructorCallNode(intptr_t token_index, | 1440 ConstructorCallNode(intptr_t token_index, |
1438 const AbstractTypeArguments& type_arguments, | 1441 const AbstractTypeArguments& type_arguments, |
1439 const Function& constructor, | 1442 const Function& constructor, |
1440 ArgumentListNode* arguments) | 1443 ArgumentListNode* arguments, |
| 1444 const LocalVariable& allocated_object_var) |
1441 : AstNode(token_index), | 1445 : AstNode(token_index), |
1442 type_arguments_(type_arguments), | 1446 type_arguments_(type_arguments), |
1443 constructor_(constructor), | 1447 constructor_(constructor), |
1444 arguments_(arguments) { | 1448 arguments_(arguments), |
| 1449 allocated_object_var_(allocated_object_var) { |
1445 ASSERT(type_arguments_.IsZoneHandle()); | 1450 ASSERT(type_arguments_.IsZoneHandle()); |
1446 ASSERT(constructor_.IsZoneHandle()); | 1451 ASSERT(constructor_.IsZoneHandle()); |
1447 ASSERT(arguments_ != NULL); | 1452 ASSERT(arguments_ != NULL); |
1448 } | 1453 } |
1449 | 1454 |
1450 const AbstractTypeArguments& type_arguments() const { | 1455 const AbstractTypeArguments& type_arguments() const { |
1451 return type_arguments_; | 1456 return type_arguments_; |
1452 } | 1457 } |
1453 const Function& constructor() const { return constructor_; } | 1458 const Function& constructor() const { return constructor_; } |
1454 ArgumentListNode* arguments() const { return arguments_; } | 1459 ArgumentListNode* arguments() const { return arguments_; } |
| 1460 const LocalVariable& allocated_object_var() const { |
| 1461 return allocated_object_var_; |
| 1462 } |
1455 | 1463 |
1456 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1464 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
1457 arguments()->Visit(visitor); | 1465 arguments()->Visit(visitor); |
1458 } | 1466 } |
1459 | 1467 |
1460 DECLARE_COMMON_NODE_FUNCTIONS(ConstructorCallNode); | 1468 DECLARE_COMMON_NODE_FUNCTIONS(ConstructorCallNode); |
1461 | 1469 |
1462 private: | 1470 private: |
1463 const AbstractTypeArguments& type_arguments_; | 1471 const AbstractTypeArguments& type_arguments_; |
1464 const Function& constructor_; | 1472 const Function& constructor_; |
1465 ArgumentListNode* arguments_; | 1473 ArgumentListNode* arguments_; |
| 1474 const LocalVariable& allocated_object_var_; |
1466 | 1475 |
1467 DISALLOW_IMPLICIT_CONSTRUCTORS(ConstructorCallNode); | 1476 DISALLOW_IMPLICIT_CONSTRUCTORS(ConstructorCallNode); |
1468 }; | 1477 }; |
1469 | 1478 |
1470 | 1479 |
1471 // The body of a Dart function marked as 'native' consists of this node. | 1480 // The body of a Dart function marked as 'native' consists of this node. |
1472 class NativeBodyNode : public AstNode { | 1481 class NativeBodyNode : public AstNode { |
1473 public: | 1482 public: |
1474 NativeBodyNode(intptr_t token_index, | 1483 NativeBodyNode(intptr_t token_index, |
1475 const String& native_c_function_name, | 1484 const String& native_c_function_name, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 const LocalVariable& context_var_; | 1661 const LocalVariable& context_var_; |
1653 | 1662 |
1654 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1663 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
1655 }; | 1664 }; |
1656 | 1665 |
1657 } // namespace dart | 1666 } // namespace dart |
1658 | 1667 |
1659 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1668 #undef DECLARE_COMMON_NODE_FUNCTIONS |
1660 | 1669 |
1661 #endif // VM_AST_H_ | 1670 #endif // VM_AST_H_ |
OLD | NEW |