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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 11141020: Fix bug 5002: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "platform/json.h" 7 #include "platform/json.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 return Dart_NewUnhandledExceptionError(mirrored_exc); 1015 return Dart_NewUnhandledExceptionError(mirrored_exc);
1016 } else { 1016 } else {
1017 ASSERT(Dart_IsFatalError(error)); 1017 ASSERT(Dart_IsFatalError(error));
1018 return error; 1018 return error;
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 1022
1023 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( 1023 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)(
1024 Dart_NativeArguments args) { 1024 Dart_NativeArguments args) {
1025 Dart_EnterScope();
1025 Dart_Handle mirrors = CreateMirrorSystem(); 1026 Dart_Handle mirrors = CreateMirrorSystem();
1026 if (Dart_IsError(mirrors)) { 1027 if (Dart_IsError(mirrors)) {
1027 Dart_PropagateError(mirrors); 1028 Dart_PropagateError(mirrors);
1028 } 1029 }
1029 Dart_SetReturnValue(args, mirrors); 1030 Dart_SetReturnValue(args, mirrors);
1031 Dart_ExitScope();
1030 } 1032 }
1031 1033
1032 1034
1033 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalInstanceMirror)( 1035 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalInstanceMirror)(
1034 Dart_NativeArguments args) { 1036 Dart_NativeArguments args) {
1037 Dart_EnterScope();
1035 Dart_Handle reflectee = Dart_GetNativeArgument(args, 0); 1038 Dart_Handle reflectee = Dart_GetNativeArgument(args, 0);
1036 Dart_Handle mirror = CreateInstanceMirror(reflectee); 1039 Dart_Handle mirror = CreateInstanceMirror(reflectee);
1037 if (Dart_IsError(mirror)) { 1040 if (Dart_IsError(mirror)) {
1038 Dart_PropagateError(mirror); 1041 Dart_PropagateError(mirror);
1039 } 1042 }
1040 Dart_SetReturnValue(args, mirror); 1043 Dart_SetReturnValue(args, mirror);
1044 Dart_ExitScope();
1041 } 1045 }
1042 1046
1043 1047
1044 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invoke)( 1048 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invoke)(
1045 Dart_NativeArguments args) { 1049 Dart_NativeArguments args) {
1050 Dart_EnterScope();
1046 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); 1051 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1047 Dart_Handle member = Dart_GetNativeArgument(args, 1); 1052 Dart_Handle member = Dart_GetNativeArgument(args, 1);
1048 // The wrapped arguments are either simple values or instance mirrors. 1053 // The wrapped arguments are either simple values or instance mirrors.
1049 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2); 1054 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2);
1050 1055
1051 Dart_Handle reflectee = UnwrapMirror(mirror); 1056 Dart_Handle reflectee = UnwrapMirror(mirror);
1052 GrowableArray<Dart_Handle> invoke_args; 1057 GrowableArray<Dart_Handle> invoke_args;
1053 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args); 1058 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args);
1054 if (Dart_IsError(result)) { 1059 if (Dart_IsError(result)) {
1055 Dart_PropagateError(result); 1060 Dart_PropagateError(result);
1056 } 1061 }
1057 result = 1062 result =
1058 Dart_Invoke(reflectee, member, invoke_args.length(), invoke_args.data()); 1063 Dart_Invoke(reflectee, member, invoke_args.length(), invoke_args.data());
1059 if (Dart_IsError(result)) { 1064 if (Dart_IsError(result)) {
1060 // Instead of propagating the error from an invoke directly, we 1065 // Instead of propagating the error from an invoke directly, we
1061 // provide reflective access to the error. 1066 // provide reflective access to the error.
1062 Dart_PropagateError(CreateMirroredError(result)); 1067 Dart_PropagateError(CreateMirroredError(result));
1063 } 1068 }
1064 1069
1065 Dart_Handle wrapped_result = CreateInstanceMirror(result); 1070 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1066 if (Dart_IsError(wrapped_result)) { 1071 if (Dart_IsError(wrapped_result)) {
1067 Dart_PropagateError(wrapped_result); 1072 Dart_PropagateError(wrapped_result);
1068 } 1073 }
1069 Dart_SetReturnValue(args, wrapped_result); 1074 Dart_SetReturnValue(args, wrapped_result);
1075 Dart_ExitScope();
1070 } 1076 }
1071 1077
1072 1078
1073 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_getField)( 1079 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_getField)(
1074 Dart_NativeArguments args) { 1080 Dart_NativeArguments args) {
1081 Dart_EnterScope();
1075 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); 1082 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1076 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1); 1083 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
1077 1084
1078 Dart_Handle reflectee = UnwrapMirror(mirror); 1085 Dart_Handle reflectee = UnwrapMirror(mirror);
1079 Dart_Handle result = Dart_GetField(reflectee, fieldName); 1086 Dart_Handle result = Dart_GetField(reflectee, fieldName);
1080 if (Dart_IsError(result)) { 1087 if (Dart_IsError(result)) {
1081 // Instead of propagating the error from a GetField directly, we 1088 // Instead of propagating the error from a GetField directly, we
1082 // provide reflective access to the error. 1089 // provide reflective access to the error.
1083 Dart_PropagateError(CreateMirroredError(result)); 1090 Dart_PropagateError(CreateMirroredError(result));
1084 } 1091 }
1085 1092
1086 Dart_Handle wrapped_result = CreateInstanceMirror(result); 1093 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1087 if (Dart_IsError(wrapped_result)) { 1094 if (Dart_IsError(wrapped_result)) {
1088 Dart_PropagateError(wrapped_result); 1095 Dart_PropagateError(wrapped_result);
1089 } 1096 }
1090 Dart_SetReturnValue(args, wrapped_result); 1097 Dart_SetReturnValue(args, wrapped_result);
1098 Dart_ExitScope();
1091 } 1099 }
1092 1100
1093 1101
1094 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setField)( 1102 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setField)(
1095 Dart_NativeArguments args) { 1103 Dart_NativeArguments args) {
1104 Dart_EnterScope();
1096 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); 1105 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1097 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1); 1106 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
1098 // The wrapped argument is either a simple value or instance mirror. 1107 // The wrapped argument is either a simple value or instance mirror.
1099 Dart_Handle wrapped_arg = Dart_GetNativeArgument(args, 2); 1108 Dart_Handle wrapped_arg = Dart_GetNativeArgument(args, 2);
1100 1109
1101 Dart_Handle reflectee = UnwrapMirror(mirror); 1110 Dart_Handle reflectee = UnwrapMirror(mirror);
1102 Dart_Handle set_arg = UnwrapArg(wrapped_arg); 1111 Dart_Handle set_arg = UnwrapArg(wrapped_arg);
1103 if (Dart_IsError(set_arg)) { 1112 if (Dart_IsError(set_arg)) {
1104 Dart_PropagateError(set_arg); 1113 Dart_PropagateError(set_arg);
1105 } 1114 }
1106 Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg); 1115 Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg);
1107 if (Dart_IsError(result)) { 1116 if (Dart_IsError(result)) {
1108 // Instead of propagating the error from a SetField directly, we 1117 // Instead of propagating the error from a SetField directly, we
1109 // provide reflective access to the error. 1118 // provide reflective access to the error.
1110 Dart_PropagateError(CreateMirroredError(result)); 1119 Dart_PropagateError(CreateMirroredError(result));
1111 } 1120 }
1112 1121
1113 Dart_Handle wrapped_result = CreateInstanceMirror(result); 1122 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1114 if (Dart_IsError(wrapped_result)) { 1123 if (Dart_IsError(wrapped_result)) {
1115 Dart_PropagateError(wrapped_result); 1124 Dart_PropagateError(wrapped_result);
1116 } 1125 }
1117 Dart_SetReturnValue(args, wrapped_result); 1126 Dart_SetReturnValue(args, wrapped_result);
1127 Dart_ExitScope();
1118 } 1128 }
1119 1129
1120 1130
1121 void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_apply)( 1131 void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_apply)(
1122 Dart_NativeArguments args) { 1132 Dart_NativeArguments args) {
1133 Dart_EnterScope();
1123 Dart_Handle mirror = Dart_GetNativeArgument(args, 0); 1134 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1124 // The wrapped arguments are either simple values or instance mirrors. 1135 // The wrapped arguments are either simple values or instance mirrors.
1125 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 1); 1136 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 1);
1126 1137
1127 Dart_Handle reflectee = UnwrapMirror(mirror); 1138 Dart_Handle reflectee = UnwrapMirror(mirror);
1128 GrowableArray<Dart_Handle> invoke_args; 1139 GrowableArray<Dart_Handle> invoke_args;
1129 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args); 1140 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args);
1130 if (Dart_IsError(result)) { 1141 if (Dart_IsError(result)) {
1131 Dart_PropagateError(result); 1142 Dart_PropagateError(result);
1132 } 1143 }
1133 result = 1144 result =
1134 Dart_InvokeClosure(reflectee, invoke_args.length(), invoke_args.data()); 1145 Dart_InvokeClosure(reflectee, invoke_args.length(), invoke_args.data());
1135 if (Dart_IsError(result)) { 1146 if (Dart_IsError(result)) {
1136 // Instead of propagating the error from an apply directly, we 1147 // Instead of propagating the error from an apply directly, we
1137 // provide reflective access to the error. 1148 // provide reflective access to the error.
1138 Dart_PropagateError(CreateMirroredError(result)); 1149 Dart_PropagateError(CreateMirroredError(result));
1139 } 1150 }
1140 1151
1141 Dart_Handle wrapped_result = CreateInstanceMirror(result); 1152 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1142 if (Dart_IsError(wrapped_result)) { 1153 if (Dart_IsError(wrapped_result)) {
1143 Dart_PropagateError(wrapped_result); 1154 Dart_PropagateError(wrapped_result);
1144 } 1155 }
1145 Dart_SetReturnValue(args, wrapped_result); 1156 Dart_SetReturnValue(args, wrapped_result);
1157 Dart_ExitScope();
1146 } 1158 }
1147 1159
1148 1160
1149 void NATIVE_ENTRY_FUNCTION(LocalClassMirrorImpl_invokeConstructor)( 1161 void NATIVE_ENTRY_FUNCTION(LocalClassMirrorImpl_invokeConstructor)(
1150 Dart_NativeArguments args) { 1162 Dart_NativeArguments args) {
1163 Dart_EnterScope();
1151 Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0); 1164 Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0);
1152 Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1); 1165 Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1);
1153 // The wrapped arguments are either simple values or instance mirrors. 1166 // The wrapped arguments are either simple values or instance mirrors.
1154 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2); 1167 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2);
1155 1168
1156 Dart_Handle klass = UnwrapMirror(klass_mirror); 1169 Dart_Handle klass = UnwrapMirror(klass_mirror);
1157 GrowableArray<Dart_Handle> invoke_args; 1170 GrowableArray<Dart_Handle> invoke_args;
1158 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args); 1171 Dart_Handle result = UnwrapArgList(wrapped_invoke_args, &invoke_args);
1159 if (Dart_IsError(result)) { 1172 if (Dart_IsError(result)) {
1160 Dart_PropagateError(result); 1173 Dart_PropagateError(result);
1161 } 1174 }
1162 result = Dart_New(klass, 1175 result = Dart_New(klass,
1163 constructor_name, 1176 constructor_name,
1164 invoke_args.length(), 1177 invoke_args.length(),
1165 invoke_args.data()); 1178 invoke_args.data());
1166 if (Dart_IsError(result)) { 1179 if (Dart_IsError(result)) {
1167 // Instead of propagating the error from an invoke directly, we 1180 // Instead of propagating the error from an invoke directly, we
1168 // provide reflective access to the error. 1181 // provide reflective access to the error.
1169 Dart_PropagateError(CreateMirroredError(result)); 1182 Dart_PropagateError(CreateMirroredError(result));
1170 } 1183 }
1171 1184
1172 Dart_Handle wrapped_result = CreateInstanceMirror(result); 1185 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1173 if (Dart_IsError(wrapped_result)) { 1186 if (Dart_IsError(wrapped_result)) {
1174 Dart_PropagateError(wrapped_result); 1187 Dart_PropagateError(wrapped_result);
1175 } 1188 }
1176 Dart_SetReturnValue(args, wrapped_result); 1189 Dart_SetReturnValue(args, wrapped_result);
1190 Dart_ExitScope();
1177 } 1191 }
1178 1192
1179 1193
1180 void HandleMirrorsMessage(Isolate* isolate, 1194 void HandleMirrorsMessage(Isolate* isolate,
1181 Dart_Port reply_port, 1195 Dart_Port reply_port,
1182 const Instance& message) { 1196 const Instance& message) {
1183 UNIMPLEMENTED(); 1197 UNIMPLEMENTED();
1184 } 1198 }
1185 1199
1186 } // namespace dart 1200 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698