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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 const String& public_class_name, | 624 const String& public_class_name, |
625 const Library& lib) { | 625 const Library& lib) { |
626 ASSERT(public_class_name.Length() > 0); | 626 ASSERT(public_class_name.Length() > 0); |
627 ASSERT(public_class_name.CharAt(0) == '_'); | 627 ASSERT(public_class_name.CharAt(0) == '_'); |
628 String& str = String::Handle(); | 628 String& str = String::Handle(); |
629 str = lib.PrivateName(public_class_name); | 629 str = lib.PrivateName(public_class_name); |
630 cls.set_name(str); | 630 cls.set_name(str); |
631 lib.AddClass(cls); | 631 lib.AddClass(cls); |
632 } | 632 } |
633 | 633 |
634 #define INIT_LIBRARY(name, raw_script, raw_lib) \ | 634 |
635 script ^= raw_script; \ | 635 #define LOAD_LIBRARY(name, raw_name) \ |
636 Library::Init##name##Library(isolate); \ | 636 url = Symbols::Dart##name().raw(); \ |
637 lib ^= raw_lib; \ | 637 lib = Library::LookupLibrary(url); \ |
638 ASSERT(!lib.IsNull()); \ | 638 if (lib.IsNull()) { \ |
639 lib = Library::NewLibraryHelper(url, true); \ | |
siva
2013/02/25 23:12:25
ASSERT(!lib.IsNull());
Ivan Posva
2013/02/25 23:23:59
We do not check for allocation success anywhere el
| |
640 lib.Register(); \ | |
641 } \ | |
642 isolate->object_store()->set_##raw_name##_library(lib); \ | |
643 | |
644 #define INIT_LIBRARY(name, raw_name, has_patch) \ | |
645 LOAD_LIBRARY(name, raw_name) \ | |
646 script = Bootstrap::Load##name##Script(false); \ | |
639 error = Bootstrap::Compile(lib, script); \ | 647 error = Bootstrap::Compile(lib, script); \ |
640 if (!error.IsNull()) { \ | 648 if (!error.IsNull()) { \ |
641 return error.raw(); \ | 649 return error.raw(); \ |
642 } \ | 650 } \ |
651 if (has_patch) { \ | |
652 script = Bootstrap::Load##name##Script(true); \ | |
653 error = lib.Patch(script); \ | |
654 if (!error.IsNull()) { \ | |
655 return error.raw(); \ | |
656 } \ | |
657 } \ | |
643 | 658 |
644 | 659 |
645 RawError* Object::Init(Isolate* isolate) { | 660 RawError* Object::Init(Isolate* isolate) { |
646 TIMERSCOPE(time_bootstrap); | 661 TIMERSCOPE(time_bootstrap); |
647 ObjectStore* object_store = isolate->object_store(); | 662 ObjectStore* object_store = isolate->object_store(); |
648 | 663 |
649 Class& cls = Class::Handle(); | 664 Class& cls = Class::Handle(); |
650 Type& type = Type::Handle(); | 665 Type& type = Type::Handle(); |
651 Array& array = Array::Handle(); | 666 Array& array = Array::Handle(); |
667 String& url = String::Handle(); | |
668 Library& lib = Library::Handle(); | |
669 Script& script = Script::Handle(); | |
670 Error& error = Error::Handle(); | |
652 | 671 |
653 // All RawArray fields will be initialized to an empty array, therefore | 672 // All RawArray fields will be initialized to an empty array, therefore |
654 // initialize array class first. | 673 // initialize array class first. |
655 cls = Class::New<Array>(); | 674 cls = Class::New<Array>(); |
656 object_store->set_array_class(cls); | 675 object_store->set_array_class(cls); |
657 | 676 |
658 // Array and ImmutableArray are the only VM classes that are parameterized. | 677 // Array and ImmutableArray are the only VM classes that are parameterized. |
659 // Since they are pre-finalized, CalculateFieldOffsets() is not called, so we | 678 // Since they are pre-finalized, CalculateFieldOffsets() is not called, so we |
660 // need to set the offset of their type_arguments_ field, which is explicitly | 679 // need to set the offset of their type_arguments_ field, which is explicitly |
661 // declared in RawArray. | 680 // declared in RawArray. |
(...skipping 29 matching lines...) Expand all Loading... | |
691 object_store->set_two_byte_string_class(cls); | 710 object_store->set_two_byte_string_class(cls); |
692 | 711 |
693 // Setup the symbol table for the symbols created in the isolate. | 712 // Setup the symbol table for the symbols created in the isolate. |
694 Symbols::SetupSymbolTable(isolate); | 713 Symbols::SetupSymbolTable(isolate); |
695 | 714 |
696 // Set up the libraries array before initializing the core library. | 715 // Set up the libraries array before initializing the core library. |
697 const GrowableObjectArray& libraries = | 716 const GrowableObjectArray& libraries = |
698 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); | 717 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
699 object_store->set_libraries(libraries); | 718 object_store->set_libraries(libraries); |
700 | 719 |
720 // Pre-register the core library. | |
721 Library::InitCoreLibrary(isolate); | |
722 | |
701 // Basic infrastructure has been setup, initialize the class dictionary. | 723 // Basic infrastructure has been setup, initialize the class dictionary. |
702 Library::InitCoreLibrary(isolate); | |
703 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 724 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
704 ASSERT(!core_lib.IsNull()); | 725 ASSERT(!core_lib.IsNull()); |
705 | 726 |
706 const GrowableObjectArray& pending_classes = | 727 const GrowableObjectArray& pending_classes = |
707 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); | 728 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
708 object_store->set_pending_classes(pending_classes); | 729 object_store->set_pending_classes(pending_classes); |
709 | 730 |
710 Context& context = Context::Handle(Context::New(0, Heap::kOld)); | 731 Context& context = Context::Handle(Context::New(0, Heap::kOld)); |
711 object_store->set_empty_context(context); | 732 object_store->set_empty_context(context); |
712 | 733 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 RegisterClass(cls, Symbols::Stacktrace(), core_lib); | 785 RegisterClass(cls, Symbols::Stacktrace(), core_lib); |
765 pending_classes.Add(cls, Heap::kOld); | 786 pending_classes.Add(cls, Heap::kOld); |
766 // Super type set below, after Object is allocated. | 787 // Super type set below, after Object is allocated. |
767 | 788 |
768 cls = Class::New<JSRegExp>(); | 789 cls = Class::New<JSRegExp>(); |
769 object_store->set_jsregexp_class(cls); | 790 object_store->set_jsregexp_class(cls); |
770 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib); | 791 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib); |
771 pending_classes.Add(cls, Heap::kOld); | 792 pending_classes.Add(cls, Heap::kOld); |
772 | 793 |
773 // Initialize the base interfaces used by the core VM classes. | 794 // Initialize the base interfaces used by the core VM classes. |
774 Script& script = Script::Handle(Bootstrap::LoadCoreScript(false)); | 795 script = Bootstrap::LoadCoreScript(false); |
775 | 796 |
776 // Allocate and initialize the pre-allocated classes in the core library. | 797 // Allocate and initialize the pre-allocated classes in the core library. |
777 cls = Class::New<Instance>(kInstanceCid); | 798 cls = Class::New<Instance>(kInstanceCid); |
778 object_store->set_object_class(cls); | 799 object_store->set_object_class(cls); |
779 cls.set_name(Symbols::Object()); | 800 cls.set_name(Symbols::Object()); |
780 cls.set_script(script); | 801 cls.set_script(script); |
781 cls.set_is_prefinalized(); | 802 cls.set_is_prefinalized(); |
782 core_lib.AddClass(cls); | 803 core_lib.AddClass(cls); |
783 pending_classes.Add(cls, Heap::kOld); | 804 pending_classes.Add(cls, Heap::kOld); |
784 type = Type::NewNonParameterizedType(cls); | 805 type = Type::NewNonParameterizedType(cls); |
(...skipping 29 matching lines...) Expand all Loading... | |
814 | 835 |
815 cls = Class::New<Double>(); | 836 cls = Class::New<Double>(); |
816 object_store->set_double_class(cls); | 837 object_store->set_double_class(cls); |
817 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); | 838 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); |
818 pending_classes.Add(cls, Heap::kOld); | 839 pending_classes.Add(cls, Heap::kOld); |
819 | 840 |
820 cls = Class::New<WeakProperty>(); | 841 cls = Class::New<WeakProperty>(); |
821 object_store->set_weak_property_class(cls); | 842 object_store->set_weak_property_class(cls); |
822 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); | 843 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); |
823 | 844 |
824 Library::InitScalarlistLibrary(isolate); | 845 // Setup some default native field classes which can be extended for |
846 // specifying native fields in dart classes. | |
847 Library::InitNativeWrappersLibrary(isolate); | |
848 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | |
849 | |
850 // Pre-register the scalarlist library so the native class implementations | |
851 // can be hooked up before compiling it. | |
852 LOAD_LIBRARY(Scalarlist, scalarlist); | |
853 | |
825 Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary()); | 854 Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary()); |
855 ASSERT(!scalarlist_lib.IsNull()); | |
826 | 856 |
827 cls = Class::New<Float32x4>(); | 857 cls = Class::New<Float32x4>(); |
828 object_store->set_float32x4_class(cls); | 858 object_store->set_float32x4_class(cls); |
829 RegisterPrivateClass(cls, Symbols::_Float32x4(), scalarlist_lib); | 859 RegisterPrivateClass(cls, Symbols::_Float32x4(), scalarlist_lib); |
830 | 860 |
831 cls = Class::New<Uint32x4>(); | 861 cls = Class::New<Uint32x4>(); |
832 object_store->set_uint32x4_class(cls); | 862 object_store->set_uint32x4_class(cls); |
833 RegisterPrivateClass(cls, Symbols::_Uint32x4(), scalarlist_lib); | 863 RegisterPrivateClass(cls, Symbols::_Uint32x4(), scalarlist_lib); |
834 | 864 |
835 cls = Class::New<Int8Array>(); | 865 cls = Class::New<Int8Array>(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1003 object_store->set_void_type(type); | 1033 object_store->set_void_type(type); |
1004 | 1034 |
1005 // The class 'dynamic' is registered in the class dictionary because its name | 1035 // The class 'dynamic' is registered in the class dictionary because its name |
1006 // is a built-in identifier, rather than a reserved keyword. Its name is not | 1036 // is a built-in identifier, rather than a reserved keyword. Its name is not |
1007 // heap allocated, because the class resides in the VM isolate. | 1037 // heap allocated, because the class resides in the VM isolate. |
1008 // The corresponding type, the "unknown type", is stored in the object store. | 1038 // The corresponding type, the "unknown type", is stored in the object store. |
1009 cls = dynamic_class(); | 1039 cls = dynamic_class(); |
1010 type = Type::NewNonParameterizedType(cls); | 1040 type = Type::NewNonParameterizedType(cls); |
1011 object_store->set_dynamic_type(type); | 1041 object_store->set_dynamic_type(type); |
1012 | 1042 |
1013 // Setup some default native field classes which can be extended for | |
1014 // specifying native fields in dart classes. | |
1015 Library::InitNativeWrappersLibrary(isolate); | |
1016 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | |
1017 | |
1018 // Finish the initialization by compiling the bootstrap scripts containing the | 1043 // Finish the initialization by compiling the bootstrap scripts containing the |
1019 // base interfaces and the implementation of the internal classes. | 1044 // base interfaces and the implementation of the internal classes. |
1020 Error& error = Error::Handle(); | 1045 INIT_LIBRARY(Core, core, true); |
1021 error = Bootstrap::Compile(core_lib, script); | 1046 |
1022 if (!error.IsNull()) { | 1047 INIT_LIBRARY(Async, async, true); |
1023 return error.raw(); | 1048 INIT_LIBRARY(Collection, collection, false); |
1024 } | 1049 INIT_LIBRARY(CollectionDev, collection_dev, false); |
1025 Script& patch_script = Script::Handle(Bootstrap::LoadCoreScript(true)); | 1050 INIT_LIBRARY(Crypto, crypto, false); |
1026 error = core_lib.Patch(patch_script); | 1051 INIT_LIBRARY(Isolate, isolate, true); |
1027 if (!error.IsNull()) { | 1052 INIT_LIBRARY(Json, json, false); |
1028 return error.raw(); | 1053 INIT_LIBRARY(Math, math, true); |
1029 } | 1054 INIT_LIBRARY(Mirrors, mirrors, true); |
1030 Library::InitASyncLibrary(isolate); | 1055 INIT_LIBRARY(Scalarlist, scalarlist, true); |
1031 const Script& async_script = | 1056 INIT_LIBRARY(Utf, utf, false); |
1032 Script::Handle(Bootstrap::LoadASyncScript(false)); | 1057 INIT_LIBRARY(Uri, uri, false); |
1033 const Library& async_lib = Library::Handle(Library::ASyncLibrary()); | 1058 |
1034 ASSERT(!async_lib.IsNull()); | |
1035 error = Bootstrap::Compile(async_lib, async_script); | |
1036 if (!error.IsNull()) { | |
1037 return error.raw(); | |
1038 } | |
1039 patch_script = Bootstrap::LoadASyncScript(true); | |
1040 error = async_lib.Patch(patch_script); | |
1041 if (!error.IsNull()) { | |
1042 return error.raw(); | |
1043 } | |
1044 const Script& collection_script = | |
1045 Script::Handle(Bootstrap::LoadCollectionScript(false)); | |
1046 const Library& collection_lib = | |
1047 Library::Handle(Library::CollectionLibrary()); | |
1048 ASSERT(!collection_lib.IsNull()); | |
1049 error = Bootstrap::Compile(collection_lib, collection_script); | |
1050 if (!error.IsNull()) { | |
1051 return error.raw(); | |
1052 } | |
1053 const Script& collection_dev_script = | |
1054 Script::Handle(Bootstrap::LoadCollectionDevScript(false)); | |
1055 const Library& collection_dev_lib = | |
1056 Library::Handle(Library::CollectionDevLibrary()); | |
1057 ASSERT(!collection_dev_lib.IsNull()); | |
1058 error = Bootstrap::Compile(collection_dev_lib, collection_dev_script); | |
1059 if (!error.IsNull()) { | |
1060 return error.raw(); | |
1061 } | |
1062 const Script& math_script = Script::Handle(Bootstrap::LoadMathScript(false)); | |
1063 const Library& math_lib = Library::Handle(Library::MathLibrary()); | |
1064 ASSERT(!math_lib.IsNull()); | |
1065 error = Bootstrap::Compile(math_lib, math_script); | |
1066 if (!error.IsNull()) { | |
1067 return error.raw(); | |
1068 } | |
1069 patch_script = Bootstrap::LoadMathScript(true); | |
1070 error = math_lib.Patch(patch_script); | |
1071 if (!error.IsNull()) { | |
1072 return error.raw(); | |
1073 } | |
1074 const Script& isolate_script = Script::Handle( | |
1075 Bootstrap::LoadIsolateScript(false)); | |
1076 Library::InitIsolateLibrary(isolate); | |
1077 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | |
1078 ASSERT(!isolate_lib.IsNull()); | |
1079 error = Bootstrap::Compile(isolate_lib, isolate_script); | |
1080 if (!error.IsNull()) { | |
1081 return error.raw(); | |
1082 } | |
1083 patch_script = Bootstrap::LoadIsolateScript(true); | |
1084 error = isolate_lib.Patch(patch_script); | |
1085 if (!error.IsNull()) { | |
1086 return error.raw(); | |
1087 } | |
1088 const Script& mirrors_script = Script::Handle( | |
1089 Bootstrap::LoadMirrorsScript(false)); | |
1090 Library::InitMirrorsLibrary(isolate); | |
1091 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); | |
1092 ASSERT(!mirrors_lib.IsNull()); | |
1093 error = Bootstrap::Compile(mirrors_lib, mirrors_script); | |
1094 if (!error.IsNull()) { | |
1095 return error.raw(); | |
1096 } | |
1097 patch_script = Bootstrap::LoadMirrorsScript(true); | |
1098 error = mirrors_lib.Patch(patch_script); | |
1099 if (!error.IsNull()) { | |
1100 return error.raw(); | |
1101 } | |
1102 const Script& scalarlist_script = Script::Handle( | |
1103 Bootstrap::LoadScalarlistScript(false)); | |
1104 ASSERT(!scalarlist_lib.IsNull()); | |
1105 error = Bootstrap::Compile(scalarlist_lib, scalarlist_script); | |
1106 if (!error.IsNull()) { | |
1107 return error.raw(); | |
1108 } | |
1109 patch_script = Bootstrap::LoadScalarlistScript(true); | |
1110 error = scalarlist_lib.Patch(patch_script); | |
1111 if (!error.IsNull()) { | |
1112 return error.raw(); | |
1113 } | |
1114 Library& lib = Library::Handle(); | |
1115 INIT_LIBRARY(Crypto, | |
1116 Bootstrap::LoadCryptoScript(false), | |
1117 Library::CryptoLibrary()); | |
1118 INIT_LIBRARY(Json, | |
1119 Bootstrap::LoadJsonScript(false), | |
1120 Library::JsonLibrary()); | |
1121 patch_script = Bootstrap::LoadJsonScript(true); | |
1122 error = lib.Patch(patch_script); | |
1123 if (!error.IsNull()) { | |
1124 return error.raw(); | |
1125 } | |
1126 INIT_LIBRARY(Utf, | |
1127 Bootstrap::LoadUtfScript(false), | |
1128 Library::UtfLibrary()); | |
1129 INIT_LIBRARY(Uri, | |
1130 Bootstrap::LoadUriScript(false), | |
1131 Library::UriLibrary()); | |
1132 Bootstrap::SetupNativeResolver(); | 1059 Bootstrap::SetupNativeResolver(); |
1133 | 1060 |
1134 // Remove the Object superclass cycle by setting the super type to null (not | 1061 // Remove the Object superclass cycle by setting the super type to null (not |
1135 // to the type of null). | 1062 // to the type of null). |
1136 cls = object_store->object_class(); | 1063 cls = object_store->object_class(); |
1137 cls.set_super_type(Type::Handle()); | 1064 cls.set_super_type(Type::Handle()); |
1138 | 1065 |
1139 ClassFinalizer::VerifyBootstrapClasses(); | 1066 ClassFinalizer::VerifyBootstrapClasses(); |
1140 MarkInvisibleFunctions(); | 1067 MarkInvisibleFunctions(); |
1141 | 1068 |
(...skipping 5232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6374 } | 6301 } |
6375 return result.raw(); | 6302 return result.raw(); |
6376 } | 6303 } |
6377 | 6304 |
6378 | 6305 |
6379 RawLibrary* Library::New(const String& url) { | 6306 RawLibrary* Library::New(const String& url) { |
6380 return NewLibraryHelper(url, false); | 6307 return NewLibraryHelper(url, false); |
6381 } | 6308 } |
6382 | 6309 |
6383 | 6310 |
6384 void Library::InitASyncLibrary(Isolate* isolate) { | |
6385 const String& url = Symbols::DartAsync(); | |
6386 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6387 lib.Register(); | |
6388 isolate->object_store()->set_async_library(lib); | |
6389 } | |
6390 | |
6391 | |
6392 void Library::InitCoreLibrary(Isolate* isolate) { | 6311 void Library::InitCoreLibrary(Isolate* isolate) { |
6393 const String& core_lib_url = Symbols::DartCore(); | 6312 const String& core_lib_url = Symbols::DartCore(); |
6394 const Library& core_lib = | 6313 const Library& core_lib = |
6395 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); | 6314 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); |
6396 core_lib.Register(); | 6315 core_lib.Register(); |
6397 isolate->object_store()->set_core_library(core_lib); | 6316 isolate->object_store()->set_core_library(core_lib); |
6398 Library::InitMathLibrary(isolate); | |
6399 const Library& math_lib = Library::Handle(Library::MathLibrary()); | |
6400 const Namespace& math_ns = Namespace::Handle( | |
6401 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | |
6402 Library::InitCollectionDevLibrary(isolate); | |
6403 const Library& collection_dev_lib = | |
6404 Library::Handle(Library::CollectionDevLibrary()); | |
6405 const Namespace& collection_dev_ns = Namespace::Handle( | |
6406 Namespace::New(collection_dev_lib, Array::Handle(), Array::Handle())); | |
6407 Library::InitCollectionLibrary(isolate); | |
6408 const Library& collection_lib = | |
6409 Library::Handle(Library::CollectionLibrary()); | |
6410 const Namespace& collection_ns = Namespace::Handle( | |
6411 Namespace::New(collection_lib, Array::Handle(), Array::Handle())); | |
6412 core_lib.AddImport(math_ns); | |
6413 core_lib.AddImport(collection_ns); | |
6414 core_lib.AddImport(collection_dev_ns); | |
6415 isolate->object_store()->set_root_library(Library::Handle()); | 6317 isolate->object_store()->set_root_library(Library::Handle()); |
6416 | 6318 |
6417 // Hook up predefined classes without setting their library pointers. These | 6319 // Hook up predefined classes without setting their library pointers. These |
6418 // classes are coming from the VM isolate, and are shared between multiple | 6320 // classes are coming from the VM isolate, and are shared between multiple |
6419 // isolates so setting their library pointers would be wrong. | 6321 // isolates so setting their library pointers would be wrong. |
6420 const Class& cls = Class::Handle(Object::dynamic_class()); | 6322 const Class& cls = Class::Handle(Object::dynamic_class()); |
6421 core_lib.AddObject(cls, String::Handle(cls.Name())); | 6323 core_lib.AddObject(cls, String::Handle(cls.Name())); |
6422 } | 6324 } |
6423 | 6325 |
6424 | 6326 |
6425 void Library::InitCollectionLibrary(Isolate* isolate) { | |
6426 const String& url = Symbols::DartCollection(); | |
6427 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6428 lib.Register(); | |
6429 const Library& math_lib = Library::Handle(Library::MathLibrary()); | |
6430 const Namespace& math_ns = Namespace::Handle( | |
6431 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | |
6432 const Library& collection_dev_lib = | |
6433 Library::Handle(Library::CollectionDevLibrary()); | |
6434 const Namespace& collection_dev_ns = Namespace::Handle( | |
6435 Namespace::New(collection_dev_lib, Array::Handle(), Array::Handle())); | |
6436 lib.AddImport(math_ns); | |
6437 lib.AddImport(collection_dev_ns); | |
6438 isolate->object_store()->set_collection_library(lib); | |
6439 } | |
6440 | |
6441 | |
6442 void Library::InitCollectionDevLibrary(Isolate* isolate) { | |
6443 const String& url = Symbols::DartCollectionDev(); | |
6444 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6445 lib.Register(); | |
6446 isolate->object_store()->set_collection_dev_library(lib); | |
6447 } | |
6448 | |
6449 | |
6450 void Library::InitCryptoLibrary(Isolate* isolate) { | |
6451 const String& url = Symbols::DartCrypto(); | |
6452 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6453 lib.Register(); | |
6454 const Library& math_lib = Library::Handle(Library::MathLibrary()); | |
6455 const Namespace& math_ns = Namespace::Handle( | |
6456 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | |
6457 lib.AddImport(math_ns); | |
6458 isolate->object_store()->set_crypto_library(lib); | |
6459 } | |
6460 | |
6461 | |
6462 void Library::InitIsolateLibrary(Isolate* isolate) { | |
6463 const String& url = Symbols::DartIsolate(); | |
6464 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6465 lib.Register(); | |
6466 const Library& async_lib = Library::Handle(Library::ASyncLibrary()); | |
6467 const Namespace& async_ns = Namespace::Handle( | |
6468 Namespace::New(async_lib, Array::Handle(), Array::Handle())); | |
6469 lib.AddImport(async_ns); | |
6470 isolate->object_store()->set_isolate_library(lib); | |
6471 } | |
6472 | |
6473 | |
6474 void Library::InitJsonLibrary(Isolate* isolate) { | |
6475 const String& url = Symbols::DartJson(); | |
6476 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6477 lib.Register(); | |
6478 isolate->object_store()->set_json_library(lib); | |
6479 } | |
6480 | |
6481 | |
6482 void Library::InitMathLibrary(Isolate* isolate) { | |
6483 const String& url = Symbols::DartMath(); | |
6484 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6485 lib.Register(); | |
6486 isolate->object_store()->set_math_library(lib); | |
6487 } | |
6488 | |
6489 | |
6490 void Library::InitMirrorsLibrary(Isolate* isolate) { | |
6491 const String& url = Symbols::DartMirrors(); | |
6492 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6493 lib.Register(); | |
6494 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | |
6495 const Namespace& isolate_ns = Namespace::Handle( | |
6496 Namespace::New(isolate_lib, Array::Handle(), Array::Handle())); | |
6497 lib.AddImport(isolate_ns); | |
6498 const Library& async_lib = Library::Handle(Library::ASyncLibrary()); | |
6499 const Namespace& async_ns = Namespace::Handle( | |
6500 Namespace::New(async_lib, Array::Handle(), Array::Handle())); | |
6501 lib.AddImport(async_ns); | |
6502 const Library& wrappers_lib = | |
6503 Library::Handle(Library::NativeWrappersLibrary()); | |
6504 const Namespace& wrappers_ns = Namespace::Handle( | |
6505 Namespace::New(wrappers_lib, Array::Handle(), Array::Handle())); | |
6506 lib.AddImport(wrappers_ns); | |
6507 isolate->object_store()->set_mirrors_library(lib); | |
6508 } | |
6509 | |
6510 | |
6511 void Library::InitNativeWrappersLibrary(Isolate* isolate) { | 6327 void Library::InitNativeWrappersLibrary(Isolate* isolate) { |
6512 static const int kNumNativeWrappersClasses = 4; | 6328 static const int kNumNativeWrappersClasses = 4; |
6513 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); | 6329 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); |
6514 const String& native_flds_lib_url = Symbols::DartNativeWrappers(); | 6330 const String& native_flds_lib_url = Symbols::DartNativeWrappers(); |
6515 const Library& native_flds_lib = Library::Handle( | 6331 const Library& native_flds_lib = Library::Handle( |
6516 Library::NewLibraryHelper(native_flds_lib_url, false)); | 6332 Library::NewLibraryHelper(native_flds_lib_url, false)); |
6517 native_flds_lib.Register(); | 6333 native_flds_lib.Register(); |
6518 isolate->object_store()->set_native_wrappers_library(native_flds_lib); | 6334 isolate->object_store()->set_native_wrappers_library(native_flds_lib); |
6519 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; | 6335 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; |
6520 static const int kNameLength = 25; | 6336 static const int kNameLength = 25; |
6521 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); | 6337 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); |
6522 char name_buffer[kNameLength]; | 6338 char name_buffer[kNameLength]; |
6523 String& cls_name = String::Handle(); | 6339 String& cls_name = String::Handle(); |
6524 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { | 6340 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { |
6525 OS::SNPrint(name_buffer, | 6341 OS::SNPrint(name_buffer, |
6526 kNameLength, | 6342 kNameLength, |
6527 "%s%d", | 6343 "%s%d", |
6528 kNativeWrappersClass, | 6344 kNativeWrappersClass, |
6529 fld_cnt); | 6345 fld_cnt); |
6530 cls_name = Symbols::New(name_buffer); | 6346 cls_name = Symbols::New(name_buffer); |
6531 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); | 6347 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); |
6532 } | 6348 } |
6533 } | 6349 } |
6534 | 6350 |
6535 | 6351 |
6536 void Library::InitScalarlistLibrary(Isolate* isolate) { | |
6537 const String& url = Symbols::DartScalarlist(); | |
6538 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6539 lib.Register(); | |
6540 const Library& collection_lib = | |
6541 Library::Handle(Library::CollectionLibrary()); | |
6542 const Namespace& collection_ns = Namespace::Handle( | |
6543 Namespace::New(collection_lib, Array::Handle(), Array::Handle())); | |
6544 lib.AddImport(collection_ns); | |
6545 isolate->object_store()->set_scalarlist_library(lib); | |
6546 } | |
6547 | |
6548 | |
6549 void Library::InitUriLibrary(Isolate* isolate) { | |
6550 const String& url = Symbols::DartUri(); | |
6551 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6552 lib.Register(); | |
6553 const Library& math_lib = Library::Handle(Library::MathLibrary()); | |
6554 const Namespace& math_ns = Namespace::Handle( | |
6555 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | |
6556 const Library& utf_lib = Library::Handle(Library::UtfLibrary()); | |
6557 const Namespace& utf_ns = Namespace::Handle( | |
6558 Namespace::New(utf_lib, Array::Handle(), Array::Handle())); | |
6559 lib.AddImport(math_ns); | |
6560 lib.AddImport(utf_ns); | |
6561 isolate->object_store()->set_uri_library(lib); | |
6562 } | |
6563 | |
6564 | |
6565 void Library::InitUtfLibrary(Isolate* isolate) { | |
6566 const String& url = Symbols::DartUtf(); | |
6567 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | |
6568 lib.Register(); | |
6569 const Library& async_lib = Library::Handle(Library::ASyncLibrary()); | |
6570 const Namespace& async_ns = Namespace::Handle( | |
6571 Namespace::New(async_lib, Array::Handle(), Array::Handle())); | |
6572 lib.AddImport(async_ns); | |
6573 isolate->object_store()->set_utf_library(lib); | |
6574 } | |
6575 | |
6576 | |
6577 RawLibrary* Library::LookupLibrary(const String &url) { | 6352 RawLibrary* Library::LookupLibrary(const String &url) { |
6578 Isolate* isolate = Isolate::Current(); | 6353 Isolate* isolate = Isolate::Current(); |
6579 Library& lib = Library::Handle(isolate, Library::null()); | 6354 Library& lib = Library::Handle(isolate, Library::null()); |
6580 String& lib_url = String::Handle(isolate, String::null()); | 6355 String& lib_url = String::Handle(isolate, String::null()); |
6581 GrowableObjectArray& libs = GrowableObjectArray::Handle( | 6356 GrowableObjectArray& libs = GrowableObjectArray::Handle( |
6582 isolate, isolate->object_store()->libraries()); | 6357 isolate, isolate->object_store()->libraries()); |
6583 for (int i = 0; i < libs.Length(); i++) { | 6358 for (int i = 0; i < libs.Length(); i++) { |
6584 lib ^= libs.At(i); | 6359 lib ^= libs.At(i); |
6585 lib_url ^= lib.url(); | 6360 lib_url ^= lib.url(); |
6586 if (lib_url.Equals(url)) { | 6361 if (lib_url.Equals(url)) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6660 ASSERT(Library::LookupLibrary(String::Handle(url())) == Library::null()); | 6435 ASSERT(Library::LookupLibrary(String::Handle(url())) == Library::null()); |
6661 ObjectStore* object_store = Isolate::Current()->object_store(); | 6436 ObjectStore* object_store = Isolate::Current()->object_store(); |
6662 GrowableObjectArray& libs = | 6437 GrowableObjectArray& libs = |
6663 GrowableObjectArray::Handle(object_store->libraries()); | 6438 GrowableObjectArray::Handle(object_store->libraries()); |
6664 ASSERT(!libs.IsNull()); | 6439 ASSERT(!libs.IsNull()); |
6665 set_index(libs.Length()); | 6440 set_index(libs.Length()); |
6666 libs.Add(*this); | 6441 libs.Add(*this); |
6667 } | 6442 } |
6668 | 6443 |
6669 | 6444 |
6670 RawLibrary* Library::ASyncLibrary() { | 6445 RawLibrary* Library::AsyncLibrary() { |
6671 return Isolate::Current()->object_store()->async_library(); | 6446 return Isolate::Current()->object_store()->async_library(); |
6672 } | 6447 } |
6673 | 6448 |
6674 | 6449 |
6675 RawLibrary* Library::CoreLibrary() { | 6450 RawLibrary* Library::CoreLibrary() { |
6676 return Isolate::Current()->object_store()->core_library(); | 6451 return Isolate::Current()->object_store()->core_library(); |
6677 } | 6452 } |
6678 | 6453 |
6679 | 6454 |
6680 RawLibrary* Library::CollectionLibrary() { | 6455 RawLibrary* Library::CollectionLibrary() { |
(...skipping 6617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13298 } | 13073 } |
13299 return result.raw(); | 13074 return result.raw(); |
13300 } | 13075 } |
13301 | 13076 |
13302 | 13077 |
13303 const char* WeakProperty::ToCString() const { | 13078 const char* WeakProperty::ToCString() const { |
13304 return "_WeakProperty"; | 13079 return "_WeakProperty"; |
13305 } | 13080 } |
13306 | 13081 |
13307 } // namespace dart | 13082 } // namespace dart |
OLD | NEW |