| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 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::LoadLibrary(id); | 199 lib = Builtin::LoadAndCheckLibrary(id); |
| 200 if (!Dart_IsError(lib)) { | 200 if (!Dart_IsError(lib)) { |
| 201 Builtin::SetupLibrary(lib, id); | 201 Builtin::SetupLibrary(lib, id); |
| 202 } | 202 } |
| 203 return lib; | 203 return lib; |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 static void PrintUsage() { | 207 static void PrintUsage() { |
| 208 fprintf(stderr, | 208 fprintf(stderr, |
| 209 "dart [<vm-flags>] " | 209 "dart [<vm-flags>] " |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 free(error); | 362 free(error); |
| 363 exit(255); | 363 exit(255); |
| 364 } | 364 } |
| 365 Dart_EnterScope(); | 365 Dart_EnterScope(); |
| 366 | 366 |
| 367 // Setup generic library tag handler. | 367 // Setup generic library tag handler. |
| 368 result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); | 368 result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); |
| 369 CHECK_RESULT(result); | 369 CHECK_RESULT(result); |
| 370 | 370 |
| 371 // Get handle to builtin library. | 371 // Get handle to builtin library. |
| 372 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 372 Dart_Handle builtin_lib = |
| 373 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 373 CHECK_RESULT(builtin_lib); | 374 CHECK_RESULT(builtin_lib); |
| 374 | 375 |
| 375 // Prepare for script loading by setting up the 'print' and 'timer' | 376 // Prepare for script loading by setting up the 'print' and 'timer' |
| 376 // closures and setting up 'package root' for URI resolution. | 377 // closures and setting up 'package root' for URI resolution. |
| 377 result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib); | 378 result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib); |
| 378 CHECK_RESULT(result); | 379 CHECK_RESULT(result); |
| 379 | 380 |
| 380 // Load specified script. | 381 // Load specified script. |
| 381 library = DartUtils::LoadScript(app_script_name, true, builtin_lib); | 382 library = DartUtils::LoadScript(app_script_name, true, builtin_lib); |
| 382 | 383 |
| 383 // Now create and write snapshot of script. | 384 // Now create and write snapshot of script. |
| 384 CreateAndWriteSnapshot(true); | 385 CreateAndWriteSnapshot(true); |
| 385 } | 386 } |
| 386 } else { | 387 } else { |
| 387 SetupForGenericSnapshotCreation(); | 388 SetupForGenericSnapshotCreation(); |
| 388 CreateAndWriteSnapshot(false); | 389 CreateAndWriteSnapshot(false); |
| 389 } | 390 } |
| 390 return 0; | 391 return 0; |
| 391 } | 392 } |
| OLD | NEW |