| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
| 6 // command line. | 6 // command line. |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 static Dart_Handle LoadGenericSnapshotCreationScript( | 190 static Dart_Handle LoadGenericSnapshotCreationScript( |
| 191 Builtin::BuiltinLibraryId id) { | 191 Builtin::BuiltinLibraryId id) { |
| 192 Dart_Handle source = Builtin::Source(id); | 192 Dart_Handle source = Builtin::Source(id); |
| 193 if (Dart_IsError(source)) { | 193 if (Dart_IsError(source)) { |
| 194 return source; // source contains the error string. | 194 return source; // source contains the error string. |
| 195 } | 195 } |
| 196 Dart_Handle lib; | 196 Dart_Handle lib; |
| 197 // Load the builtin library to make it available in the snapshot | 197 // Load the builtin library to make it available in the snapshot |
| 198 // for importing. | 198 // for importing. |
| 199 lib = Builtin::LoadAndCheckLibrary(id); | 199 lib = Builtin::LoadAndCheckLibrary(id); |
| 200 if (!Dart_IsError(lib)) { | 200 ASSERT(!Dart_IsError(lib)); |
| 201 Builtin::SetupLibrary(lib, id); | |
| 202 } | |
| 203 return lib; | 201 return lib; |
| 204 } | 202 } |
| 205 | 203 |
| 206 | 204 |
| 207 static void PrintUsage() { | 205 static void PrintUsage() { |
| 208 fprintf(stderr, | 206 fprintf(stderr, |
| 209 "dart [<vm-flags>] " | 207 "dart [<vm-flags>] " |
| 210 "[<dart-script-file>]\n"); | 208 "[<dart-script-file>]\n"); |
| 211 } | 209 } |
| 212 | 210 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if (Dart_IsError(result)) { | 251 if (Dart_IsError(result)) { |
| 254 fprintf(stderr, "%s", Dart_GetError(result)); | 252 fprintf(stderr, "%s", Dart_GetError(result)); |
| 255 Dart_ExitScope(); | 253 Dart_ExitScope(); |
| 256 Dart_ShutdownIsolate(); | 254 Dart_ShutdownIsolate(); |
| 257 exit(255); | 255 exit(255); |
| 258 } | 256 } |
| 259 // This is a generic dart snapshot which needs builtin library setup. | 257 // This is a generic dart snapshot which needs builtin library setup. |
| 260 Dart_Handle library = | 258 Dart_Handle library = |
| 261 LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary); | 259 LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary); |
| 262 VerifyLoaded(library); | 260 VerifyLoaded(library); |
| 261 library = LoadGenericSnapshotCreationScript(Builtin::kJsonLibrary); |
| 262 VerifyLoaded(library); |
| 263 library = LoadGenericSnapshotCreationScript(Builtin::kUriLibrary); |
| 264 VerifyLoaded(library); |
| 263 library = LoadGenericSnapshotCreationScript(Builtin::kCryptoLibrary); | 265 library = LoadGenericSnapshotCreationScript(Builtin::kCryptoLibrary); |
| 264 VerifyLoaded(library); | 266 VerifyLoaded(library); |
| 265 library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary); | 267 library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary); |
| 266 VerifyLoaded(library); | 268 VerifyLoaded(library); |
| 267 library = LoadGenericSnapshotCreationScript(Builtin::kJsonLibrary); | |
| 268 VerifyLoaded(library); | |
| 269 library = LoadGenericSnapshotCreationScript(Builtin::kUriLibrary); | |
| 270 VerifyLoaded(library); | |
| 271 library = LoadGenericSnapshotCreationScript(Builtin::kUtfLibrary); | 269 library = LoadGenericSnapshotCreationScript(Builtin::kUtfLibrary); |
| 272 VerifyLoaded(library); | 270 VerifyLoaded(library); |
| 273 } | 271 } |
| 274 | 272 |
| 275 | 273 |
| 276 int main(int argc, char** argv) { | 274 int main(int argc, char** argv) { |
| 277 CommandLineOptions vm_options(argc); | 275 CommandLineOptions vm_options(argc); |
| 278 | 276 |
| 279 // Initialize the URL mapping array. | 277 // Initialize the URL mapping array. |
| 280 CommandLineOptions url_mapping_array(argc); | 278 CommandLineOptions url_mapping_array(argc); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 381 |
| 384 // Now create and write snapshot of script. | 382 // Now create and write snapshot of script. |
| 385 CreateAndWriteSnapshot(true); | 383 CreateAndWriteSnapshot(true); |
| 386 } | 384 } |
| 387 } else { | 385 } else { |
| 388 SetupForGenericSnapshotCreation(); | 386 SetupForGenericSnapshotCreation(); |
| 389 CreateAndWriteSnapshot(false); | 387 CreateAndWriteSnapshot(false); |
| 390 } | 388 } |
| 391 return 0; | 389 return 0; |
| 392 } | 390 } |
| OLD | NEW |