Chromium Code Reviews| Index: runtime/bin/gen_snapshot.cc |
| diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc |
| index d8543adb9f47701284f3f9be79bc2e656c450498..0f668bb9a6d71da30bf5c0b6bd6b71bc5c311f1a 100644 |
| --- a/runtime/bin/gen_snapshot.cc |
| +++ b/runtime/bin/gen_snapshot.cc |
| @@ -177,15 +177,26 @@ static Dart_Handle BuiltinLibraryTagHandler(Dart_LibraryTag tag, |
| } |
| -static Dart_Handle LoadGenericSnapshotCreationScript() { |
| - Dart_Handle source = Builtin::Source(); |
| +static Dart_Handle LoadGenericSnapshotCreationScript( |
| + Builtin::BuiltinLibraryId id) { |
| + Dart_Handle source = Builtin::Source(id); |
| if (Dart_IsError(source)) { |
| return source; // source contains the error string. |
| } |
| - Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); |
| - Dart_Handle lib = Dart_LoadScript(url, source, BuiltinLibraryTagHandler); |
| + Dart_Handle lib; |
| + if (id == Builtin::kBuiltinLibrary) { |
| + // Load the dart:builtin library as the script. |
| + Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); |
| + lib = Dart_LoadScript(url, source, BuiltinLibraryTagHandler); |
| + } else { |
| + // Load the dart:io library with dependencies as a library to make |
|
Ivan Posva
2012/01/21 20:24:55
ASSERT(id == Builtin::kIOLibrary);
Mads Ager (google)
2012/01/23 11:35:38
Done.
|
| + // it available in the snapshot for importing. |
| + lib = Builtin::LoadLibrary(Builtin::kIOLibrary); |
| + Builtin::ImportLibrary(lib, Builtin::kNativeWrappersLibrary); |
| + Builtin::ImportLibrary(lib, Builtin::kCoreImplLibrary); |
| + } |
| if (!Dart_IsError(lib)) { |
| - Builtin::SetupLibrary(lib); |
| + Builtin::SetupLibrary(lib, id); |
| } |
| return lib; |
| } |
| @@ -198,6 +209,18 @@ static void PrintUsage() { |
| } |
| +static void VerifyLoaded(Dart_Handle library) { |
| + if (Dart_IsError(library)) { |
| + const char* err_msg = Dart_GetError(library); |
| + fprintf(stderr, "Errors encountered while loading: %s\n", err_msg); |
| + Dart_ExitScope(); |
| + Dart_ShutdownIsolate(); |
| + exit(255); |
| + } |
| + ASSERT(Dart_IsLibrary(library)); |
| +} |
| + |
| + |
| int main(int argc, char** argv) { |
| CommandLineOptions vm_options(argc); |
| @@ -243,18 +266,15 @@ int main(int argc, char** argv) { |
| if (app_script_name != NULL) { |
| // Load the specified script. |
| library = LoadSnapshotCreationScript(app_script_name); |
| + VerifyLoaded(library); |
| } else { |
| // This is a generic dart snapshot which needs builtin library setup. |
| - library = LoadGenericSnapshotCreationScript(); |
| - } |
| - if (Dart_IsError(library)) { |
| - const char* err_msg = Dart_GetError(library); |
| - fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); |
| - Dart_ExitScope(); |
| - Dart_ShutdownIsolate(); |
| - exit(255); |
| + library = LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary); |
| + VerifyLoaded(library); |
| + library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary); |
| + VerifyLoaded(library); |
| } |
| - ASSERT(Dart_IsLibrary(library)); |
| + |
| uint8_t* buffer = NULL; |
| intptr_t size = 0; |
| // First create the snapshot. |