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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "platform/json.h" | 7 #include "platform/json.h" |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "include/dart_debugger_api.h" | 9 #include "include/dart_debugger_api.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 } | 562 } |
563 | 563 |
564 | 564 |
565 static Dart_Handle CreateIsolateMirror() { | 565 static Dart_Handle CreateIsolateMirror() { |
566 Dart_Handle cls_name = Dart_NewString("_LocalIsolateMirrorImpl"); | 566 Dart_Handle cls_name = Dart_NewString("_LocalIsolateMirrorImpl"); |
567 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); | 567 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); |
568 if (Dart_IsError(cls)) { | 568 if (Dart_IsError(cls)) { |
569 return cls; | 569 return cls; |
570 } | 570 } |
571 | 571 |
| 572 Dart_Handle args[] = { Dart_DebugName() }; |
| 573 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); |
| 574 if (Dart_IsError(mirror)) { |
| 575 return mirror; |
| 576 } |
| 577 |
| 578 return mirror; |
| 579 } |
| 580 |
| 581 |
| 582 static Dart_Handle CreateMirrorSystem() { |
| 583 Dart_Handle cls_name = Dart_NewString("_LocalMirrorSystemImpl"); |
| 584 Dart_Handle cls = Dart_GetClass(MirrorLib(), cls_name); |
| 585 if (Dart_IsError(cls)) { |
| 586 return cls; |
| 587 } |
| 588 |
572 Dart_Handle libraries = CreateLibrariesMap(); | 589 Dart_Handle libraries = CreateLibrariesMap(); |
573 if (Dart_IsError(libraries)) { | 590 if (Dart_IsError(libraries)) { |
574 return libraries; | 591 return libraries; |
575 } | 592 } |
576 | 593 |
577 // Lookup the root_lib_mirror from the library list to canonicalize it. | 594 // Lookup the root_lib_mirror from the library list to canonicalize it. |
578 Dart_Handle root_lib_name = Dart_LibraryName(Dart_RootLibrary()); | 595 Dart_Handle root_lib_name = Dart_LibraryName(Dart_RootLibrary()); |
579 Dart_Handle root_lib_mirror = MapGet(libraries, root_lib_name); | 596 Dart_Handle root_lib_mirror = MapGet(libraries, root_lib_name); |
580 if (Dart_IsError(root_lib_mirror)) { | 597 if (Dart_IsError(root_lib_mirror)) { |
581 return root_lib_mirror; | 598 return root_lib_mirror; |
582 } | 599 } |
583 | 600 |
584 Dart_Handle args[] = { | 601 Dart_Handle args[] = { |
585 Dart_DebugName(), | |
586 root_lib_mirror, | 602 root_lib_mirror, |
587 libraries, | 603 libraries, |
| 604 CreateIsolateMirror(), |
588 }; | 605 }; |
589 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 606 Dart_Handle mirror = Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); |
590 if (Dart_IsError(mirror)) { | 607 if (Dart_IsError(mirror)) { |
591 return mirror; | 608 return mirror; |
592 } | 609 } |
593 | 610 |
594 return mirror; | 611 return mirror; |
595 } | 612 } |
596 | 613 |
597 | 614 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 Dart_Handle mirrored_exc = | 697 Dart_Handle mirrored_exc = |
681 Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); | 698 Dart_New(cls, Dart_Null(), ARRAY_SIZE(args), args); |
682 return Dart_NewUnhandledExceptionError(mirrored_exc); | 699 return Dart_NewUnhandledExceptionError(mirrored_exc); |
683 } else { | 700 } else { |
684 ASSERT(Dart_IsFatalError(error)); | 701 ASSERT(Dart_IsFatalError(error)); |
685 return error; | 702 return error; |
686 } | 703 } |
687 } | 704 } |
688 | 705 |
689 | 706 |
690 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalIsolateMirror)( | 707 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( |
691 Dart_NativeArguments args) { | 708 Dart_NativeArguments args) { |
692 Dart_Handle mirror = CreateIsolateMirror(); | 709 Dart_Handle mirrors = CreateMirrorSystem(); |
693 if (Dart_IsError(mirror)) { | 710 if (Dart_IsError(mirrors)) { |
694 Dart_PropagateError(mirror); | 711 Dart_PropagateError(mirrors); |
695 } | 712 } |
696 Dart_SetReturnValue(args, mirror); | 713 Dart_SetReturnValue(args, mirrors); |
697 } | 714 } |
698 | 715 |
699 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalInstanceMirror)( | 716 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalInstanceMirror)( |
700 Dart_NativeArguments args) { | 717 Dart_NativeArguments args) { |
701 Dart_Handle reflectee = Dart_GetNativeArgument(args, 0); | 718 Dart_Handle reflectee = Dart_GetNativeArgument(args, 0); |
702 Dart_Handle mirror = CreateInstanceMirror(reflectee); | 719 Dart_Handle mirror = CreateInstanceMirror(reflectee); |
703 if (Dart_IsError(mirror)) { | 720 if (Dart_IsError(mirror)) { |
704 Dart_PropagateError(mirror); | 721 Dart_PropagateError(mirror); |
705 } | 722 } |
706 Dart_SetReturnValue(args, mirror); | 723 Dart_SetReturnValue(args, mirror); |
(...skipping 26 matching lines...) Expand all Loading... |
733 Dart_SetReturnValue(args, wrapped_result); | 750 Dart_SetReturnValue(args, wrapped_result); |
734 } | 751 } |
735 | 752 |
736 void HandleMirrorsMessage(Isolate* isolate, | 753 void HandleMirrorsMessage(Isolate* isolate, |
737 Dart_Port reply_port, | 754 Dart_Port reply_port, |
738 const Instance& message) { | 755 const Instance& message) { |
739 UNIMPLEMENTED(); | 756 UNIMPLEMENTED(); |
740 } | 757 } |
741 | 758 |
742 } // namespace dart | 759 } // namespace dart |
OLD | NEW |