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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 #define INIT_LIBRARY(name, raw_script, raw_lib) \ | 634 #define INIT_LIBRARY(name, raw_script, raw_lib) \ |
635 script ^= raw_script; \ | 635 script ^= raw_script; \ |
636 Library::Init##name##Library(isolate); \ | 636 Library::Init##name##Library(isolate); \ |
637 lib ^= raw_lib; \ | 637 lib ^= raw_lib; \ |
638 ASSERT(!lib.IsNull()); \ | 638 ASSERT(!lib.IsNull()); \ |
639 error = Bootstrap::Compile(lib, script); \ | 639 error = Bootstrap::Compile(lib, script); \ |
640 if (!error.IsNull()) { \ | 640 if (!error.IsNull()) { \ |
641 return error.raw(); \ | 641 return error.raw(); \ |
642 } \ | 642 } \ |
643 | 643 |
644 #define PATCH_LIBRARY(lib, raw_patch_script) \ | |
645 patch_script ^= raw_patch_script; \ | |
646 error = lib.Patch(patch_script); \ | |
647 if (!error.IsNull()) { \ | |
648 return error.raw(); \ | |
649 } \ | |
siva
2013/02/22 18:25:39
Could you leave this the way it was without a macr
| |
644 | 650 |
645 RawError* Object::Init(Isolate* isolate) { | 651 RawError* Object::Init(Isolate* isolate) { |
646 TIMERSCOPE(time_bootstrap); | 652 TIMERSCOPE(time_bootstrap); |
647 ObjectStore* object_store = isolate->object_store(); | 653 ObjectStore* object_store = isolate->object_store(); |
648 | 654 |
649 Class& cls = Class::Handle(); | 655 Class& cls = Class::Handle(); |
650 Type& type = Type::Handle(); | 656 Type& type = Type::Handle(); |
651 Array& array = Array::Handle(); | 657 Array& array = Array::Handle(); |
652 | 658 |
653 // All RawArray fields will be initialized to an empty array, therefore | 659 // All RawArray fields will be initialized to an empty array, therefore |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 Library::InitNativeWrappersLibrary(isolate); | 1004 Library::InitNativeWrappersLibrary(isolate); |
999 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | 1005 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); |
1000 | 1006 |
1001 // Finish the initialization by compiling the bootstrap scripts containing the | 1007 // Finish the initialization by compiling the bootstrap scripts containing the |
1002 // base interfaces and the implementation of the internal classes. | 1008 // base interfaces and the implementation of the internal classes. |
1003 Error& error = Error::Handle(); | 1009 Error& error = Error::Handle(); |
1004 error = Bootstrap::Compile(core_lib, script); | 1010 error = Bootstrap::Compile(core_lib, script); |
1005 if (!error.IsNull()) { | 1011 if (!error.IsNull()) { |
1006 return error.raw(); | 1012 return error.raw(); |
1007 } | 1013 } |
1008 Script& patch_script = Script::Handle(Bootstrap::LoadCoreScript(true)); | 1014 Script& patch_script = Script::Handle(); |
1009 error = core_lib.Patch(patch_script); | 1015 PATCH_LIBRARY(core_lib, Bootstrap::LoadCoreScript(true)); |
1010 if (!error.IsNull()) { | 1016 |
1011 return error.raw(); | |
1012 } | |
1013 Library::InitASyncLibrary(isolate); | 1017 Library::InitASyncLibrary(isolate); |
1014 const Script& async_script = | 1018 const Script& async_script = |
1015 Script::Handle(Bootstrap::LoadASyncScript(false)); | 1019 Script::Handle(Bootstrap::LoadASyncScript(false)); |
1016 const Library& async_lib = Library::Handle(Library::ASyncLibrary()); | 1020 const Library& async_lib = Library::Handle(Library::ASyncLibrary()); |
1017 ASSERT(!async_lib.IsNull()); | 1021 ASSERT(!async_lib.IsNull()); |
1018 error = Bootstrap::Compile(async_lib, async_script); | 1022 error = Bootstrap::Compile(async_lib, async_script); |
1019 if (!error.IsNull()) { | 1023 if (!error.IsNull()) { |
1020 return error.raw(); | 1024 return error.raw(); |
1021 } | 1025 } |
1022 patch_script = Bootstrap::LoadASyncScript(true); | 1026 PATCH_LIBRARY(async_lib, Bootstrap::LoadASyncScript(true)); |
1023 error = async_lib.Patch(patch_script); | 1027 |
1024 if (!error.IsNull()) { | |
1025 return error.raw(); | |
1026 } | |
1027 const Script& collection_script = | 1028 const Script& collection_script = |
1028 Script::Handle(Bootstrap::LoadCollectionScript(false)); | 1029 Script::Handle(Bootstrap::LoadCollectionScript(false)); |
1029 const Library& collection_lib = | 1030 const Library& collection_lib = |
1030 Library::Handle(Library::CollectionLibrary()); | 1031 Library::Handle(Library::CollectionLibrary()); |
1031 ASSERT(!collection_lib.IsNull()); | 1032 ASSERT(!collection_lib.IsNull()); |
1032 error = Bootstrap::Compile(collection_lib, collection_script); | 1033 error = Bootstrap::Compile(collection_lib, collection_script); |
1033 if (!error.IsNull()) { | 1034 if (!error.IsNull()) { |
1034 return error.raw(); | 1035 return error.raw(); |
1035 } | 1036 } |
1036 const Script& collection_dev_script = | 1037 const Script& collection_dev_script = |
1037 Script::Handle(Bootstrap::LoadCollectionDevScript(false)); | 1038 Script::Handle(Bootstrap::LoadCollectionDevScript(false)); |
1038 const Library& collection_dev_lib = | 1039 const Library& collection_dev_lib = |
1039 Library::Handle(Library::CollectionDevLibrary()); | 1040 Library::Handle(Library::CollectionDevLibrary()); |
1040 ASSERT(!collection_dev_lib.IsNull()); | 1041 ASSERT(!collection_dev_lib.IsNull()); |
1041 error = Bootstrap::Compile(collection_dev_lib, collection_dev_script); | 1042 error = Bootstrap::Compile(collection_dev_lib, collection_dev_script); |
1042 if (!error.IsNull()) { | 1043 if (!error.IsNull()) { |
1043 return error.raw(); | 1044 return error.raw(); |
1044 } | 1045 } |
1045 const Script& math_script = Script::Handle(Bootstrap::LoadMathScript(false)); | 1046 const Script& math_script = Script::Handle(Bootstrap::LoadMathScript(false)); |
1046 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 1047 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
1047 ASSERT(!math_lib.IsNull()); | 1048 ASSERT(!math_lib.IsNull()); |
1048 error = Bootstrap::Compile(math_lib, math_script); | 1049 error = Bootstrap::Compile(math_lib, math_script); |
1049 if (!error.IsNull()) { | 1050 if (!error.IsNull()) { |
1050 return error.raw(); | 1051 return error.raw(); |
1051 } | 1052 } |
1052 patch_script = Bootstrap::LoadMathScript(true); | 1053 PATCH_LIBRARY(math_lib, Bootstrap::LoadMathScript(true)); |
1053 error = math_lib.Patch(patch_script); | 1054 |
1054 if (!error.IsNull()) { | |
1055 return error.raw(); | |
1056 } | |
1057 const Script& isolate_script = Script::Handle( | 1055 const Script& isolate_script = Script::Handle( |
1058 Bootstrap::LoadIsolateScript(false)); | 1056 Bootstrap::LoadIsolateScript(false)); |
1059 Library::InitIsolateLibrary(isolate); | 1057 Library::InitIsolateLibrary(isolate); |
1060 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 1058 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
1061 ASSERT(!isolate_lib.IsNull()); | 1059 ASSERT(!isolate_lib.IsNull()); |
1062 error = Bootstrap::Compile(isolate_lib, isolate_script); | 1060 error = Bootstrap::Compile(isolate_lib, isolate_script); |
1063 if (!error.IsNull()) { | 1061 if (!error.IsNull()) { |
1064 return error.raw(); | 1062 return error.raw(); |
1065 } | 1063 } |
1066 patch_script = Bootstrap::LoadIsolateScript(true); | 1064 PATCH_LIBRARY(isolate_lib, Bootstrap::LoadIsolateScript(true)); |
1067 error = isolate_lib.Patch(patch_script); | 1065 |
1068 if (!error.IsNull()) { | |
1069 return error.raw(); | |
1070 } | |
1071 const Script& mirrors_script = Script::Handle( | 1066 const Script& mirrors_script = Script::Handle( |
1072 Bootstrap::LoadMirrorsScript(false)); | 1067 Bootstrap::LoadMirrorsScript(false)); |
1073 Library::InitMirrorsLibrary(isolate); | 1068 Library::InitMirrorsLibrary(isolate); |
1074 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); | 1069 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); |
1075 ASSERT(!mirrors_lib.IsNull()); | 1070 ASSERT(!mirrors_lib.IsNull()); |
1076 error = Bootstrap::Compile(mirrors_lib, mirrors_script); | 1071 error = Bootstrap::Compile(mirrors_lib, mirrors_script); |
1077 if (!error.IsNull()) { | 1072 if (!error.IsNull()) { |
1078 return error.raw(); | 1073 return error.raw(); |
1079 } | 1074 } |
1080 patch_script = Bootstrap::LoadMirrorsScript(true); | 1075 PATCH_LIBRARY(mirrors_lib, Bootstrap::LoadMirrorsScript(true)); |
1081 error = mirrors_lib.Patch(patch_script); | 1076 |
1082 if (!error.IsNull()) { | |
1083 return error.raw(); | |
1084 } | |
1085 const Script& scalarlist_script = Script::Handle( | 1077 const Script& scalarlist_script = Script::Handle( |
1086 Bootstrap::LoadScalarlistScript(false)); | 1078 Bootstrap::LoadScalarlistScript(false)); |
1087 ASSERT(!scalarlist_lib.IsNull()); | 1079 ASSERT(!scalarlist_lib.IsNull()); |
1088 error = Bootstrap::Compile(scalarlist_lib, scalarlist_script); | 1080 error = Bootstrap::Compile(scalarlist_lib, scalarlist_script); |
1089 if (!error.IsNull()) { | 1081 if (!error.IsNull()) { |
1090 return error.raw(); | 1082 return error.raw(); |
1091 } | 1083 } |
1092 patch_script = Bootstrap::LoadScalarlistScript(true); | 1084 PATCH_LIBRARY(scalarlist_lib, Bootstrap::LoadScalarlistScript(true)); |
1093 error = scalarlist_lib.Patch(patch_script); | 1085 |
1094 if (!error.IsNull()) { | |
1095 return error.raw(); | |
1096 } | |
1097 Library& lib = Library::Handle(); | 1086 Library& lib = Library::Handle(); |
1098 INIT_LIBRARY(Crypto, | 1087 INIT_LIBRARY(Crypto, |
1099 Bootstrap::LoadCryptoScript(false), | 1088 Bootstrap::LoadCryptoScript(false), |
1100 Library::CryptoLibrary()); | 1089 Library::CryptoLibrary()); |
1101 INIT_LIBRARY(Json, | 1090 INIT_LIBRARY(Json, |
1102 Bootstrap::LoadJsonScript(false), | 1091 Bootstrap::LoadJsonScript(false), |
1103 Library::JsonLibrary()); | 1092 Library::JsonLibrary()); |
1093 PATCH_LIBRARY(lib, Bootstrap::LoadJsonScript(true)); | |
siva
2013/02/22 18:25:39
Just add the patch code inline here.
| |
1104 INIT_LIBRARY(Utf, | 1094 INIT_LIBRARY(Utf, |
1105 Bootstrap::LoadUtfScript(false), | 1095 Bootstrap::LoadUtfScript(false), |
1106 Library::UtfLibrary()); | 1096 Library::UtfLibrary()); |
1107 INIT_LIBRARY(Uri, | 1097 INIT_LIBRARY(Uri, |
1108 Bootstrap::LoadUriScript(false), | 1098 Bootstrap::LoadUriScript(false), |
1109 Library::UriLibrary()); | 1099 Library::UriLibrary()); |
1110 Bootstrap::SetupNativeResolver(); | 1100 Bootstrap::SetupNativeResolver(); |
1111 | 1101 |
1112 // Remove the Object superclass cycle by setting the super type to null (not | 1102 // Remove the Object superclass cycle by setting the super type to null (not |
1113 // to the type of null). | 1103 // to the type of null). |
(...skipping 11878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12992 } | 12982 } |
12993 return result.raw(); | 12983 return result.raw(); |
12994 } | 12984 } |
12995 | 12985 |
12996 | 12986 |
12997 const char* WeakProperty::ToCString() const { | 12987 const char* WeakProperty::ToCString() const { |
12998 return "_WeakProperty"; | 12988 return "_WeakProperty"; |
12999 } | 12989 } |
13000 | 12990 |
13001 } // namespace dart | 12991 } // namespace dart |
OLD | NEW |