Index: bin/gen_snapshot.cc |
=================================================================== |
--- bin/gen_snapshot.cc (revision 1465) |
+++ bin/gen_snapshot.cc (working copy) |
@@ -90,38 +90,42 @@ |
} |
+static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
+ Dart_Handle library, |
+ Dart_Handle url) { |
+ const bool kDontImportBuiltinLib = false; // Do not import builtin lib. |
+ return LibraryTagHandlerHelper(tag, library, url, kDontImportBuiltinLib); |
+} |
+ |
+ |
static void* SnapshotCreateCallback(void* data) { |
const char* script_name = reinterpret_cast<const char*>(data); |
Dart_Handle result; |
+ Dart_Handle library; |
Dart_EnterScope(); |
ASSERT(snapshot_filename != NULL); |
- // If a file is specified on the command line, load it up before a snapshot |
- // is created. |
+ // load up the script before a snapshot is created. |
Anton Muhin
2011/11/13 16:19:32
nit: [L]oad the script
siva
2011/11/15 02:16:52
Done.
|
if (script_name != NULL) { |
// Load the specified script. |
- Dart_Handle library = LoadSnapshotCreationScript(script_name); |
- if (!Dart_IsValid(library)) { |
- const char* err_msg = Dart_GetError(library); |
- fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); |
- Dart_ExitScope(); |
- exit(255); |
- } |
- |
- if (!Dart_IsLibrary(library)) { |
- fprintf(stderr, |
- "Expected a library when loading script: %s", |
- script_name); |
- Dart_ExitScope(); |
- exit(255); |
- } |
+ library = LoadSnapshotCreationScript(script_name, LibraryTagHandler); |
} else { |
- // Implicitly load builtin library. |
- Builtin_LoadLibrary(); |
- // Setup the native resolver for built in library functions. |
- Builtin_SetNativeResolver(); |
+ // This is a generic dart snapshot which needs builtin library |
+ // setup. |
+ library = Builtin_LoadLibrary(LibraryTagHandler); |
Anton Muhin
2011/11/13 16:19:32
cannot you migrate to the common infrastructure fo
siva
2011/11/15 02:16:52
I would have if we had a 'builtin.dart' file to us
Anton Muhin
2011/11/15 12:22:23
sure
On 2011/11/15 02:16:52, asiva wrote:
|
} |
+ if (!Dart_IsValid(library)) { |
+ const char* err_msg = Dart_GetError(library); |
+ fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg); |
+ Dart_ExitScope(); |
+ exit(255); |
+ } |
+ if (!Dart_IsLibrary(library)) { |
Anton Muhin
2011/11/13 16:19:32
should it be an assert? esp. with new API.
siva
2011/11/15 02:16:52
No we want to fail if we don't find a library obje
Anton Muhin
2011/11/15 12:22:23
Is it a possible case when Builtin_LoadLibrary suc
siva
2011/11/15 19:42:49
I see what you are saying.
Changed to an ASSERT.
|
+ fprintf(stderr, "Expected a library when loading script: %s", script_name); |
+ Dart_ExitScope(); |
+ exit(255); |
+ } |
uint8_t* buffer = NULL; |
intptr_t size = 0; |