| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 508 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 509 | 509 |
| 510 // Initialize the Dart VM. | 510 // Initialize the Dart VM. |
| 511 // Note: We don't expect isolates to be created from dart code during | 511 // Note: We don't expect isolates to be created from dart code during |
| 512 // snapshot generation. | 512 // snapshot generation. |
| 513 if (!Dart_Initialize(NULL, NULL, NULL, NULL, | 513 if (!Dart_Initialize(NULL, NULL, NULL, NULL, |
| 514 DartUtils::OpenFile, | 514 DartUtils::OpenFile, |
| 515 DartUtils::ReadFile, | 515 DartUtils::ReadFile, |
| 516 DartUtils::WriteFile, | 516 DartUtils::WriteFile, |
| 517 DartUtils::CloseFile, | 517 DartUtils::CloseFile, |
| 518 DartUtils::EntropySource, | 518 DartUtils::EntropySource)) { |
| 519 NULL)) { | |
| 520 Log::PrintErr("VM initialization failed\n"); | 519 Log::PrintErr("VM initialization failed\n"); |
| 521 return 255; | 520 return 255; |
| 522 } | 521 } |
| 523 | 522 |
| 524 char* error; | 523 char* error; |
| 525 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error); | 524 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error); |
| 526 if (isolate == NULL) { | 525 if (isolate == NULL) { |
| 527 Log::PrintErr("Error: %s", error); | 526 Log::PrintErr("Error: %s", error); |
| 528 free(error); | 527 free(error); |
| 529 exit(255); | 528 exit(255); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 547 Dart_Handle builtin_lib = | 546 Dart_Handle builtin_lib = |
| 548 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 547 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 549 CHECK_RESULT(builtin_lib); | 548 CHECK_RESULT(builtin_lib); |
| 550 | 549 |
| 551 // Ensure that we mark all libraries as loaded. | 550 // Ensure that we mark all libraries as loaded. |
| 552 result = Dart_FinalizeLoading(false); | 551 result = Dart_FinalizeLoading(false); |
| 553 CHECK_RESULT(result); | 552 CHECK_RESULT(result); |
| 554 | 553 |
| 555 // Prepare for script loading by setting up the 'print' and 'timer' | 554 // Prepare for script loading by setting up the 'print' and 'timer' |
| 556 // closures and setting up 'package root' for URI resolution. | 555 // closures and setting up 'package root' for URI resolution. |
| 557 result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib); | 556 result = |
| 557 DartUtils::PrepareForScriptLoading(package_root, false, builtin_lib); |
| 558 CHECK_RESULT(result); | 558 CHECK_RESULT(result); |
| 559 Dart_ExitScope(); | 559 Dart_ExitScope(); |
| 560 | 560 |
| 561 UriResolverIsolateScope::isolate = isolate; | 561 UriResolverIsolateScope::isolate = isolate; |
| 562 | 562 |
| 563 // Now we create an isolate into which we load all the code that needs to | 563 // Now we create an isolate into which we load all the code that needs to |
| 564 // be in the snapshot. | 564 // be in the snapshot. |
| 565 if (Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error) == NULL) { | 565 if (Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error) == NULL) { |
| 566 fprintf(stderr, "%s", error); | 566 fprintf(stderr, "%s", error); |
| 567 free(error); | 567 free(error); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 589 } | 589 } |
| 590 return 0; | 590 return 0; |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace bin | 593 } // namespace bin |
| 594 } // namespace dart | 594 } // namespace dart |
| 595 | 595 |
| 596 int main(int argc, char** argv) { | 596 int main(int argc, char** argv) { |
| 597 return dart::bin::main(argc, argv); | 597 return dart::bin::main(argc, argv); |
| 598 } | 598 } |
| OLD | NEW |