Chromium Code Reviews| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_debugger_api.h" | 6 #include "include/dart_debugger_api.h" |
| 7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. | 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. |
| 10 #include "vm/bootstrap_natives.h" | 10 #include "vm/bootstrap_natives.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 13 #include "vm/message.h" | 13 #include "vm/message.h" |
| 14 #include "vm/port.h" | 14 #include "vm/port.h" |
| 15 #include "vm/resolver.h" | 15 #include "vm/resolver.h" |
| 16 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 static RawInstance* CreateClassMirror(const Class& cls, | |
| 21 const Instance& owner_mirror); | |
| 22 static RawInstance* CreateLibraryMirror(const Library& lib); | |
| 23 static RawInstance* CreateMethodMirror(const Function& func, | |
| 24 const Instance& owner_mirror); | |
|
siva
2013/07/18 20:38:45
Why are these forward declarations needed?
Michael Lippautz (Google)
2013/07/18 22:01:23
Are not needed anymore. (At some point code was or
| |
| 25 | |
| 20 inline Dart_Handle NewString(const char* str) { | 26 inline Dart_Handle NewString(const char* str) { |
| 21 return Dart_NewStringFromCString(str); | 27 return Dart_NewStringFromCString(str); |
| 22 } | 28 } |
| 23 | 29 |
| 24 | 30 |
| 25 DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) { | 31 DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) { |
| 26 GET_NON_NULL_NATIVE_ARGUMENT(Instance, port, arguments->NativeArgAt(0)); | 32 GET_NON_NULL_NATIVE_ARGUMENT(Instance, port, arguments->NativeArgAt(0)); |
| 27 | 33 |
| 28 // Get the port id from the SendPort instance. | 34 // Get the port id from the SendPort instance. |
| 29 const Object& id_obj = Object::Handle(DartLibraryCalls::PortGetId(port)); | 35 const Object& id_obj = Object::Handle(DartLibraryCalls::PortGetId(port)); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args); | 495 Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args); |
| 490 return mirror; | 496 return mirror; |
| 491 } | 497 } |
| 492 | 498 |
| 493 | 499 |
| 494 static Dart_Handle CreateMemberMap(Dart_Handle owner, Dart_Handle owner_mirror); | 500 static Dart_Handle CreateMemberMap(Dart_Handle owner, Dart_Handle owner_mirror); |
| 495 static Dart_Handle CreateConstructorMap(Dart_Handle owner, | 501 static Dart_Handle CreateConstructorMap(Dart_Handle owner, |
| 496 Dart_Handle owner_mirror); | 502 Dart_Handle owner_mirror); |
| 497 | 503 |
| 498 | 504 |
| 499 static Dart_Handle CreateClassMirror(Dart_Handle intf, | 505 static Dart_Handle CreateClassMirrorUsingApi(Dart_Handle intf, |
| 500 Dart_Handle intf_name, | 506 Dart_Handle intf_name, |
| 501 Dart_Handle lib, | 507 Dart_Handle lib, |
| 502 Dart_Handle lib_mirror) { | 508 Dart_Handle lib_mirror) { |
| 503 ASSERT(Dart_IsClass(intf)); | 509 ASSERT(Dart_IsClass(intf)); |
| 504 if (Dart_ClassIsTypedef(intf)) { | 510 if (Dart_ClassIsTypedef(intf)) { |
| 505 // This class is actually a typedef. Represent it specially in | 511 // This class is actually a typedef. Represent it specially in |
| 506 // reflection. | 512 // reflection. |
| 507 return CreateTypedefMirror(intf, intf_name, lib, lib_mirror); | 513 return CreateTypedefMirror(intf, intf_name, lib, lib_mirror); |
| 508 } | 514 } |
| 509 | 515 |
| 510 Dart_Handle cls_name = NewString("_LocalClassMirrorImpl"); | 516 Dart_Handle cls_name = NewString("_LocalClassMirrorImpl"); |
| 511 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); | 517 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 512 if (Dart_IsError(type)) { | 518 if (Dart_IsError(type)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 CreateLazyMirror(default_class), | 556 CreateLazyMirror(default_class), |
| 551 member_map, | 557 member_map, |
| 552 constructor_map, | 558 constructor_map, |
| 553 type_var_map, | 559 type_var_map, |
| 554 }; | 560 }; |
| 555 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 561 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 556 return mirror; | 562 return mirror; |
| 557 } | 563 } |
| 558 | 564 |
| 559 | 565 |
| 560 static Dart_Handle CreateMethodMirror(Dart_Handle func, | 566 static Dart_Handle CreateMethodMirrorUsingApi(Dart_Handle func, |
| 561 Dart_Handle owner_mirror) { | 567 Dart_Handle owner_mirror) { |
| 562 // TODO(11742): Unwrapping is needed until the whole method is converted. | 568 // TODO(11742): Unwrapping is needed until the whole method is converted. |
| 563 Isolate* isolate = Isolate::Current(); | 569 Isolate* isolate = Isolate::Current(); |
| 564 DARTSCOPE(isolate); | 570 DARTSCOPE(isolate); |
| 565 const Function& func_obj = Api::UnwrapFunctionHandle(isolate, func); | 571 const Function& func_obj = Api::UnwrapFunctionHandle(isolate, func); |
| 566 | 572 |
| 567 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); | 573 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); |
| 568 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); | 574 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); |
| 569 if (Dart_IsError(mirror_type)) { | 575 if (Dart_IsError(mirror_type)) { |
| 570 return mirror_type; | 576 return mirror_type; |
| 571 } | 577 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 if (Dart_IsError(result)) { | 656 if (Dart_IsError(result)) { |
| 651 return result; | 657 return result; |
| 652 } | 658 } |
| 653 for (intptr_t i = 0; i < len; i++) { | 659 for (intptr_t i = 0; i < len; i++) { |
| 654 Dart_Handle intf_name = Dart_ListGetAt(names, i); | 660 Dart_Handle intf_name = Dart_ListGetAt(names, i); |
| 655 Dart_Handle intf = Dart_GetClass(owner, intf_name); | 661 Dart_Handle intf = Dart_GetClass(owner, intf_name); |
| 656 if (Dart_IsError(intf)) { | 662 if (Dart_IsError(intf)) { |
| 657 return intf; | 663 return intf; |
| 658 } | 664 } |
| 659 Dart_Handle intf_mirror = | 665 Dart_Handle intf_mirror = |
| 660 CreateClassMirror(intf, intf_name, owner, owner_mirror); | 666 CreateClassMirrorUsingApi(intf, intf_name, owner, owner_mirror); |
| 661 if (Dart_IsError(intf_mirror)) { | 667 if (Dart_IsError(intf_mirror)) { |
| 662 return intf_mirror; | 668 return intf_mirror; |
| 663 } | 669 } |
| 664 result = MapAdd(map, intf_name, intf_mirror); | 670 result = MapAdd(map, intf_name, intf_mirror); |
| 665 if (Dart_IsError(result)) { | 671 if (Dart_IsError(result)) { |
| 666 return result; | 672 return result; |
| 667 } | 673 } |
| 668 } | 674 } |
| 669 return Dart_True(); | 675 return Dart_True(); |
| 670 } | 676 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 694 bool is_constructor = false; | 700 bool is_constructor = false; |
| 695 result = Dart_FunctionIsConstructor(func, &is_constructor); | 701 result = Dart_FunctionIsConstructor(func, &is_constructor); |
| 696 if (Dart_IsError(result)) { | 702 if (Dart_IsError(result)) { |
| 697 return result; | 703 return result; |
| 698 } | 704 } |
| 699 if (is_constructor) { | 705 if (is_constructor) { |
| 700 // Skip constructors. | 706 // Skip constructors. |
| 701 continue; | 707 continue; |
| 702 } | 708 } |
| 703 | 709 |
| 704 Dart_Handle func_mirror = CreateMethodMirror(func, owner_mirror); | 710 Dart_Handle func_mirror = CreateMethodMirrorUsingApi(func, owner_mirror); |
| 705 if (Dart_IsError(func_mirror)) { | 711 if (Dart_IsError(func_mirror)) { |
| 706 return func_mirror; | 712 return func_mirror; |
| 707 } | 713 } |
| 708 result = MapAdd(map, func_name, func_mirror); | 714 result = MapAdd(map, func_name, func_mirror); |
| 709 if (Dart_IsError(result)) { | 715 if (Dart_IsError(result)) { |
| 710 return result; | 716 return result; |
| 711 } | 717 } |
| 712 } | 718 } |
| 713 return Dart_True(); | 719 return Dart_True(); |
| 714 } | 720 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 738 bool is_constructor = false; | 744 bool is_constructor = false; |
| 739 result = Dart_FunctionIsConstructor(func, &is_constructor); | 745 result = Dart_FunctionIsConstructor(func, &is_constructor); |
| 740 if (Dart_IsError(result)) { | 746 if (Dart_IsError(result)) { |
| 741 return result; | 747 return result; |
| 742 } | 748 } |
| 743 if (!is_constructor) { | 749 if (!is_constructor) { |
| 744 // Skip non-constructors. | 750 // Skip non-constructors. |
| 745 continue; | 751 continue; |
| 746 } | 752 } |
| 747 | 753 |
| 748 Dart_Handle func_mirror = CreateMethodMirror(func, owner_mirror); | 754 Dart_Handle func_mirror = CreateMethodMirrorUsingApi(func, owner_mirror); |
| 749 if (Dart_IsError(func_mirror)) { | 755 if (Dart_IsError(func_mirror)) { |
| 750 return func_mirror; | 756 return func_mirror; |
| 751 } | 757 } |
| 752 result = MapAdd(map, func_name, func_mirror); | 758 result = MapAdd(map, func_name, func_mirror); |
| 753 if (Dart_IsError(result)) { | 759 if (Dart_IsError(result)) { |
| 754 return result; | 760 return result; |
| 755 } | 761 } |
| 756 } | 762 } |
| 757 return Dart_True(); | 763 return Dart_True(); |
| 758 } | 764 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 Dart_Handle result; | 832 Dart_Handle result; |
| 827 Dart_Handle map = MapNew(); | 833 Dart_Handle map = MapNew(); |
| 828 result = AddConstructors(map, owner, owner_mirror); | 834 result = AddConstructors(map, owner, owner_mirror); |
| 829 if (Dart_IsError(result)) { | 835 if (Dart_IsError(result)) { |
| 830 return result; | 836 return result; |
| 831 } | 837 } |
| 832 return map; | 838 return map; |
| 833 } | 839 } |
| 834 | 840 |
| 835 | 841 |
| 836 static Dart_Handle CreateLibraryMirror(Dart_Handle lib) { | 842 static Dart_Handle CreateLibraryMirrorUsingApi(Dart_Handle lib) { |
| 837 Dart_Handle cls_name = NewString("_LocalLibraryMirrorImpl"); | 843 Dart_Handle cls_name = NewString("_LocalLibraryMirrorImpl"); |
| 838 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); | 844 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 839 if (Dart_IsError(type)) { | 845 if (Dart_IsError(type)) { |
| 840 return type; | 846 return type; |
| 841 } | 847 } |
| 842 Dart_Handle lazy_lib_mirror = CreateLazyMirror(lib); | 848 Dart_Handle lazy_lib_mirror = CreateLazyMirror(lib); |
| 843 if (Dart_IsError(lazy_lib_mirror)) { | 849 if (Dart_IsError(lazy_lib_mirror)) { |
| 844 return lazy_lib_mirror; | 850 return lazy_lib_mirror; |
| 845 } | 851 } |
| 846 Dart_Handle member_map = CreateMemberMap(lib, lazy_lib_mirror); | 852 Dart_Handle member_map = CreateMemberMap(lib, lazy_lib_mirror); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 881 int64_t id64; | 887 int64_t id64; |
| 882 Dart_IntegerToInt64(lib_id, &id64); | 888 Dart_IntegerToInt64(lib_id, &id64); |
| 883 Dart_Handle lib_url = Dart_GetLibraryURL(id64); | 889 Dart_Handle lib_url = Dart_GetLibraryURL(id64); |
| 884 if (Dart_IsError(lib_url)) { | 890 if (Dart_IsError(lib_url)) { |
| 885 return lib_url; | 891 return lib_url; |
| 886 } | 892 } |
| 887 Dart_Handle lib = Dart_LookupLibrary(lib_url); | 893 Dart_Handle lib = Dart_LookupLibrary(lib_url); |
| 888 if (Dart_IsError(lib)) { | 894 if (Dart_IsError(lib)) { |
| 889 return lib; | 895 return lib; |
| 890 } | 896 } |
| 891 Dart_Handle lib_mirror = CreateLibraryMirror(lib); | 897 Dart_Handle lib_mirror = CreateLibraryMirrorUsingApi(lib); |
| 892 if (Dart_IsError(lib_mirror)) { | 898 if (Dart_IsError(lib_mirror)) { |
| 893 return lib_mirror; | 899 return lib_mirror; |
| 894 } | 900 } |
| 895 result = MapAdd(map, lib_url, lib_mirror); | 901 result = MapAdd(map, lib_url, lib_mirror); |
| 896 } | 902 } |
| 897 return map; | 903 return map; |
| 898 } | 904 } |
| 899 | 905 |
| 900 | 906 |
| 901 static Dart_Handle CreateIsolateMirror() { | 907 static Dart_Handle CreateIsolateMirror() { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 | 989 |
| 984 // TODO(turnidge): Why not use the real function name here? | 990 // TODO(turnidge): Why not use the real function name here? |
| 985 Dart_Handle func_owner = Dart_FunctionOwner(func); | 991 Dart_Handle func_owner = Dart_FunctionOwner(func); |
| 986 if (Dart_IsError(func_owner)) { | 992 if (Dart_IsError(func_owner)) { |
| 987 return func_owner; | 993 return func_owner; |
| 988 } | 994 } |
| 989 | 995 |
| 990 // TODO(turnidge): Pass the function owner here. This will require | 996 // TODO(turnidge): Pass the function owner here. This will require |
| 991 // us to support functions in CreateLazyMirror. | 997 // us to support functions in CreateLazyMirror. |
| 992 Dart_Handle func_mirror = | 998 Dart_Handle func_mirror = |
| 993 CreateMethodMirror(func, Dart_Null()); | 999 CreateMethodMirrorUsingApi(func, Dart_Null()); |
| 994 if (Dart_IsError(func_mirror)) { | 1000 if (Dart_IsError(func_mirror)) { |
| 995 return func_mirror; | 1001 return func_mirror; |
| 996 } | 1002 } |
| 997 Dart_Handle args[] = { | 1003 Dart_Handle args[] = { |
| 998 CreateVMReference(instance), | 1004 CreateVMReference(instance), |
| 999 CreateLazyMirror(instance_cls), | 1005 CreateLazyMirror(instance_cls), |
| 1000 instance, | 1006 instance, |
| 1001 func_mirror, | 1007 func_mirror, |
| 1002 }; | 1008 }; |
| 1003 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 1009 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1004 | 1010 |
| 1005 } else { | 1011 } else { |
| 1006 Dart_Handle cls_name = NewString("_LocalInstanceMirrorImpl"); | 1012 Dart_Handle cls_name = NewString("_LocalInstanceMirrorImpl"); |
| 1007 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); | 1013 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 1008 if (Dart_IsError(type)) { | 1014 if (Dart_IsError(type)) { |
| 1009 return type; | 1015 return type; |
| 1010 } | 1016 } |
| 1011 Dart_Handle args[] = { | 1017 Dart_Handle args[] = { |
| 1012 CreateVMReference(instance), | 1018 CreateVMReference(instance), |
| 1013 CreateLazyMirror(instance_cls), | 1019 CreateLazyMirror(instance_cls), |
| 1014 instance, | 1020 instance, |
| 1015 }; | 1021 }; |
| 1016 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 1022 return Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 1017 } | 1023 } |
| 1018 } | 1024 } |
| 1019 | 1025 |
| 1020 | 1026 |
| 1027 // TODO(11742): At some point the function taking native parameters will replace | |
| 1028 // the version that uses API handles. | |
|
siva
2013/07/18 20:38:45
This comment here is misleading it seems to imply
Michael Lippautz (Google)
2013/07/18 22:01:23
Done.
| |
| 1029 static RawInstance* CreateClassMirror(const Class& cls, | |
| 1030 const Instance& owner_mirror) { | |
| 1031 Dart_EnterScope(); | |
| 1032 Isolate* isolate = Isolate::Current(); | |
| 1033 Dart_Handle cls_handle = Api::NewHandle(isolate, cls.raw()); | |
| 1034 if (Dart_IsError(cls_handle)) { | |
| 1035 Dart_PropagateError(cls_handle); | |
| 1036 } | |
| 1037 Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name()); | |
| 1038 if (Dart_IsError(name_handle)) { | |
| 1039 Dart_PropagateError(name_handle); | |
| 1040 } | |
| 1041 Dart_Handle lib_handle = Api::NewHandle(isolate, cls.library()); | |
| 1042 if (Dart_IsError(lib_handle)) { | |
| 1043 Dart_PropagateError(lib_handle); | |
| 1044 } | |
| 1045 Dart_Handle lib_mirror = CreateLibraryMirrorUsingApi(lib_handle); | |
| 1046 if (Dart_IsError(lib_mirror)) { | |
| 1047 Dart_PropagateError(lib_mirror); | |
| 1048 } | |
| 1049 Dart_Handle result = CreateClassMirrorUsingApi(cls_handle, | |
| 1050 name_handle, | |
| 1051 lib_handle, | |
| 1052 lib_mirror); | |
| 1053 if (Dart_IsError(result)) { | |
| 1054 Dart_PropagateError(result); | |
| 1055 } | |
| 1056 const Instance& retvalue = Api::UnwrapInstanceHandle(isolate, result); | |
| 1057 Dart_ExitScope(); | |
| 1058 return retvalue.raw(); | |
| 1059 } | |
| 1060 | |
| 1061 | |
| 1062 // TODO(11742): At some point the function taking native parameters will replace | |
| 1063 // the version that uses API handles. | |
| 1064 static RawInstance* CreateLibraryMirror(const Library& lib) { | |
| 1065 Dart_EnterScope(); | |
| 1066 Isolate* isolate = Isolate::Current(); | |
| 1067 Dart_Handle lib_handle = Api::NewHandle(isolate, lib.raw()); | |
| 1068 Dart_Handle result = CreateLibraryMirrorUsingApi(lib_handle); | |
| 1069 if (Dart_IsError(result)) { | |
| 1070 Dart_PropagateError(result); | |
| 1071 } | |
| 1072 const Instance& retvalue = Api::UnwrapInstanceHandle(isolate, result); | |
| 1073 Dart_ExitScope(); | |
| 1074 return retvalue.raw(); | |
| 1075 } | |
| 1076 | |
| 1077 | |
| 1078 // TODO(11742): At some point the function taking native parameters will replace | |
| 1079 // the version that uses API handles. | |
| 1080 static RawInstance* CreateMethodMirror(const Function& func, | |
| 1081 const Instance& owner_mirror) { | |
| 1082 Dart_EnterScope(); | |
| 1083 Isolate* isolate = Isolate::Current(); | |
| 1084 Dart_Handle func_handle = Api::NewHandle(isolate, func.raw()); | |
| 1085 Dart_Handle owner_handle = Api::NewHandle(isolate, owner_mirror.raw()); | |
| 1086 Dart_Handle result = CreateMethodMirrorUsingApi(func_handle, owner_handle); | |
| 1087 if (Dart_IsError(result)) { | |
| 1088 Dart_PropagateError(result); | |
| 1089 } | |
| 1090 const Instance& retvalue = Api::UnwrapInstanceHandle(isolate, result); | |
| 1091 Dart_ExitScope(); | |
| 1092 return retvalue.raw(); | |
| 1093 } | |
| 1094 | |
| 1095 | |
| 1021 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( | 1096 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( |
| 1022 Dart_NativeArguments args) { | 1097 Dart_NativeArguments args) { |
| 1023 Dart_EnterScope(); | 1098 Dart_EnterScope(); |
| 1024 Dart_Handle mirrors = CreateMirrorSystem(); | 1099 Dart_Handle mirrors = CreateMirrorSystem(); |
| 1025 if (Dart_IsError(mirrors)) { | 1100 if (Dart_IsError(mirrors)) { |
| 1026 Dart_PropagateError(mirrors); | 1101 Dart_PropagateError(mirrors); |
| 1027 } | 1102 } |
| 1028 Dart_SetReturnValue(args, mirrors); | 1103 Dart_SetReturnValue(args, mirrors); |
| 1029 Dart_ExitScope(); | 1104 Dart_ExitScope(); |
| 1030 } | 1105 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1058 Dart_PropagateError(cls_handle); | 1133 Dart_PropagateError(cls_handle); |
| 1059 } | 1134 } |
| 1060 Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name()); | 1135 Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name()); |
| 1061 if (Dart_IsError(name_handle)) { | 1136 if (Dart_IsError(name_handle)) { |
| 1062 Dart_PropagateError(name_handle); | 1137 Dart_PropagateError(name_handle); |
| 1063 } | 1138 } |
| 1064 Dart_Handle lib_handle = Api::NewHandle(isolate, cls.library()); | 1139 Dart_Handle lib_handle = Api::NewHandle(isolate, cls.library()); |
| 1065 if (Dart_IsError(lib_handle)) { | 1140 if (Dart_IsError(lib_handle)) { |
| 1066 Dart_PropagateError(lib_handle); | 1141 Dart_PropagateError(lib_handle); |
| 1067 } | 1142 } |
| 1068 Dart_Handle lib_mirror = CreateLibraryMirror(lib_handle); | 1143 Dart_Handle lib_mirror = CreateLibraryMirrorUsingApi(lib_handle); |
| 1069 if (Dart_IsError(lib_mirror)) { | 1144 if (Dart_IsError(lib_mirror)) { |
| 1070 Dart_PropagateError(lib_mirror); | 1145 Dart_PropagateError(lib_mirror); |
| 1071 } | 1146 } |
| 1072 Dart_Handle result = CreateClassMirror(cls_handle, | 1147 Dart_Handle result = CreateClassMirrorUsingApi(cls_handle, |
| 1073 name_handle, | 1148 name_handle, |
| 1074 lib_handle, | 1149 lib_handle, |
| 1075 lib_mirror); | 1150 lib_mirror); |
| 1076 if (Dart_IsError(result)) { | 1151 if (Dart_IsError(result)) { |
| 1077 Dart_PropagateError(result); | 1152 Dart_PropagateError(result); |
| 1078 } | 1153 } |
| 1079 Dart_SetReturnValue(args, result); | 1154 Dart_SetReturnValue(args, result); |
| 1080 Dart_ExitScope(); | 1155 Dart_ExitScope(); |
| 1081 } | 1156 } |
| 1082 | 1157 |
| 1083 void NATIVE_ENTRY_FUNCTION(Mirrors_metadata)(Dart_NativeArguments args) { | 1158 void NATIVE_ENTRY_FUNCTION(Mirrors_metadata)(Dart_NativeArguments args) { |
| 1084 Dart_EnterScope(); | 1159 Dart_EnterScope(); |
| 1085 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); | 1160 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1784 | 1859 |
| 1785 | 1860 |
| 1786 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { | 1861 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { |
| 1787 const MirrorReference& func_ref = | 1862 const MirrorReference& func_ref = |
| 1788 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | 1863 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); |
| 1789 Function& func = Function::Handle(); | 1864 Function& func = Function::Handle(); |
| 1790 func ^= func_ref.referent(); | 1865 func ^= func_ref.referent(); |
| 1791 return func.UserVisibleName(); | 1866 return func.UserVisibleName(); |
| 1792 } | 1867 } |
| 1793 | 1868 |
| 1869 | |
| 1870 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 1) { | |
| 1871 const MirrorReference& func_ref = | |
| 1872 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | |
| 1873 Function& func = Function::Handle(); | |
| 1874 func ^= func_ref.referent(); | |
| 1875 if (func.IsNonImplicitClosureFunction()) { | |
| 1876 return CreateMethodMirror(Function::Handle( | |
| 1877 func.parent_function()), Instance::Handle()); | |
| 1878 } | |
| 1879 const Class& owner = Class::Handle(func.Owner()); | |
| 1880 if (owner.IsTopLevel()) { | |
| 1881 return CreateLibraryMirror(Library::Handle(owner.library())); | |
| 1882 } | |
| 1883 return CreateClassMirror(owner, Instance::Handle()); | |
| 1884 } | |
| 1885 | |
| 1794 } // namespace dart | 1886 } // namespace dart |
| OLD | NEW |