OLD | NEW |
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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 | 922 |
923 cls = Class::New<Double>(); | 923 cls = Class::New<Double>(); |
924 object_store->set_double_class(cls); | 924 object_store->set_double_class(cls); |
925 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); | 925 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); |
926 pending_classes.Add(cls, Heap::kOld); | 926 pending_classes.Add(cls, Heap::kOld); |
927 | 927 |
928 cls = Class::New<WeakProperty>(); | 928 cls = Class::New<WeakProperty>(); |
929 object_store->set_weak_property_class(cls); | 929 object_store->set_weak_property_class(cls); |
930 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); | 930 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); |
931 | 931 |
| 932 // Pre-register the mirrors library so we can place the vm class |
| 933 // MirrorReference there rather than the core library. |
| 934 lib = Library::LookupLibrary(Symbols::DartMirrors()); |
| 935 if (lib.IsNull()) { |
| 936 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true); |
| 937 lib.Register(); |
| 938 isolate->object_store()->set_bootstrap_library(ObjectStore::kMirrors, |
| 939 lib); |
| 940 } |
| 941 ASSERT(!lib.IsNull()); |
| 942 ASSERT(lib.raw() == Library::MirrorsLibrary()); |
| 943 |
| 944 cls = Class::New<MirrorReference>(); |
| 945 object_store->set_mirror_reference_class(cls); |
| 946 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib); |
| 947 |
932 // Setup some default native field classes which can be extended for | 948 // Setup some default native field classes which can be extended for |
933 // specifying native fields in dart classes. | 949 // specifying native fields in dart classes. |
934 Library::InitNativeWrappersLibrary(isolate); | 950 Library::InitNativeWrappersLibrary(isolate); |
935 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | 951 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); |
936 | 952 |
937 // Pre-register the typed_data library so the native class implementations | 953 // Pre-register the typed_data library so the native class implementations |
938 // can be hooked up before compiling it. | 954 // can be hooked up before compiling it. |
939 lib = Library::LookupLibrary(Symbols::DartTypedData()); | 955 lib = Library::LookupLibrary(Symbols::DartTypedData()); |
940 if (lib.IsNull()) { | 956 if (lib.IsNull()) { |
941 lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true); | 957 lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 object_store->set_jsregexp_class(cls); | 1208 object_store->set_jsregexp_class(cls); |
1193 | 1209 |
1194 // Some classes are not stored in the object store. Yet we still need to | 1210 // Some classes are not stored in the object store. Yet we still need to |
1195 // create their Class object so that they get put into the class_table | 1211 // create their Class object so that they get put into the class_table |
1196 // (as a side effect of Class::New()). | 1212 // (as a side effect of Class::New()). |
1197 cls = Class::New<DartFunction>(); | 1213 cls = Class::New<DartFunction>(); |
1198 cls = Class::New<Number>(); | 1214 cls = Class::New<Number>(); |
1199 | 1215 |
1200 cls = Class::New<WeakProperty>(); | 1216 cls = Class::New<WeakProperty>(); |
1201 object_store->set_weak_property_class(cls); | 1217 object_store->set_weak_property_class(cls); |
| 1218 |
| 1219 cls = Class::New<MirrorReference>(); |
| 1220 object_store->set_mirror_reference_class(cls); |
1202 } | 1221 } |
1203 | 1222 |
1204 | 1223 |
1205 void Object::Print() const { | 1224 void Object::Print() const { |
1206 OS::Print("%s\n", ToCString()); | 1225 OS::Print("%s\n", ToCString()); |
1207 } | 1226 } |
1208 | 1227 |
1209 | 1228 |
1210 RawString* Object::DictionaryName() const { | 1229 RawString* Object::DictionaryName() const { |
1211 return String::null(); | 1230 return String::null(); |
(...skipping 12452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13664 WeakProperty::InstanceSize(), | 13683 WeakProperty::InstanceSize(), |
13665 space); | 13684 space); |
13666 return reinterpret_cast<RawWeakProperty*>(raw); | 13685 return reinterpret_cast<RawWeakProperty*>(raw); |
13667 } | 13686 } |
13668 | 13687 |
13669 | 13688 |
13670 const char* WeakProperty::ToCString() const { | 13689 const char* WeakProperty::ToCString() const { |
13671 return "_WeakProperty"; | 13690 return "_WeakProperty"; |
13672 } | 13691 } |
13673 | 13692 |
| 13693 |
| 13694 RawMirrorReference* MirrorReference::New(Heap::Space space) { |
| 13695 ASSERT(Isolate::Current()->object_store()->mirror_reference_class() |
| 13696 != Class::null()); |
| 13697 RawObject* raw = Object::Allocate(MirrorReference::kClassId, |
| 13698 MirrorReference::InstanceSize(), |
| 13699 space); |
| 13700 return reinterpret_cast<RawMirrorReference*>(raw); |
| 13701 } |
| 13702 |
| 13703 |
| 13704 const char* MirrorReference::ToCString() const { |
| 13705 return "_MirrorReference"; |
| 13706 } |
| 13707 |
| 13708 |
13674 } // namespace dart | 13709 } // namespace dart |
OLD | NEW |