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 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
11 | 11 |
12 #include "bin/builtin.h" | 12 #include "bin/builtin.h" |
13 #include "bin/dartutils.h" | 13 #include "bin/dartutils.h" |
14 #include "bin/directory.h" | 14 #include "bin/directory.h" |
15 #include "bin/embedded_dart_io.h" | 15 #include "bin/embedded_dart_io.h" |
16 #include "bin/eventhandler.h" | 16 #include "bin/eventhandler.h" |
17 #include "bin/extensions.h" | 17 #include "bin/extensions.h" |
18 #include "bin/file.h" | 18 #include "bin/file.h" |
19 #include "bin/isolate_data.h" | 19 #include "bin/isolate_data.h" |
| 20 #include "bin/loader.h" |
20 #include "bin/log.h" | 21 #include "bin/log.h" |
21 #include "bin/platform.h" | 22 #include "bin/platform.h" |
22 #include "bin/process.h" | 23 #include "bin/process.h" |
23 #include "bin/thread.h" | 24 #include "bin/thread.h" |
24 #include "bin/utils.h" | 25 #include "bin/utils.h" |
25 #include "bin/vmservice_impl.h" | 26 #include "bin/vmservice_impl.h" |
26 #include "platform/globals.h" | 27 #include "platform/globals.h" |
27 #include "platform/hashmap.h" | 28 #include "platform/hashmap.h" |
28 #include "platform/text_buffer.h" | 29 #include "platform/text_buffer.h" |
29 #if !defined(DART_PRECOMPILER) | 30 #if !defined(DART_PRECOMPILER) |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 720 |
720 Dart_EnterScope(); | 721 Dart_EnterScope(); |
721 | 722 |
722 if (isolate_snapshot_buffer != NULL) { | 723 if (isolate_snapshot_buffer != NULL) { |
723 // Setup the native resolver as the snapshot does not carry it. | 724 // Setup the native resolver as the snapshot does not carry it. |
724 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 725 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
725 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 726 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
726 } | 727 } |
727 | 728 |
728 // Set up the library tag handler for this isolate. | 729 // Set up the library tag handler for this isolate. |
729 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); | 730 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
730 CHECK_RESULT(result); | 731 CHECK_RESULT(result); |
731 | 732 |
732 if (Dart_IsServiceIsolate(isolate)) { | 733 if (Dart_IsServiceIsolate(isolate)) { |
733 // If this is the service isolate, load embedder specific bits and return. | 734 // If this is the service isolate, load embedder specific bits and return. |
734 bool skip_library_load = run_app_snapshot; | 735 bool skip_library_load = run_app_snapshot; |
735 if (!VmService::Setup(vm_service_server_ip, | 736 if (!VmService::Setup(vm_service_server_ip, |
736 vm_service_server_port, | 737 vm_service_server_port, |
737 skip_library_load)) { | 738 skip_library_load)) { |
738 *error = strdup(VmService::GetErrorMessage()); | 739 *error = strdup(VmService::GetErrorMessage()); |
739 return NULL; | 740 return NULL; |
(...skipping 25 matching lines...) Expand all Loading... |
765 CHECK_RESULT(result); | 766 CHECK_RESULT(result); |
766 | 767 |
767 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | 768 result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
768 CHECK_RESULT(result); | 769 CHECK_RESULT(result); |
769 | 770 |
770 if (run_app_snapshot) { | 771 if (run_app_snapshot) { |
771 result = DartUtils::SetupIOLibrary(script_uri); | 772 result = DartUtils::SetupIOLibrary(script_uri); |
772 CHECK_RESULT(result); | 773 CHECK_RESULT(result); |
773 } else { | 774 } else { |
774 // Load the specified application script into the newly created isolate. | 775 // Load the specified application script into the newly created isolate. |
775 result = DartUtils::LoadScript(script_uri); | 776 Dart_Handle uri = |
776 CHECK_RESULT(result); | 777 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); |
777 | 778 CHECK_RESULT(uri); |
778 // Run event-loop and wait for script loading to complete. | 779 result = Loader::LibraryTagHandler(Dart_kScriptTag, |
779 result = Dart_RunLoop(); | 780 Dart_Null(), |
| 781 uri); |
780 CHECK_RESULT(result); | 782 CHECK_RESULT(result); |
781 | 783 |
782 Dart_TimelineEvent("LoadScript", | 784 Dart_TimelineEvent("LoadScript", |
783 Dart_TimelineGetMicros(), | 785 Dart_TimelineGetMicros(), |
784 Dart_GetMainPortId(), | 786 Dart_GetMainPortId(), |
785 Dart_Timeline_Event_Async_End, | 787 Dart_Timeline_Event_Async_End, |
786 0, NULL, NULL); | 788 0, NULL, NULL); |
787 | 789 |
788 result = DartUtils::SetupIOLibrary(script_uri); | 790 result = DartUtils::SetupIOLibrary(script_uri); |
789 CHECK_RESULT(result); | 791 CHECK_RESULT(result); |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 Platform::Exit(Process::GlobalExitCode()); | 1733 Platform::Exit(Process::GlobalExitCode()); |
1732 } | 1734 } |
1733 | 1735 |
1734 } // namespace bin | 1736 } // namespace bin |
1735 } // namespace dart | 1737 } // namespace dart |
1736 | 1738 |
1737 int main(int argc, char** argv) { | 1739 int main(int argc, char** argv) { |
1738 dart::bin::main(argc, argv); | 1740 dart::bin::main(argc, argv); |
1739 UNREACHABLE(); | 1741 UNREACHABLE(); |
1740 } | 1742 } |
OLD | NEW |