| 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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 Dart_PropagateError(mirror); | 801 Dart_PropagateError(mirror); |
| 802 } | 802 } |
| 803 Dart_SetReturnValue(args, mirror); | 803 Dart_SetReturnValue(args, mirror); |
| 804 } | 804 } |
| 805 | 805 |
| 806 | 806 |
| 807 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invoke)( | 807 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invoke)( |
| 808 Dart_NativeArguments args) { | 808 Dart_NativeArguments args) { |
| 809 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); | 809 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
| 810 Dart_Handle member = Dart_GetNativeArgument(args, 1); | 810 Dart_Handle member = Dart_GetNativeArgument(args, 1); |
| 811 Dart_Handle raw_invoke_args = Dart_GetNativeArgument(args, 2); | 811 // The wrapped arguments are either simple values or instance mirrors. |
| 812 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2); |
| 812 | 813 |
| 813 Dart_Handle reflectee = UnwrapMirror(mirror); | 814 Dart_Handle reflectee = UnwrapMirror(mirror); |
| 814 GrowableArray<Dart_Handle> invoke_args; | 815 GrowableArray<Dart_Handle> invoke_args; |
| 815 Dart_Handle result = UnwrapArgList(raw_invoke_args, &invoke_args); | 816 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args); |
| 816 if (Dart_IsError(result)) { | 817 if (Dart_IsError(result)) { |
| 817 Dart_PropagateError(result); | 818 Dart_PropagateError(result); |
| 818 } | 819 } |
| 819 result = | 820 result = |
| 820 Dart_Invoke(reflectee, member, invoke_args.length(), invoke_args.data()); | 821 Dart_Invoke(reflectee, member, invoke_args.length(), invoke_args.data()); |
| 821 if (Dart_IsError(result)) { | 822 if (Dart_IsError(result)) { |
| 822 // Instead of propagating the error from an invoke directly, we | 823 // Instead of propagating the error from an invoke directly, we |
| 823 // provide reflective access to the error. | 824 // provide reflective access to the error. |
| 824 Dart_PropagateError(CreateMirroredError(result)); | 825 Dart_PropagateError(CreateMirroredError(result)); |
| 825 } | 826 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 850 Dart_PropagateError(wrapped_result); | 851 Dart_PropagateError(wrapped_result); |
| 851 } | 852 } |
| 852 Dart_SetReturnValue(args, wrapped_result); | 853 Dart_SetReturnValue(args, wrapped_result); |
| 853 } | 854 } |
| 854 | 855 |
| 855 | 856 |
| 856 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setField)( | 857 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setField)( |
| 857 Dart_NativeArguments args) { | 858 Dart_NativeArguments args) { |
| 858 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); | 859 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
| 859 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1); | 860 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1); |
| 860 Dart_Handle raw_arg = Dart_GetNativeArgument(args, 2); | 861 // The wrapped argument is either a simple value or instance mirror. |
| 862 Dart_Handle wrapped_arg = Dart_GetNativeArgument(args, 2); |
| 861 | 863 |
| 862 Dart_Handle reflectee = UnwrapMirror(mirror); | 864 Dart_Handle reflectee = UnwrapMirror(mirror); |
| 863 Dart_Handle set_arg = UnwrapArg(raw_arg); | 865 Dart_Handle set_arg = UnwrapArg(wrapped_arg); |
| 864 if (Dart_IsError(set_arg)) { | 866 if (Dart_IsError(set_arg)) { |
| 865 Dart_PropagateError(set_arg); | 867 Dart_PropagateError(set_arg); |
| 866 } | 868 } |
| 867 Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg); | 869 Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg); |
| 868 if (Dart_IsError(result)) { | 870 if (Dart_IsError(result)) { |
| 869 // Instead of propagating the error from a SetField directly, we | 871 // Instead of propagating the error from a SetField directly, we |
| 870 // provide reflective access to the error. | 872 // provide reflective access to the error. |
| 871 Dart_PropagateError(CreateMirroredError(result)); | 873 Dart_PropagateError(CreateMirroredError(result)); |
| 872 } | 874 } |
| 873 | 875 |
| 874 Dart_Handle wrapped_result = CreateInstanceMirror(result); | 876 Dart_Handle wrapped_result = CreateInstanceMirror(result); |
| 875 if (Dart_IsError(wrapped_result)) { | 877 if (Dart_IsError(wrapped_result)) { |
| 876 Dart_PropagateError(wrapped_result); | 878 Dart_PropagateError(wrapped_result); |
| 877 } | 879 } |
| 878 Dart_SetReturnValue(args, wrapped_result); | 880 Dart_SetReturnValue(args, wrapped_result); |
| 879 } | 881 } |
| 880 | 882 |
| 881 | 883 |
| 882 void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_apply)( | 884 void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_apply)( |
| 883 Dart_NativeArguments args) { | 885 Dart_NativeArguments args) { |
| 884 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); | 886 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
| 885 Dart_Handle raw_invoke_args = Dart_GetNativeArgument(args, 1); | 887 // The wrapped arguments are either simple values or instance mirrors. |
| 888 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 1); |
| 886 | 889 |
| 887 Dart_Handle reflectee = UnwrapMirror(mirror); | 890 Dart_Handle reflectee = UnwrapMirror(mirror); |
| 888 GrowableArray<Dart_Handle> invoke_args; | 891 GrowableArray<Dart_Handle> invoke_args; |
| 889 Dart_Handle result = UnwrapArgList(raw_invoke_args, &invoke_args); | 892 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args); |
| 890 if (Dart_IsError(result)) { | 893 if (Dart_IsError(result)) { |
| 891 Dart_PropagateError(result); | 894 Dart_PropagateError(result); |
| 892 } | 895 } |
| 893 result = | 896 result = |
| 894 Dart_InvokeClosure(reflectee, invoke_args.length(), invoke_args.data()); | 897 Dart_InvokeClosure(reflectee, invoke_args.length(), invoke_args.data()); |
| 895 if (Dart_IsError(result)) { | 898 if (Dart_IsError(result)) { |
| 896 // Instead of propagating the error from an apply directly, we | 899 // Instead of propagating the error from an apply directly, we |
| 897 // provide reflective access to the error. | 900 // provide reflective access to the error. |
| 898 Dart_PropagateError(CreateMirroredError(result)); | 901 Dart_PropagateError(CreateMirroredError(result)); |
| 899 } | 902 } |
| 900 | 903 |
| 901 Dart_Handle wrapped_result = CreateInstanceMirror(result); | 904 Dart_Handle wrapped_result = CreateInstanceMirror(result); |
| 902 if (Dart_IsError(wrapped_result)) { | 905 if (Dart_IsError(wrapped_result)) { |
| 903 Dart_PropagateError(wrapped_result); | 906 Dart_PropagateError(wrapped_result); |
| 904 } | 907 } |
| 905 Dart_SetReturnValue(args, wrapped_result); | 908 Dart_SetReturnValue(args, wrapped_result); |
| 906 } | 909 } |
| 907 | 910 |
| 908 | 911 |
| 909 void NATIVE_ENTRY_FUNCTION(LocalInterfaceMirrorImpl_invokeConstructor)( | 912 void NATIVE_ENTRY_FUNCTION(LocalInterfaceMirrorImpl_invokeConstructor)( |
| 910 Dart_NativeArguments args) { | 913 Dart_NativeArguments args) { |
| 911 Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0); | 914 Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0); |
| 912 Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1); | 915 Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1); |
| 913 Dart_Handle wrapped_args = Dart_GetNativeArgument(args, 2); | 916 // The wrapped arguments are either simple values or instance mirrors. |
| 917 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2); |
| 914 | 918 |
| 915 Dart_Handle klass = UnwrapMirror(klass_mirror); | 919 Dart_Handle klass = UnwrapMirror(klass_mirror); |
| 916 GrowableArray<Dart_Handle> invoke_args; | 920 GrowableArray<Dart_Handle> invoke_args; |
| 917 Dart_Handle result = UnwrapArgList(wrapped_args, &invoke_args); | 921 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args); |
| 918 if (Dart_IsError(result)) { | 922 if (Dart_IsError(result)) { |
| 919 Dart_PropagateError(result); | 923 Dart_PropagateError(result); |
| 920 } | 924 } |
| 921 result = Dart_New(klass, | 925 result = Dart_New(klass, |
| 922 constructor_name, | 926 constructor_name, |
| 923 invoke_args.length(), | 927 invoke_args.length(), |
| 924 invoke_args.data()); | 928 invoke_args.data()); |
| 925 if (Dart_IsError(result)) { | 929 if (Dart_IsError(result)) { |
| 926 // Instead of propagating the error from an invoke directly, we | 930 // Instead of propagating the error from an invoke directly, we |
| 927 // provide reflective access to the error. | 931 // provide reflective access to the error. |
| 928 Dart_PropagateError(CreateMirroredError(result)); | 932 Dart_PropagateError(CreateMirroredError(result)); |
| 929 } | 933 } |
| 930 | 934 |
| 931 Dart_Handle wrapped_result = CreateInstanceMirror(result); | 935 Dart_Handle wrapped_result = CreateInstanceMirror(result); |
| 932 if (Dart_IsError(wrapped_result)) { | 936 if (Dart_IsError(wrapped_result)) { |
| 933 Dart_PropagateError(wrapped_result); | 937 Dart_PropagateError(wrapped_result); |
| 934 } | 938 } |
| 935 Dart_SetReturnValue(args, wrapped_result); | 939 Dart_SetReturnValue(args, wrapped_result); |
| 936 } | 940 } |
| 937 | 941 |
| 938 | 942 |
| 939 void HandleMirrorsMessage(Isolate* isolate, | 943 void HandleMirrorsMessage(Isolate* isolate, |
| 940 Dart_Port reply_port, | 944 Dart_Port reply_port, |
| 941 const Instance& message) { | 945 const Instance& message) { |
| 942 UNIMPLEMENTED(); | 946 UNIMPLEMENTED(); |
| 943 } | 947 } |
| 944 | 948 |
| 945 } // namespace dart | 949 } // namespace dart |
| OLD | NEW |