Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: runtime/vm/kernel.cc

Issue 2665723002: Implement canonical name scheme in kernel. (Closed)
Patch Set: Address Kevin's comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/kernel.h ('k') | runtime/vm/kernel_binary.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel.cc
diff --git a/runtime/vm/kernel.cc b/runtime/vm/kernel.cc
index 80ffe1d935ce537f24d1ebe2be3ed41ee6de6b2a..39d581a001e725e8b6137ed60b8e9295fb05fa99 100644
--- a/runtime/vm/kernel.cc
+++ b/runtime/vm/kernel.cc
@@ -18,6 +18,78 @@ void VisitList(List<T>* list, Visitor* visitor) {
}
+CanonicalName::CanonicalName() : is_referenced_(false) {}
+
+
+CanonicalName::~CanonicalName() {
+ for (intptr_t i = 0; i < children_.length(); ++i) {
+ delete children_[i];
+ }
+}
+
+
+CanonicalName* CanonicalName::NewRoot() {
+ return new CanonicalName();
+}
+
+
+void CanonicalName::BindTo(LinkedNode* new_target) {
+ ASSERT(new_target != NULL);
+ if (definition_ == new_target) return;
+ ASSERT(definition_ == NULL);
+ ASSERT(new_target->canonical_name_ == NULL);
+ definition_ = new_target;
+ new_target->canonical_name_ = this;
+}
+
+
+void CanonicalName::Unbind() {
+ if (definition_ == NULL) return;
+ ASSERT(definition_->canonical_name_ == this);
+ definition_->canonical_name_ = NULL;
+ definition_ = NULL;
+}
+
+
+CanonicalName* CanonicalName::AddChild(String* name) {
+ CanonicalName* child = new CanonicalName();
+ child->parent_ = this;
+ child->name_ = name;
+ children_.Add(child);
+ return child;
+}
+
+
+Library* CanonicalName::AsLibrary() {
+ return Library::Cast(definition());
+}
+
+
+Class* CanonicalName::AsClass() {
+ return Class::Cast(definition());
+}
+
+
+Member* CanonicalName::AsMember() {
+ return Member::Cast(definition());
+}
+
+
+Field* CanonicalName::AsField() {
+ return Field::Cast(definition());
+}
+
+
+Constructor* CanonicalName::AsConstructor() {
+ return Constructor::Cast(definition());
+}
+
+
+Procedure* CanonicalName::AsProcedure() {
+ return Procedure::Cast(definition());
+}
+
+
Node::~Node() {}
@@ -29,6 +101,9 @@ void TreeNode::AcceptVisitor(Visitor* visitor) {
}
+LinkedNode::~LinkedNode() {}
+
+
Library::~Library() {}
« no previous file with comments | « runtime/vm/kernel.h ('k') | runtime/vm/kernel_binary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698