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

Unified Diff: runtime/vm/object.cc

Issue 154733003: Access to imports in the VM's runtime mirrors. Extend test coverage of the source mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: sync Created 6 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/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 3ea8065e7c466591b6faab27acfb3577ab8845cf..422919bae22f74f218768d8351688e348189cf16 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -8953,6 +8953,45 @@ void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const {
}
+void Namespace::set_metadata_field(const Field& value) const {
+ StorePointer(&raw_ptr()->metadata_field_, value.raw());
+}
+
+
+void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) {
+ ASSERT(Field::Handle(metadata_field()).IsNull());
+ Field& field = Field::Handle(Field::New(Symbols::TopLevel(),
+ true, // is_static
+ false, // is_final
+ false, // is_const
+ owner_class,
+ token_pos));
+ field.set_type(Type::Handle(Type::DynamicType()));
+ field.set_value(Array::empty_array());
+ set_metadata_field(field);
+}
+
+
+RawObject* Namespace::GetMetadata() const {
+ Field& field = Field::Handle(metadata_field());
+ if (field.IsNull()) {
+ // There is no metadata for this object.
+ return Object::empty_array().raw();
+ }
+ Object& metadata = Object::Handle();
+ metadata = field.value();
+ if (field.value() == Object::empty_array().raw()) {
+ metadata = Parser::ParseMetadata(Class::Handle(field.owner()),
+ field.token_pos());
+ if (metadata.IsArray()) {
+ ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw());
+ field.set_value(Array::Cast(metadata));
+ }
+ }
+ return metadata.raw();
+}
+
+
const char* Namespace::ToCString() const {
const char* kFormat = "Namespace for library '%s'";
const Library& lib = Library::Handle(library());
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698