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 "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_tools_api.h" | 8 #include "include/dart_tools_api.h" |
9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
10 | 10 |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 result = Dart_Invoke(builtin_lib, | 742 result = Dart_Invoke(builtin_lib, |
743 NewString("_loadPackagesMap"), | 743 NewString("_loadPackagesMap"), |
744 kNumArgs, | 744 kNumArgs, |
745 dart_args); | 745 dart_args); |
746 RETURN_IF_ERROR(result); | 746 RETURN_IF_ERROR(result); |
747 } | 747 } |
748 return Dart_True(); | 748 return Dart_True(); |
749 } | 749 } |
750 | 750 |
751 | 751 |
752 Dart_Handle DartUtils::PrepareCoreLibrary(Dart_Handle core_lib, | 752 Dart_Handle DartUtils::PrepareUriLibrary(Dart_Handle uri_lib, |
753 Dart_Handle builtin_lib, | 753 Dart_Handle builtin_lib, |
754 bool is_service_isolate) { | 754 bool is_service_isolate) { |
755 if (!is_service_isolate) { | 755 if (!is_service_isolate) { |
756 // Setup the 'Uri.base' getter in dart:core. | 756 // Setup the 'Uri.base' getter in dart:uri. |
757 Dart_Handle uri_base = Dart_Invoke( | 757 Dart_Handle uri_base = Dart_Invoke( |
758 builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); | 758 builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); |
759 RETURN_IF_ERROR(uri_base); | 759 RETURN_IF_ERROR(uri_base); |
760 Dart_Handle result = Dart_SetField(core_lib, | 760 Dart_Handle result = Dart_SetField(uri_lib, |
761 NewString("_uriBaseClosure"), | 761 NewString("_uriBaseClosure"), |
762 uri_base); | 762 uri_base); |
763 RETURN_IF_ERROR(result); | 763 RETURN_IF_ERROR(result); |
764 } | 764 } |
765 return Dart_True(); | 765 return Dart_True(); |
766 } | 766 } |
767 | 767 |
768 | 768 |
769 Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib, | 769 Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib, |
770 Dart_Handle isolate_lib) { | 770 Dart_Handle isolate_lib) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 url = NewString(kIsolateLibURL); | 807 url = NewString(kIsolateLibURL); |
808 RETURN_IF_ERROR(url); | 808 RETURN_IF_ERROR(url); |
809 Dart_Handle isolate_lib = Dart_LookupLibrary(url); | 809 Dart_Handle isolate_lib = Dart_LookupLibrary(url); |
810 RETURN_IF_ERROR(isolate_lib); | 810 RETURN_IF_ERROR(isolate_lib); |
811 url = NewString(kInternalLibURL); | 811 url = NewString(kInternalLibURL); |
812 RETURN_IF_ERROR(url); | 812 RETURN_IF_ERROR(url); |
813 Dart_Handle internal_lib = Dart_LookupLibrary(url); | 813 Dart_Handle internal_lib = Dart_LookupLibrary(url); |
814 RETURN_IF_ERROR(internal_lib); | 814 RETURN_IF_ERROR(internal_lib); |
815 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 815 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
816 RETURN_IF_ERROR(io_lib); | 816 RETURN_IF_ERROR(io_lib); |
| 817 url = NewString(kUriLibURL); |
| 818 RETURN_IF_ERROR(url); |
| 819 Dart_Handle uri_lib = Dart_LookupLibrary(url); |
| 820 RETURN_IF_ERROR(uri_lib); |
817 | 821 |
818 // We need to ensure that all the scripts loaded so far are finalized | 822 // We need to ensure that all the scripts loaded so far are finalized |
819 // as we are about to invoke some Dart code below to setup closures. | 823 // as we are about to invoke some Dart code below to setup closures. |
820 Dart_Handle result = Dart_FinalizeLoading(false); | 824 Dart_Handle result = Dart_FinalizeLoading(false); |
821 RETURN_IF_ERROR(result); | 825 RETURN_IF_ERROR(result); |
822 | 826 |
823 result = PrepareBuiltinLibrary(builtin_lib, | 827 result = PrepareBuiltinLibrary(builtin_lib, |
824 internal_lib, | 828 internal_lib, |
825 is_service_isolate, | 829 is_service_isolate, |
826 trace_loading, | 830 trace_loading, |
827 package_root, | 831 package_root, |
828 package_map, | 832 package_map, |
829 packages_file); | 833 packages_file); |
830 RETURN_IF_ERROR(result); | 834 RETURN_IF_ERROR(result); |
831 | 835 |
832 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib)); | 836 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib)); |
833 RETURN_IF_ERROR(PrepareCoreLibrary( | 837 RETURN_IF_ERROR(PrepareUriLibrary( |
834 core_lib, builtin_lib, is_service_isolate)); | 838 uri_lib, builtin_lib, is_service_isolate)); |
835 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib)); | 839 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib)); |
836 RETURN_IF_ERROR(PrepareIOLibrary(io_lib)); | 840 RETURN_IF_ERROR(PrepareIOLibrary(io_lib)); |
837 return result; | 841 return result; |
838 } | 842 } |
839 | 843 |
840 | 844 |
841 Dart_Handle DartUtils::SetupIOLibrary(const char* script_uri) { | 845 Dart_Handle DartUtils::SetupIOLibrary(const char* script_uri) { |
842 Dart_Handle io_lib_url = NewString(kIOLibURL); | 846 Dart_Handle io_lib_url = NewString(kIOLibURL); |
843 RETURN_IF_ERROR(io_lib_url); | 847 RETURN_IF_ERROR(io_lib_url); |
844 Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); | 848 Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 new CObjectString(CObject::NewString(os_error->message())); | 1298 new CObjectString(CObject::NewString(os_error->message())); |
1295 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1299 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1296 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1300 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1297 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1301 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1298 result->SetAt(2, error_message); | 1302 result->SetAt(2, error_message); |
1299 return result; | 1303 return result; |
1300 } | 1304 } |
1301 | 1305 |
1302 } // namespace bin | 1306 } // namespace bin |
1303 } // namespace dart | 1307 } // namespace dart |
OLD | NEW |