OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 #include "vm/kernel.h" | 5 #include "vm/kernel.h" |
6 | 6 |
7 #if !defined(DART_PRECOMPILED_RUNTIME) | 7 #if !defined(DART_PRECOMPILED_RUNTIME) |
8 namespace dart { | 8 namespace dart { |
9 | 9 |
10 namespace kernel { | 10 namespace kernel { |
11 | 11 |
12 | 12 |
13 template <typename T> | 13 template <typename T> |
14 void VisitList(List<T>* list, Visitor* visitor) { | 14 void VisitList(List<T>* list, Visitor* visitor) { |
15 for (int i = 0; i < list->length(); ++i) { | 15 for (int i = 0; i < list->length(); ++i) { |
16 (*list)[i]->AcceptVisitor(visitor); | 16 (*list)[i]->AcceptVisitor(visitor); |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 | 20 |
| 21 CanonicalName::CanonicalName() : is_referenced_(false) {} |
| 22 |
| 23 |
| 24 CanonicalName::~CanonicalName() { |
| 25 for (intptr_t i = 0; i < children_.length(); ++i) { |
| 26 delete children_[i]; |
| 27 } |
| 28 } |
| 29 |
| 30 |
| 31 CanonicalName* CanonicalName::NewRoot() { |
| 32 return new CanonicalName(); |
| 33 } |
| 34 |
| 35 |
| 36 void CanonicalName::BindTo(LinkedNode* new_target) { |
| 37 ASSERT(new_target != NULL); |
| 38 if (definition_ == new_target) return; |
| 39 ASSERT(definition_ == NULL); |
| 40 ASSERT(new_target->canonical_name_ == NULL); |
| 41 definition_ = new_target; |
| 42 new_target->canonical_name_ = this; |
| 43 } |
| 44 |
| 45 |
| 46 void CanonicalName::Unbind() { |
| 47 if (definition_ == NULL) return; |
| 48 ASSERT(definition_->canonical_name_ == this); |
| 49 definition_->canonical_name_ = NULL; |
| 50 definition_ = NULL; |
| 51 } |
| 52 |
| 53 |
| 54 CanonicalName* CanonicalName::AddChild(String* name) { |
| 55 CanonicalName* child = new CanonicalName(); |
| 56 child->parent_ = this; |
| 57 child->name_ = name; |
| 58 children_.Add(child); |
| 59 return child; |
| 60 } |
| 61 |
| 62 |
| 63 Library* CanonicalName::AsLibrary() { |
| 64 return Library::Cast(definition()); |
| 65 } |
| 66 |
| 67 |
| 68 Class* CanonicalName::AsClass() { |
| 69 return Class::Cast(definition()); |
| 70 } |
| 71 |
| 72 |
| 73 Member* CanonicalName::AsMember() { |
| 74 return Member::Cast(definition()); |
| 75 } |
| 76 |
| 77 |
| 78 Field* CanonicalName::AsField() { |
| 79 return Field::Cast(definition()); |
| 80 } |
| 81 |
| 82 |
| 83 Constructor* CanonicalName::AsConstructor() { |
| 84 return Constructor::Cast(definition()); |
| 85 } |
| 86 |
| 87 |
| 88 Procedure* CanonicalName::AsProcedure() { |
| 89 return Procedure::Cast(definition()); |
| 90 } |
| 91 |
| 92 |
21 Node::~Node() {} | 93 Node::~Node() {} |
22 | 94 |
23 | 95 |
24 TreeNode::~TreeNode() {} | 96 TreeNode::~TreeNode() {} |
25 | 97 |
26 | 98 |
27 void TreeNode::AcceptVisitor(Visitor* visitor) { | 99 void TreeNode::AcceptVisitor(Visitor* visitor) { |
28 AcceptTreeVisitor(visitor); | 100 AcceptTreeVisitor(visitor); |
29 } | 101 } |
30 | 102 |
31 | 103 |
| 104 LinkedNode::~LinkedNode() {} |
| 105 |
| 106 |
32 Library::~Library() {} | 107 Library::~Library() {} |
33 | 108 |
34 | 109 |
35 void Library::AcceptTreeVisitor(TreeVisitor* visitor) { | 110 void Library::AcceptTreeVisitor(TreeVisitor* visitor) { |
36 visitor->VisitLibrary(this); | 111 visitor->VisitLibrary(this); |
37 } | 112 } |
38 | 113 |
39 | 114 |
40 void Library::VisitChildren(Visitor* visitor) { | 115 void Library::VisitChildren(Visitor* visitor) { |
41 VisitList(&classes(), visitor); | 116 VisitList(&classes(), visitor); |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 void Program::VisitChildren(Visitor* visitor) { | 1270 void Program::VisitChildren(Visitor* visitor) { |
1196 VisitList(&libraries(), visitor); | 1271 VisitList(&libraries(), visitor); |
1197 visitor->VisitProcedureReference(main_method()); | 1272 visitor->VisitProcedureReference(main_method()); |
1198 } | 1273 } |
1199 | 1274 |
1200 | 1275 |
1201 } // namespace kernel | 1276 } // namespace kernel |
1202 | 1277 |
1203 } // namespace dart | 1278 } // namespace dart |
1204 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1279 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |