| Index: runtime/lib/mirrors.cc
|
| ===================================================================
|
| --- runtime/lib/mirrors.cc (revision 9823)
|
| +++ runtime/lib/mirrors.cc (working copy)
|
| @@ -164,31 +164,39 @@
|
| }
|
|
|
|
|
| -static Dart_Handle UnwrapArgList(Dart_Handle arg_list,
|
| - GrowableArray<Dart_Handle>* arg_array) {
|
| - intptr_t len = 0;
|
| - Dart_Handle result = Dart_ListLength(arg_list, &len);
|
| - if (Dart_IsError(result)) {
|
| - return result;
|
| - }
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle arg = Dart_ListGetAt(arg_list, i);
|
| +static Dart_Handle UnwrapArg(Dart_Handle arg) {
|
| if (Dart_IsError(arg)) {
|
| return arg;
|
| }
|
| bool is_mirror = false;
|
| - result = IsMirror(arg, &is_mirror);
|
| + Dart_Handle result = IsMirror(arg, &is_mirror);
|
| if (Dart_IsError(result)) {
|
| return result;
|
| }
|
| if (is_mirror) {
|
| - arg_array->Add(UnwrapMirror(arg));
|
| + return UnwrapMirror(arg);
|
| } else {
|
| // Simple value.
|
| ASSERT(IsSimpleValue(arg));
|
| - arg_array->Add(arg);
|
| + return arg;
|
| }
|
| +}
|
| +
|
| +static Dart_Handle UnwrapArgList(Dart_Handle arg_list,
|
| + GrowableArray<Dart_Handle>* arg_array) {
|
| + intptr_t len = 0;
|
| + Dart_Handle result = Dart_ListLength(arg_list, &len);
|
| + if (Dart_IsError(result)) {
|
| + return result;
|
| }
|
| + for (int i = 0; i < len; i++) {
|
| + Dart_Handle arg = Dart_ListGetAt(arg_list, i);
|
| + Dart_Handle unwrapped_arg = UnwrapArg(arg);
|
| + if (Dart_IsError(unwrapped_arg)) {
|
| + return unwrapped_arg;
|
| + }
|
| + arg_array->Add(unwrapped_arg);
|
| + }
|
| return Dart_True();
|
| }
|
|
|
| @@ -761,6 +769,7 @@
|
| Dart_SetReturnValue(args, mirrors);
|
| }
|
|
|
| +
|
| void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalInstanceMirror)(
|
| Dart_NativeArguments args) {
|
| Dart_Handle reflectee = Dart_GetNativeArgument(args, 0);
|
| @@ -771,6 +780,7 @@
|
| Dart_SetReturnValue(args, mirror);
|
| }
|
|
|
| +
|
| void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invoke)(
|
| Dart_NativeArguments args) {
|
| Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
|
| @@ -798,6 +808,54 @@
|
| Dart_SetReturnValue(args, wrapped_result);
|
| }
|
|
|
| +
|
| +void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_getField)(
|
| + Dart_NativeArguments args) {
|
| + Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
|
| + Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
|
| +
|
| + Dart_Handle reflectee = UnwrapMirror(mirror);
|
| + Dart_Handle result = Dart_GetField(reflectee, fieldName);
|
| + if (Dart_IsError(result)) {
|
| + // Instead of propagating the error from a GetField directly, we
|
| + // provide reflective access to the error.
|
| + Dart_PropagateError(CreateMirroredError(result));
|
| + }
|
| +
|
| + Dart_Handle wrapped_result = CreateInstanceMirror(result);
|
| + if (Dart_IsError(wrapped_result)) {
|
| + Dart_PropagateError(wrapped_result);
|
| + }
|
| + Dart_SetReturnValue(args, wrapped_result);
|
| +}
|
| +
|
| +
|
| +void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setField)(
|
| + Dart_NativeArguments args) {
|
| + Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
|
| + Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
|
| + Dart_Handle raw_arg = Dart_GetNativeArgument(args, 2);
|
| +
|
| + Dart_Handle reflectee = UnwrapMirror(mirror);
|
| + Dart_Handle set_arg = UnwrapArg(raw_arg);
|
| + if (Dart_IsError(set_arg)) {
|
| + Dart_PropagateError(set_arg);
|
| + }
|
| + Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg);
|
| + if (Dart_IsError(result)) {
|
| + // Instead of propagating the error from a SetField directly, we
|
| + // provide reflective access to the error.
|
| + Dart_PropagateError(CreateMirroredError(result));
|
| + }
|
| +
|
| + Dart_Handle wrapped_result = CreateInstanceMirror(result);
|
| + if (Dart_IsError(wrapped_result)) {
|
| + Dart_PropagateError(wrapped_result);
|
| + }
|
| + Dart_SetReturnValue(args, wrapped_result);
|
| +}
|
| +
|
| +
|
| void HandleMirrorsMessage(Isolate* isolate,
|
| Dart_Port reply_port,
|
| const Instance& message) {
|
|
|