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::NewRoot() { |
| 25 return new CanonicalName(); |
| 26 } |
| 27 |
| 28 |
| 29 void CanonicalName::LinkTo(LinkedNode* new_target) { |
| 30 ASSERT(new_target != NULL); |
| 31 if (definition_ == new_target) return; |
| 32 ASSERT(definition_ == NULL); |
| 33 ASSERT(new_target->canonical_name_ == NULL); |
| 34 definition_ = new_target; |
| 35 new_target->canonical_name_ = this; |
| 36 } |
| 37 |
| 38 |
| 39 void CanonicalName::Unlink() { |
| 40 if (definition_ == NULL) return; |
| 41 ASSERT(definition_->canonical_name_ == this); |
| 42 definition_->canonical_name_ = NULL; |
| 43 definition_ = NULL; |
| 44 } |
| 45 |
| 46 |
| 47 CanonicalName* CanonicalName::AddChild(String* name) { |
| 48 CanonicalName* child = new CanonicalName(); |
| 49 child->parent_ = this; |
| 50 child->name_ = name; |
| 51 return child; |
| 52 } |
| 53 |
| 54 |
| 55 Library* CanonicalName::AsLibrary() { |
| 56 return Library::Cast(definition()); |
| 57 } |
| 58 |
| 59 |
| 60 Class* CanonicalName::AsClass() { |
| 61 return Class::Cast(definition()); |
| 62 } |
| 63 |
| 64 |
| 65 Member* CanonicalName::AsMember() { |
| 66 return Member::Cast(definition()); |
| 67 } |
| 68 |
| 69 |
| 70 Field* CanonicalName::AsField() { |
| 71 return Field::Cast(definition()); |
| 72 } |
| 73 |
| 74 |
| 75 Constructor* CanonicalName::AsConstructor() { |
| 76 return Constructor::Cast(definition()); |
| 77 } |
| 78 |
| 79 |
| 80 Procedure* CanonicalName::AsProcedure() { |
| 81 return Procedure::Cast(definition()); |
| 82 } |
| 83 |
| 84 |
21 Node::~Node() {} | 85 Node::~Node() {} |
22 | 86 |
23 | 87 |
24 TreeNode::~TreeNode() {} | 88 TreeNode::~TreeNode() {} |
25 | 89 |
26 | 90 |
27 void TreeNode::AcceptVisitor(Visitor* visitor) { | 91 void TreeNode::AcceptVisitor(Visitor* visitor) { |
28 AcceptTreeVisitor(visitor); | 92 AcceptTreeVisitor(visitor); |
29 } | 93 } |
30 | 94 |
31 | 95 |
| 96 LinkedNode::~LinkedNode() {} |
| 97 |
| 98 |
32 Library::~Library() {} | 99 Library::~Library() {} |
33 | 100 |
34 | 101 |
35 void Library::AcceptTreeVisitor(TreeVisitor* visitor) { | 102 void Library::AcceptTreeVisitor(TreeVisitor* visitor) { |
36 visitor->VisitLibrary(this); | 103 visitor->VisitLibrary(this); |
37 } | 104 } |
38 | 105 |
39 | 106 |
40 void Library::VisitChildren(Visitor* visitor) { | 107 void Library::VisitChildren(Visitor* visitor) { |
41 VisitList(&classes(), visitor); | 108 VisitList(&classes(), visitor); |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 void Program::VisitChildren(Visitor* visitor) { | 1255 void Program::VisitChildren(Visitor* visitor) { |
1189 VisitList(&libraries(), visitor); | 1256 VisitList(&libraries(), visitor); |
1190 visitor->VisitProcedureReference(main_method()); | 1257 visitor->VisitProcedureReference(main_method()); |
1191 } | 1258 } |
1192 | 1259 |
1193 | 1260 |
1194 } // namespace kernel | 1261 } // namespace kernel |
1195 | 1262 |
1196 } // namespace dart | 1263 } // namespace dart |
1197 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1264 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |