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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 return Dart_LoadLibrary(url, source); | 653 return Dart_LoadLibrary(url, source); |
654 } else if (tag == Dart_kSourceTag) { | 654 } else if (tag == Dart_kSourceTag) { |
655 return Dart_LoadSource(library, url, source); | 655 return Dart_LoadSource(library, url, source); |
656 } | 656 } |
657 return Dart_Error("wrong tag"); | 657 return Dart_Error("wrong tag"); |
658 } | 658 } |
659 | 659 |
660 | 660 |
661 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, | 661 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, |
662 Dart_Handle builtin_lib) { | 662 Dart_Handle builtin_lib) { |
663 Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); | 663 // Setup the internal library's 'internalPrint' function. |
664 DART_CHECK_VALID(corelib); | 664 Dart_Handle internal_lib = |
665 | 665 Dart_LookupLibrary(NewString("dart:_collection-dev")); |
Ivan Posva
2013/10/16 07:19:51
In my opinion this has nothing to do with any coll
floitsch
2013/10/16 07:38:56
Yes. we want to rename it, but since it's not user
| |
666 // Setup the corelib 'print' function. | 666 DART_CHECK_VALID(internal_lib); |
667 Dart_Handle print = Dart_Invoke( | 667 Dart_Handle print = Dart_Invoke( |
668 builtin_lib, NewString("_getPrintClosure"), 0, NULL); | 668 builtin_lib, NewString("_getPrintClosure"), 0, NULL); |
669 Dart_Handle result = Dart_SetField(corelib, | 669 Dart_Handle result = Dart_SetField(internal_lib, |
670 NewString("_printClosure"), | 670 NewString("_printClosure"), |
671 print); | 671 print); |
672 DART_CHECK_VALID(result); | 672 DART_CHECK_VALID(result); |
673 | 673 |
674 // Setup the 'timer' factory. | 674 // Setup the 'timer' factory. |
675 Dart_Handle url = NewString(kAsyncLibURL); | 675 Dart_Handle url = NewString(kAsyncLibURL); |
676 DART_CHECK_VALID(url); | 676 DART_CHECK_VALID(url); |
677 Dart_Handle async_lib = Dart_LookupLibrary(url); | 677 Dart_Handle async_lib = Dart_LookupLibrary(url); |
678 DART_CHECK_VALID(async_lib); | 678 DART_CHECK_VALID(async_lib); |
679 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 679 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
680 Dart_Handle timer_closure = | 680 Dart_Handle timer_closure = |
681 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); | 681 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); |
682 Dart_Handle args[1]; | 682 Dart_Handle args[1]; |
683 args[0] = timer_closure; | 683 args[0] = timer_closure; |
684 DART_CHECK_VALID(Dart_Invoke( | 684 DART_CHECK_VALID(Dart_Invoke( |
685 async_lib, NewString("_setTimerFactoryClosure"), 1, args)); | 685 async_lib, NewString("_setTimerFactoryClosure"), 1, args)); |
686 | 686 |
687 // Setup the corelib 'Uri.base' getter. | 687 // Setup the corelib 'Uri.base' getter. |
688 Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); | |
689 DART_CHECK_VALID(corelib); | |
688 Dart_Handle uri_base = Dart_Invoke( | 690 Dart_Handle uri_base = Dart_Invoke( |
689 builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); | 691 builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); |
690 DART_CHECK_VALID(uri_base); | 692 DART_CHECK_VALID(uri_base); |
691 result = Dart_SetField(corelib, | 693 result = Dart_SetField(corelib, |
692 NewString("_uriBaseClosure"), | 694 NewString("_uriBaseClosure"), |
693 uri_base); | 695 uri_base); |
694 DART_CHECK_VALID(result); | 696 DART_CHECK_VALID(result); |
695 | 697 |
696 if (IsWindowsHost()) { | 698 if (IsWindowsHost()) { |
697 // Set running on Windows flag. | 699 // Set running on Windows flag. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1024 new CObjectString(CObject::NewString(os_error->message())); | 1026 new CObjectString(CObject::NewString(os_error->message())); |
1025 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1027 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1026 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1028 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1027 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1029 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1028 result->SetAt(2, error_message); | 1030 result->SetAt(2, error_message); |
1029 return result; | 1031 return result; |
1030 } | 1032 } |
1031 | 1033 |
1032 } // namespace bin | 1034 } // namespace bin |
1033 } // namespace dart | 1035 } // namespace dart |
OLD | NEW |