Index: runtime/vm/kernel_binary.cc |
diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc |
index 44980724fba3ac957b4b70827f9e7852f2ab0e22..a1cad8377e2c09b8d4a288acc9e78b0380914b6b 100644 |
--- a/runtime/vm/kernel_binary.cc |
+++ b/runtime/vm/kernel_binary.cc |
@@ -494,6 +494,13 @@ class Reader { |
return name; |
} |
+ CanonicalName* ReadDefiningCanonicalNameReference(LinkedNode* node_to_link) { |
+ CanonicalName* name = ReadCanonicalNameReference(); |
+ ASSERT(name != NULL); |
+ name->BindTo(node_to_link); |
+ return name; |
+ } |
+ |
intptr_t offset() { return offset_; } |
private: |
@@ -680,9 +687,11 @@ Library* Library::ReadFrom(Reader* reader) { |
int flags = reader->ReadFlags(); |
ASSERT(flags == 0); // external libraries not supported |
- canonical_name_ = reader->ReadCanonicalNameReference(); |
+ CanonicalName* canonical_name = |
+ reader->ReadDefiningCanonicalNameReference(this); |
+ |
name_ = Reference::ReadStringFrom(reader); |
- import_uri_ = canonical_name_->name(); |
+ import_uri_ = canonical_name->name(); |
source_uri_index_ = reader->ReadUInt(); |
reader->set_current_script_id(source_uri_index_); |
@@ -708,7 +717,7 @@ Library* Library::ReadFrom(Reader* reader) { |
Class* Class::ReadFrom(Reader* reader) { |
TRACE_READ_OFFSET(); |
- canonical_name_ = reader->ReadCanonicalNameReference(); |
+ reader->ReadDefiningCanonicalNameReference(this); |
position_ = reader->ReadPosition(false); |
is_abstract_ = reader->ReadBool(); |
name_ = Reference::ReadStringFrom(reader); |
@@ -800,7 +809,7 @@ Field* Field::ReadFrom(Reader* reader) { |
Tag tag = reader->ReadTag(); |
ASSERT(tag == kField); |
- canonical_name_ = reader->ReadCanonicalNameReference(); |
+ reader->ReadDefiningCanonicalNameReference(this); |
position_ = reader->ReadPosition(false); |
end_position_ = reader->ReadPosition(false); |
flags_ = reader->ReadFlags(); |
@@ -821,7 +830,7 @@ Constructor* Constructor::ReadFrom(Reader* reader) { |
Tag tag = reader->ReadTag(); |
ASSERT(tag == kConstructor); |
- canonical_name_ = reader->ReadCanonicalNameReference(); |
+ reader->ReadDefiningCanonicalNameReference(this); |
VariableScope<ReaderHelper> parameters(reader->helper()); |
position_ = reader->ReadPosition(); |
end_position_ = reader->ReadPosition(); |
@@ -839,7 +848,7 @@ Procedure* Procedure::ReadFrom(Reader* reader) { |
Tag tag = reader->ReadTag(); |
ASSERT(tag == kProcedure); |
- canonical_name_ = reader->ReadCanonicalNameReference(); |
+ reader->ReadDefiningCanonicalNameReference(this); |
VariableScope<ReaderHelper> parameters(reader->helper()); |
position_ = reader->ReadPosition(false); |
end_position_ = reader->ReadPosition(false); |
@@ -1881,6 +1890,15 @@ Program* Program::ReadFrom(Reader* reader) { |
program->main_method_reference_ = Reference::ReadMemberFrom(reader); |
+#ifdef DEBUG |
+ for (intptr_t i = 0; i < canonical_names; ++i) { |
+ CanonicalName* name = reader->helper()->GetCanonicalName(i); |
+ if (name->is_referenced() && name->definition() == NULL) { |
+ FATAL("Missing definition for canonical name"); |
+ } |
+ } |
+#endif |
+ |
return program; |
} |