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 <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.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" |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 int* exit_code) { | 831 int* exit_code) { |
832 Dart_EnterScope(); | 832 Dart_EnterScope(); |
833 IsolateData* isolate_data = | 833 IsolateData* isolate_data = |
834 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); | 834 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); |
835 void* kernel_program = isolate_data->kernel_program; | 835 void* kernel_program = isolate_data->kernel_program; |
836 | 836 |
837 // Set up the library tag handler for this isolate. | 837 // Set up the library tag handler for this isolate. |
838 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); | 838 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
839 CHECK_RESULT(result); | 839 CHECK_RESULT(result); |
840 | 840 |
| 841 // Prepare builtin and other core libraries for use to resolve URIs. |
| 842 // Set up various closures, e.g: printing, timers etc. |
| 843 // Set up 'package root' for URI resolution. |
| 844 result = DartUtils::PrepareForScriptLoading(false, trace_loading); |
| 845 CHECK_RESULT(result); |
| 846 |
841 if (kernel_program != NULL) { | 847 if (kernel_program != NULL) { |
842 Dart_Handle result = Dart_LoadKernel(kernel_program); | 848 Dart_Handle uri = Dart_NewStringFromCString(script_uri); |
| 849 CHECK_RESULT(uri); |
| 850 Dart_Handle resolved_script_uri = DartUtils::ResolveScript(uri); |
| 851 CHECK_RESULT(resolved_script_uri); |
| 852 result = |
| 853 Dart_LoadScript(uri, resolved_script_uri, |
| 854 reinterpret_cast<Dart_Handle>(kernel_program), 0, 0); |
843 CHECK_RESULT(result); | 855 CHECK_RESULT(result); |
844 } | 856 } |
845 if (set_native_resolvers) { | 857 if (set_native_resolvers) { |
846 // Setup the native resolver as the snapshot does not carry it. | 858 // Setup the native resolver as the snapshot does not carry it. |
847 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 859 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
848 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 860 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
849 } | 861 } |
850 if (isolate_run_app_snapshot) { | 862 if (isolate_run_app_snapshot) { |
851 Dart_Handle result = Loader::ReloadNativeExtensions(); | 863 Dart_Handle result = Loader::ReloadNativeExtensions(); |
852 CHECK_RESULT(result); | 864 CHECK_RESULT(result); |
853 } | 865 } |
854 | 866 |
855 // Prepare builtin and other core libraries for use to resolve URIs. | |
856 // Set up various closures, e.g: printing, timers etc. | |
857 // Set up 'package root' for URI resolution. | |
858 result = DartUtils::PrepareForScriptLoading(false, trace_loading); | |
859 CHECK_RESULT(result); | |
860 | |
861 // Set up the load port provided by the service isolate so that we can | 867 // Set up the load port provided by the service isolate so that we can |
862 // load scripts. | 868 // load scripts. |
863 result = DartUtils::SetupServiceLoadPort(); | 869 result = DartUtils::SetupServiceLoadPort(); |
864 CHECK_RESULT(result); | 870 CHECK_RESULT(result); |
865 | 871 |
866 // Setup package root if specified. | 872 // Setup package root if specified. |
867 result = DartUtils::SetupPackageRoot(package_root, packages_config); | 873 result = DartUtils::SetupPackageRoot(package_root, packages_config); |
868 CHECK_RESULT(result); | 874 CHECK_RESULT(result); |
869 | 875 |
870 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | 876 result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 Platform::Exit(Process::GlobalExitCode()); | 1892 Platform::Exit(Process::GlobalExitCode()); |
1887 } | 1893 } |
1888 | 1894 |
1889 } // namespace bin | 1895 } // namespace bin |
1890 } // namespace dart | 1896 } // namespace dart |
1891 | 1897 |
1892 int main(int argc, char** argv) { | 1898 int main(int argc, char** argv) { |
1893 dart::bin::main(argc, argv); | 1899 dart::bin::main(argc, argv); |
1894 UNREACHABLE(); | 1900 UNREACHABLE(); |
1895 } | 1901 } |
OLD | NEW |