Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: runtime/bin/dartutils.cc

Issue 1553233002: Add package config support to dart:isolate (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressed review comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 Dart_PropagateError(err); 651 Dart_PropagateError(err);
652 } 652 }
653 } 653 }
654 654
655 655
656 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib, 656 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
657 Dart_Handle internal_lib, 657 Dart_Handle internal_lib,
658 bool is_service_isolate, 658 bool is_service_isolate,
659 bool trace_loading, 659 bool trace_loading,
660 const char* package_root, 660 const char* package_root,
661 const char** package_map, 661 const char* packages_config) {
662 const char* packages_file) {
663 // Setup the internal library's 'internalPrint' function. 662 // Setup the internal library's 'internalPrint' function.
664 Dart_Handle print = Dart_Invoke( 663 Dart_Handle print = Dart_Invoke(
665 builtin_lib, NewString("_getPrintClosure"), 0, NULL); 664 builtin_lib, NewString("_getPrintClosure"), 0, NULL);
666 RETURN_IF_ERROR(print); 665 RETURN_IF_ERROR(print);
667 Dart_Handle result = 666 Dart_Handle result =
668 Dart_SetField(internal_lib, NewString("_printClosure"), print); 667 Dart_SetField(internal_lib, NewString("_printClosure"), print);
669 RETURN_IF_ERROR(result); 668 RETURN_IF_ERROR(result);
670 669
671 if (!is_service_isolate) { 670 if (!is_service_isolate) {
672 if (IsWindowsHost()) { 671 if (IsWindowsHost()) {
(...skipping 13 matching lines...) Expand all
686 if (load_port == ILLEGAL_PORT) { 685 if (load_port == ILLEGAL_PORT) {
687 return Dart_NewUnhandledExceptionError( 686 return Dart_NewUnhandledExceptionError(
688 NewDartUnsupportedError("Service did not return load port.")); 687 NewDartUnsupportedError("Service did not return load port."));
689 } 688 }
690 result = Builtin::SetLoadPort(load_port); 689 result = Builtin::SetLoadPort(load_port);
691 RETURN_IF_ERROR(result); 690 RETURN_IF_ERROR(result);
692 } 691 }
693 692
694 // Set up package root if specified. 693 // Set up package root if specified.
695 if (package_root != NULL) { 694 if (package_root != NULL) {
696 ASSERT(package_map == NULL); 695 ASSERT(packages_config == NULL);
697 ASSERT(packages_file == NULL);
698 result = NewString(package_root); 696 result = NewString(package_root);
699 RETURN_IF_ERROR(result); 697 RETURN_IF_ERROR(result);
700 const int kNumArgs = 1; 698 const int kNumArgs = 1;
701 Dart_Handle dart_args[kNumArgs]; 699 Dart_Handle dart_args[kNumArgs];
702 dart_args[0] = result; 700 dart_args[0] = result;
703 result = Dart_Invoke(builtin_lib, 701 result = Dart_Invoke(builtin_lib,
704 NewString("_setPackageRoot"), 702 NewString("_setPackageRoot"),
705 kNumArgs, 703 kNumArgs,
706 dart_args); 704 dart_args);
707 RETURN_IF_ERROR(result); 705 RETURN_IF_ERROR(result);
708 } else if (package_map != NULL) { 706 } else if (packages_config != NULL) {
709 ASSERT(packages_file == NULL); 707 result = NewString(packages_config);
710 Dart_Handle func_name = NewString("_addPackageMapEntry");
711 RETURN_IF_ERROR(func_name);
712
713 for (int i = 0; package_map[i] != NULL; i +=2) {
714 const int kNumArgs = 2;
715 Dart_Handle dart_args[kNumArgs];
716 // Get the key.
717 result = NewString(package_map[i]);
718 RETURN_IF_ERROR(result);
719 dart_args[0] = result;
720 if (package_map[i + 1] == NULL) {
721 return Dart_NewUnhandledExceptionError(
722 NewDartArgumentError("Adding package map entry without value."));
723 }
724 // Get the value.
725 result = NewString(package_map[i + 1]);
726 RETURN_IF_ERROR(result);
727 dart_args[1] = result;
728 // Setup the next package map entry.
729 result = Dart_Invoke(builtin_lib,
730 func_name,
731 kNumArgs,
732 dart_args);
733 RETURN_IF_ERROR(result);
734 }
735 } else if (packages_file != NULL) {
736 result = NewString(packages_file);
737 RETURN_IF_ERROR(result); 708 RETURN_IF_ERROR(result);
738 const int kNumArgs = 1; 709 const int kNumArgs = 1;
739 Dart_Handle dart_args[kNumArgs]; 710 Dart_Handle dart_args[kNumArgs];
740 dart_args[0] = result; 711 dart_args[0] = result;
741 result = Dart_Invoke(builtin_lib, 712 result = Dart_Invoke(builtin_lib,
742 NewString("_loadPackagesMap"), 713 NewString("_loadPackagesMap"),
743 kNumArgs, 714 kNumArgs,
744 dart_args); 715 dart_args);
745 RETURN_IF_ERROR(result); 716 RETURN_IF_ERROR(result);
746 } 717 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 return Dart_Invoke(io_lib, NewString("_setupHooks"), 0, NULL); 753 return Dart_Invoke(io_lib, NewString("_setupHooks"), 0, NULL);
783 } 754 }
784 755
785 756
786 Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) { 757 Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) {
787 return Dart_Invoke(isolate_lib, NewString("_setupHooks"), 0, NULL); 758 return Dart_Invoke(isolate_lib, NewString("_setupHooks"), 0, NULL);
788 } 759 }
789 760
790 761
791 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, 762 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root,
792 const char** package_map, 763 const char* packages_config,
793 const char* packages_file,
794 bool is_service_isolate, 764 bool is_service_isolate,
795 bool trace_loading, 765 bool trace_loading,
796 Dart_Handle builtin_lib) { 766 Dart_Handle builtin_lib) {
797 // First ensure all required libraries are available. 767 // First ensure all required libraries are available.
798 Dart_Handle url = NewString(kCoreLibURL); 768 Dart_Handle url = NewString(kCoreLibURL);
799 RETURN_IF_ERROR(url); 769 RETURN_IF_ERROR(url);
800 Dart_Handle core_lib = Dart_LookupLibrary(url); 770 Dart_Handle core_lib = Dart_LookupLibrary(url);
801 RETURN_IF_ERROR(core_lib); 771 RETURN_IF_ERROR(core_lib);
802 url = NewString(kAsyncLibURL); 772 url = NewString(kAsyncLibURL);
803 RETURN_IF_ERROR(url); 773 RETURN_IF_ERROR(url);
(...skipping 13 matching lines...) Expand all
817 // We need to ensure that all the scripts loaded so far are finalized 787 // We need to ensure that all the scripts loaded so far are finalized
818 // as we are about to invoke some Dart code below to setup closures. 788 // as we are about to invoke some Dart code below to setup closures.
819 Dart_Handle result = Dart_FinalizeLoading(false); 789 Dart_Handle result = Dart_FinalizeLoading(false);
820 RETURN_IF_ERROR(result); 790 RETURN_IF_ERROR(result);
821 791
822 result = PrepareBuiltinLibrary(builtin_lib, 792 result = PrepareBuiltinLibrary(builtin_lib,
823 internal_lib, 793 internal_lib,
824 is_service_isolate, 794 is_service_isolate,
825 trace_loading, 795 trace_loading,
826 package_root, 796 package_root,
827 package_map, 797 packages_config);
828 packages_file);
829 RETURN_IF_ERROR(result); 798 RETURN_IF_ERROR(result);
830 799
831 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib)); 800 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib));
832 RETURN_IF_ERROR(PrepareCoreLibrary( 801 RETURN_IF_ERROR(PrepareCoreLibrary(
833 core_lib, builtin_lib, is_service_isolate)); 802 core_lib, builtin_lib, is_service_isolate));
834 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib)); 803 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib));
835 RETURN_IF_ERROR(PrepareIOLibrary(io_lib)); 804 RETURN_IF_ERROR(PrepareIOLibrary(io_lib));
836 return result; 805 return result;
837 } 806 }
838 807
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 new CObjectString(CObject::NewString(os_error->message())); 1262 new CObjectString(CObject::NewString(os_error->message()));
1294 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1263 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1295 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1264 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1296 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1265 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1297 result->SetAt(2, error_message); 1266 result->SetAt(2, error_message);
1298 return result; 1267 return result;
1299 } 1268 }
1300 1269
1301 } // namespace bin 1270 } // namespace bin
1302 } // namespace dart 1271 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698