Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 9254026: Split dart:builtin into dart:builtin and dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment and add binaries. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index d8543adb9f47701284f3f9be79bc2e656c450498..56913399078f30e98d932d3699869382ead029e4 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -177,15 +177,25 @@ 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 {
+ ASSERT(id == Builtin::kIOLibrary);
+ // Load the dart:io library to make it available in the snapshot
+ // for importing.
+ lib = Builtin::LoadLibrary(Builtin::kIOLibrary);
+ }
if (!Dart_IsError(lib)) {
- Builtin::SetupLibrary(lib);
+ Builtin::SetupLibrary(lib, id);
}
return lib;
}
@@ -198,6 +208,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 +265,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.
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698