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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 8777 matching lines...) Expand 10 before | Expand all | Expand 10 after
8788 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); 8788 OS::SNPrint(chars, len, kFormat, prefix.ToCString());
8789 return chars; 8789 return chars;
8790 } 8790 }
8791 8791
8792 8792
8793 void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const { 8793 void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const {
8794 JSONObject jsobj(stream); 8794 JSONObject jsobj(stream);
8795 } 8795 }
8796 8796
8797 8797
8798 void Namespace::set_metadata_field(const Field& value) const {
8799 StorePointer(&raw_ptr()->metadata_field_, value.raw());
8800 }
8801
8802
8803 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) {
8804 ASSERT(Field::Handle(metadata_field()).IsNull());
8805 Field& field = Field::Handle(Field::New(Symbols::TopLevel(),
8806 true, // is_static
8807 false, // is_final
8808 false, // is_const
8809 owner_class,
8810 token_pos));
8811 field.set_type(Type::Handle(Type::DynamicType()));
8812 field.set_value(Array::empty_array());
8813 set_metadata_field(field);
8814 }
8815
8816
8817 RawObject* Namespace::GetMetadata() const {
8818 Field& field = Field::Handle(metadata_field());
8819 if (field.IsNull()) {
8820 // There is no metadata for this object.
8821 return Object::empty_array().raw();
8822 }
8823 Object& metadata = Object::Handle();
8824 metadata = field.value();
8825 if (field.value() == Object::empty_array().raw()) {
8826 metadata = Parser::ParseMetadata(Class::Handle(field.owner()),
8827 field.token_pos());
8828 if (metadata.IsArray()) {
8829 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw());
8830 field.set_value(Array::Cast(metadata));
8831 }
8832 }
8833 return metadata.raw();
8834 }
8835
8836
8798 const char* Namespace::ToCString() const { 8837 const char* Namespace::ToCString() const {
8799 const char* kFormat = "Namespace for library '%s'"; 8838 const char* kFormat = "Namespace for library '%s'";
8800 const Library& lib = Library::Handle(library()); 8839 const Library& lib = Library::Handle(library());
8801 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; 8840 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1;
8802 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 8841 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8803 OS::SNPrint(chars, len, kFormat, lib.ToCString()); 8842 OS::SNPrint(chars, len, kFormat, lib.ToCString());
8804 return chars; 8843 return chars;
8805 } 8844 }
8806 8845
8807 8846
(...skipping 8417 matching lines...) Expand 10 before | Expand all | Expand 10 after
17225 return "_MirrorReference"; 17264 return "_MirrorReference";
17226 } 17265 }
17227 17266
17228 17267
17229 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17268 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17230 Instance::PrintToJSONStream(stream, ref); 17269 Instance::PrintToJSONStream(stream, ref);
17231 } 17270 }
17232 17271
17233 17272
17234 } // namespace dart 17273 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | sdk/lib/mirrors/mirrors.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698