| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/loader.h" | 5 #include "bin/loader.h" |
| 6 | 6 |
| 7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
| 8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
| 9 #include "bin/dfe.h" | 9 #include "bin/dfe.h" |
| 10 #include "bin/extensions.h" | 10 #include "bin/extensions.h" |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 if (Dart_IsError(library_url)) { | 666 if (Dart_IsError(library_url)) { |
| 667 return library_url; | 667 return library_url; |
| 668 } | 668 } |
| 669 return Dart_DefaultCanonicalizeUrl(library_url, url); | 669 return Dart_DefaultCanonicalizeUrl(library_url, url); |
| 670 } | 670 } |
| 671 const char* url_string = NULL; | 671 const char* url_string = NULL; |
| 672 Dart_Handle result = Dart_StringToCString(url, &url_string); | 672 Dart_Handle result = Dart_StringToCString(url, &url_string); |
| 673 if (Dart_IsError(result)) { | 673 if (Dart_IsError(result)) { |
| 674 return result; | 674 return result; |
| 675 } | 675 } |
| 676 if (tag == Dart_kScriptTag) { | 676 if (tag == Dart_kKernelTag) { |
| 677 if (dfe.UseDartFrontend() || dfe.kernel_file_specified()) { | 677 ASSERT(dfe.UseDartFrontend() || dfe.kernel_file_specified()); |
| 678 Dart_Isolate current = Dart_CurrentIsolate(); | 678 Dart_Isolate current = Dart_CurrentIsolate(); |
| 679 // Check if we are trying to reload a kernel file or if the '--dfe' | 679 ASSERT(!Dart_IsServiceIsolate(current) && !Dart_IsKernelIsolate(current)); |
| 680 // option was specified and we need to compile sources using DFE. | 680 return dfe.ReadKernelBinary(current, url_string); |
| 681 if (!Dart_IsServiceIsolate(current) && !Dart_IsKernelIsolate(current)) { | 681 } |
| 682 // When using DFE the library tag handler should be called only when | 682 ASSERT(!dfe.UseDartFrontend() && !dfe.kernel_file_specified()); |
| 683 // we are reloading scripts. | 683 if (tag != Dart_kScriptTag) { |
| 684 return dfe.ReloadScript(current, url_string); | |
| 685 } | |
| 686 } | |
| 687 // TODO(asiva) We need to ensure that the kernel and service isolates | |
| 688 // are always loaded from a kernel IR and do not use this path. | |
| 689 } else { | |
| 690 // Special case for handling dart: imports and parts. | 684 // Special case for handling dart: imports and parts. |
| 691 // Grab the library's url. | 685 // Grab the library's url. |
| 692 Dart_Handle library_url = Dart_LibraryUrl(library); | 686 Dart_Handle library_url = Dart_LibraryUrl(library); |
| 693 if (Dart_IsError(library_url)) { | 687 if (Dart_IsError(library_url)) { |
| 694 return library_url; | 688 return library_url; |
| 695 } | 689 } |
| 696 const char* library_url_string = NULL; | 690 const char* library_url_string = NULL; |
| 697 result = Dart_StringToCString(library_url, &library_url_string); | 691 result = Dart_StringToCString(library_url, &library_url_string); |
| 698 if (Dart_IsError(result)) { | 692 if (Dart_IsError(result)) { |
| 699 return result; | 693 return result; |
| 700 } | 694 } |
| 701 | 695 |
| 702 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); | 696 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); |
| 703 bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string); | 697 bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string); |
| 704 | 698 |
| 705 if (is_dart_scheme_url || is_dart_library) { | 699 if (is_dart_scheme_url || is_dart_library) { |
| 706 return DartColonLibraryTagHandler(tag, library, url, library_url_string, | 700 return DartColonLibraryTagHandler(tag, library, url, library_url_string, |
| 707 url_string); | 701 url_string); |
| 708 } | 702 } |
| 709 } | 703 } |
| 710 | |
| 711 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { | 704 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { |
| 712 // Handle early error cases for dart-ext: imports. | 705 // Handle early error cases for dart-ext: imports. |
| 713 if (tag != Dart_kImportTag) { | 706 if (tag != Dart_kImportTag) { |
| 714 return DartUtils::NewError("Dart extensions must use import: '%s'", | 707 return DartUtils::NewError("Dart extensions must use import: '%s'", |
| 715 url_string); | 708 url_string); |
| 716 } | 709 } |
| 717 Dart_Handle library_url = Dart_LibraryUrl(library); | 710 Dart_Handle library_url = Dart_LibraryUrl(library); |
| 718 if (Dart_IsError(library_url)) { | 711 if (Dart_IsError(library_url)) { |
| 719 return library_url; | 712 return library_url; |
| 720 } | 713 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 MutexLocker ml(loader_infos_lock_); | 927 MutexLocker ml(loader_infos_lock_); |
| 935 Loader* loader = LoaderForLocked(dest_port_id); | 928 Loader* loader = LoaderForLocked(dest_port_id); |
| 936 if (loader == NULL) { | 929 if (loader == NULL) { |
| 937 return; | 930 return; |
| 938 } | 931 } |
| 939 loader->QueueMessage(message); | 932 loader->QueueMessage(message); |
| 940 } | 933 } |
| 941 | 934 |
| 942 } // namespace bin | 935 } // namespace bin |
| 943 } // namespace dart | 936 } // namespace dart |
| OLD | NEW |