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

Unified Diff: bin/process_script.cc

Issue 8343071: When generating snapshots for a specified script don't include the builtin library by default. Th... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 2 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 | « bin/process_script.h ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/process_script.cc
===================================================================
--- bin/process_script.cc (revision 900)
+++ bin/process_script.cc (working copy)
@@ -86,9 +86,16 @@
}
-static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
- Dart_Handle library,
- Dart_Handle url) {
+enum ImportBuiltin {
Anton Muhin 2011/10/31 17:48:34 nit: I would rather have two bool constants for it
siva 2011/10/31 21:09:32 Done.
+ kImportBuiltinLib = 0, // Import builtin library into all added libs.
+ kDontImportBuiltinLib, // Do not import builtin lib into the added libs.
+};
+
+
+static Dart_Handle LibraryTagHandlerHelper(Dart_LibraryTag tag,
+ Dart_Handle library,
+ Dart_Handle url,
+ ImportBuiltin import_builtin_lib) {
if (!Dart_IsLibrary(library)) {
return Dart_Error("not a library");
}
@@ -132,10 +139,9 @@
if (!Dart_IsValid(source)) {
return result;
}
-
if (tag == kImportTag) {
Dart_Handle new_lib = Dart_LoadLibrary(url, source);
- if (Dart_IsValid(new_lib)) {
+ if ((import_builtin_lib == kImportBuiltinLib) && Dart_IsValid(new_lib)) {
// TODO(iposva): Should the builtin library be added to all libraries?
Anton Muhin 2011/10/31 17:48:34 may TODO go away or get moved into MainLibraryTagH
siva 2011/10/31 21:09:32 Done.
Builtin_ImportLibrary(new_lib);
}
@@ -146,7 +152,20 @@
return Dart_Error("wrong tag");
}
+static Dart_Handle MainLibraryTagHandler(Dart_LibraryTag tag,
+ Dart_Handle library,
+ Dart_Handle url) {
+ return LibraryTagHandlerHelper(tag, library, url, kImportBuiltinLib);
+}
+
+static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
+ Dart_Handle library,
+ Dart_Handle url) {
+ return LibraryTagHandlerHelper(tag, library, url, kDontImportBuiltinLib);
+}
+
+
Dart_Handle LoadScript(const char* script_name) {
Dart_Handle source = ReadStringFromFile(script_name);
if (!Dart_IsValid(source)) {
@@ -154,5 +173,16 @@
}
Dart_Handle url = Dart_NewString(script_name);
- return Dart_LoadScript(url, source, LibraryTagHandler);
+ return Dart_LoadScript(url, source, MainLibraryTagHandler);
}
+
+
+Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
+ Dart_Handle source = ReadStringFromFile(script_name);
+ if (!Dart_IsValid(source)) {
+ return source;
+ }
+ Dart_Handle url = Dart_NewString(script_name);
+
+ return Dart_LoadScript(url, source, CreateSnapshotLibraryTagHandler);
+}
« no previous file with comments | « bin/process_script.h ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698