| Index: bin/builtin_in.cc
|
| ===================================================================
|
| --- bin/builtin_in.cc (revision 1624)
|
| +++ bin/builtin_in.cc (working copy)
|
| @@ -94,50 +94,48 @@
|
| }
|
|
|
|
|
| -void Builtin_LoadLibrary() {
|
| - Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
|
| - Dart_Handle result = Dart_LookupLibrary(url);
|
| - if (!Dart_IsError(result)) {
|
| - // Builtin library already loaded.
|
| - return;
|
| - }
|
| -
|
| - // Load the library.
|
| - Dart_Handle source = Dart_NewString(Builtin_source_);
|
| - Dart_Handle builtin_lib = Dart_LoadLibrary(url, source);
|
| - DART_CHECK_VALID(builtin_lib);
|
| -
|
| - // Lookup the core libraries and inject the builtin library into them.
|
| - Dart_Handle core_lib = Dart_LookupLibrary(Dart_NewString("dart:core"));
|
| +static void SetupCorelibImports(Dart_Handle builtin_lib) {
|
| + // Lookup the core libraries and import the builtin library into them.
|
| + Dart_Handle url = Dart_NewString(DartUtils::kCoreLibURL);
|
| + Dart_Handle core_lib = Dart_LookupLibrary(url);
|
| DART_CHECK_VALID(core_lib);
|
| - result = Dart_LibraryImportLibrary(core_lib, builtin_lib);
|
| + Dart_Handle result = Dart_LibraryImportLibrary(core_lib, builtin_lib);
|
| DART_CHECK_VALID(result);
|
|
|
| - Dart_Handle coreimpl_lib =
|
| - Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
|
| + url = Dart_NewString(DartUtils::kCoreImplLibURL);
|
| + Dart_Handle coreimpl_lib = Dart_LookupLibrary(url);
|
| DART_CHECK_VALID(coreimpl_lib);
|
| result = Dart_LibraryImportLibrary(coreimpl_lib, builtin_lib);
|
| DART_CHECK_VALID(result);
|
| - result = Dart_LibraryImportLibrary(builtin_lib, coreimpl_lib);
|
| - DART_CHECK_VALID(result);
|
| +}
|
|
|
| - // Create a native wrapper "EventHandlerNativeWrapper" so that we can add a
|
| - // native field to store the event handle for implementing all
|
| - // event operations.
|
| - Dart_Handle name = Dart_NewString("EventHandlerNativeWrapper");
|
| - const int kNumEventHandlerFields = 1;
|
| - result = Dart_CreateNativeWrapperClass(builtin_lib,
|
| - name,
|
| - kNumEventHandlerFields);
|
| +
|
| +Dart_Handle Builtin_Source() {
|
| + Dart_Handle str = Dart_NewString(Builtin_source_);
|
| + return str;
|
| +}
|
| +
|
| +
|
| +void Builtin_SetupLibrary(Dart_Handle builtin_lib) {
|
| + // Setup core lib, builtin import structure.
|
| + SetupCorelibImports(builtin_lib);
|
| + // Setup the native resolver for built in library functions.
|
| + Dart_Handle result = Dart_SetNativeResolver(builtin_lib, native_lookup);
|
| DART_CHECK_VALID(result);
|
| }
|
|
|
|
|
| void Builtin_ImportLibrary(Dart_Handle library) {
|
| - Builtin_LoadLibrary();
|
| -
|
| Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
|
| Dart_Handle builtin_lib = Dart_LookupLibrary(url);
|
| + if (Dart_IsError(builtin_lib)) {
|
| + Dart_Handle source = Dart_NewString(Builtin_source_);
|
| + builtin_lib = Dart_LoadLibrary(url, source);
|
| + if (!Dart_IsError(builtin_lib)) {
|
| + Builtin_SetupLibrary(builtin_lib);
|
| + }
|
| + }
|
| + // Import the builtin library into current library.
|
| DART_CHECK_VALID(builtin_lib);
|
| Dart_Handle result = Dart_LibraryImportLibrary(library, builtin_lib);
|
| DART_CHECK_VALID(result);
|
| @@ -148,6 +146,7 @@
|
| Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
|
| Dart_Handle builtin_lib = Dart_LookupLibrary(url);
|
| DART_CHECK_VALID(builtin_lib);
|
| + // Setup the native resolver for built in library functions.
|
| Dart_Handle result = Dart_SetNativeResolver(builtin_lib, native_lookup);
|
| DART_CHECK_VALID(result);
|
| }
|
|
|