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_native_api.h" | 8 #include "include/dart_native_api.h" |
9 | 9 |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 if (tag == Dart_kSourceTag) { | 497 if (tag == Dart_kSourceTag) { |
498 // Prepend the library URI to form a unique script URI for the part. | 498 // Prepend the library URI to form a unique script URI for the part. |
499 intptr_t len = snprintf(NULL, 0, "%s/%s", library_url_string, url_string); | 499 intptr_t len = snprintf(NULL, 0, "%s/%s", library_url_string, url_string); |
500 char* part_uri = reinterpret_cast<char*>(malloc(len + 1)); | 500 char* part_uri = reinterpret_cast<char*>(malloc(len + 1)); |
501 snprintf(part_uri, len + 1, "%s/%s", library_url_string, url_string); | 501 snprintf(part_uri, len + 1, "%s/%s", library_url_string, url_string); |
502 Dart_Handle part_uri_obj = DartUtils::NewString(part_uri); | 502 Dart_Handle part_uri_obj = DartUtils::NewString(part_uri); |
503 free(part_uri); | 503 free(part_uri); |
504 return Dart_LoadSource( | 504 return Dart_LoadSource( |
505 library, | 505 library, |
506 part_uri_obj, | 506 part_uri_obj, |
507 Builtin::PartSource(Builtin::kIOLibrary, url_string)); | 507 Builtin::PartSource(Builtin::kIOLibrary, url_string), 0, 0); |
508 } else { | 508 } else { |
509 ASSERT(tag == Dart_kImportTag); | 509 ASSERT(tag == Dart_kImportTag); |
510 return NewError("Unable to import '%s' ", url_string); | 510 return NewError("Unable to import '%s' ", url_string); |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 Dart_Handle builtin_lib = | 514 Dart_Handle builtin_lib = |
515 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 515 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
516 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { | 516 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { |
517 // Load a native code shared library to use in a native extension | 517 // Load a native code shared library to use in a native extension |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 void FUNCTION_NAME(Builtin_LoadLibrarySource)(Dart_NativeArguments args) { | 737 void FUNCTION_NAME(Builtin_LoadLibrarySource)(Dart_NativeArguments args) { |
738 Dart_Handle tag_in = Dart_GetNativeArgument(args, 0); | 738 Dart_Handle tag_in = Dart_GetNativeArgument(args, 0); |
739 Dart_Handle resolved_script_uri = Dart_GetNativeArgument(args, 1); | 739 Dart_Handle resolved_script_uri = Dart_GetNativeArgument(args, 1); |
740 Dart_Handle library_uri = Dart_GetNativeArgument(args, 2); | 740 Dart_Handle library_uri = Dart_GetNativeArgument(args, 2); |
741 Dart_Handle sourceText = Dart_GetNativeArgument(args, 3); | 741 Dart_Handle sourceText = Dart_GetNativeArgument(args, 3); |
742 | 742 |
743 int64_t tag = DartUtils::GetIntegerValue(tag_in); | 743 int64_t tag = DartUtils::GetIntegerValue(tag_in); |
744 | 744 |
745 Dart_Handle result; | 745 Dart_Handle result; |
746 if (tag == Dart_kImportTag) { | 746 if (tag == Dart_kImportTag) { |
747 result = Dart_LoadLibrary(resolved_script_uri, sourceText); | 747 result = Dart_LoadLibrary(resolved_script_uri, sourceText, 0, 0); |
748 } else { | 748 } else { |
749 ASSERT(tag == Dart_kSourceTag); | 749 ASSERT(tag == Dart_kSourceTag); |
750 Dart_Handle library = Dart_LookupLibrary(library_uri); | 750 Dart_Handle library = Dart_LookupLibrary(library_uri); |
751 DART_CHECK_VALID(library); | 751 DART_CHECK_VALID(library); |
752 result = Dart_LoadSource(library, resolved_script_uri, sourceText); | 752 result = Dart_LoadSource(library, resolved_script_uri, sourceText, 0, 0); |
753 } | 753 } |
754 if (Dart_IsError(result)) { | 754 if (Dart_IsError(result)) { |
755 // TODO(hausner): If compilation/loading errors are supposed to | 755 // TODO(hausner): If compilation/loading errors are supposed to |
756 // be observable by the program, we need to mark the bad library | 756 // be observable by the program, we need to mark the bad library |
757 // with the error instead of propagating it. | 757 // with the error instead of propagating it. |
758 Dart_PropagateError(result); | 758 Dart_PropagateError(result); |
759 } | 759 } |
760 } | 760 } |
761 | 761 |
762 | 762 |
(...skipping 23 matching lines...) Expand all Loading... |
786 // Read the file. | 786 // Read the file. |
787 source = DartUtils::ReadStringFromFile(url_string); | 787 source = DartUtils::ReadStringFromFile(url_string); |
788 } | 788 } |
789 if (Dart_IsError(source)) { | 789 if (Dart_IsError(source)) { |
790 return source; // source contains the error string. | 790 return source; // source contains the error string. |
791 } | 791 } |
792 // The tag is either an import or a source tag. | 792 // The tag is either an import or a source tag. |
793 // Load it according to the specified tag. | 793 // Load it according to the specified tag. |
794 if (tag == Dart_kImportTag) { | 794 if (tag == Dart_kImportTag) { |
795 // Return library object or an error string. | 795 // Return library object or an error string. |
796 return Dart_LoadLibrary(url, source); | 796 return Dart_LoadLibrary(url, source, 0, 0); |
797 } else if (tag == Dart_kSourceTag) { | 797 } else if (tag == Dart_kSourceTag) { |
798 return Dart_LoadSource(library, url, source); | 798 return Dart_LoadSource(library, url, source, 0, 0); |
799 } | 799 } |
800 return Dart_NewApiError("wrong tag"); | 800 return Dart_NewApiError("wrong tag"); |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, | 804 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, |
805 Dart_Handle builtin_lib) { | 805 Dart_Handle builtin_lib) { |
806 // First ensure all required libraries are available. | 806 // First ensure all required libraries are available. |
807 Dart_Handle url = NewString(kAsyncLibURL); | 807 Dart_Handle url = NewString(kAsyncLibURL); |
808 DART_CHECK_VALID(url); | 808 DART_CHECK_VALID(url); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 new CObjectString(CObject::NewString(os_error->message())); | 1182 new CObjectString(CObject::NewString(os_error->message())); |
1183 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1183 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1184 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1184 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1185 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1185 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1186 result->SetAt(2, error_message); | 1186 result->SetAt(2, error_message); |
1187 return result; | 1187 return result; |
1188 } | 1188 } |
1189 | 1189 |
1190 } // namespace bin | 1190 } // namespace bin |
1191 } // namespace dart | 1191 } // namespace dart |
OLD | NEW |