Chromium Code Reviews| Index: runtime/lib/mirrors.cc |
| =================================================================== |
| --- runtime/lib/mirrors.cc (revision 25325) |
| +++ runtime/lib/mirrors.cc (working copy) |
| @@ -537,10 +537,6 @@ |
| if (Dart_IsError(intf_mirror)) { |
| return intf_mirror; |
| } |
| - Dart_Handle member_map = CreateMemberMap(intf, intf_mirror); |
| - if (Dart_IsError(member_map)) { |
| - return member_map; |
| - } |
| Dart_Handle constructor_map = CreateConstructorMap(intf, intf_mirror); |
| if (Dart_IsError(constructor_map)) { |
| return constructor_map; |
| @@ -558,7 +554,6 @@ |
| CreateLazyMirror(super_class), |
| CreateImplementsList(intf), |
| CreateLazyMirror(default_class), |
| - member_map, |
| constructor_map, |
| type_var_map, |
| }; |
| @@ -1313,6 +1308,51 @@ |
| } |
| +DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { |
|
rmacnak
2013/07/23 01:15:37
I intend to adapt this to be shared with LibraryMi
|
| + GET_NON_NULL_NATIVE_ARGUMENT(Instance, |
| + owner_mirror, |
| + arguments->NativeArgAt(0)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
| + const Class& klass = Class::Handle(ref.GetClassReferent()); |
| + |
| + const Array& fields = Array::Handle(klass.fields()); |
| + // Some special types like 'dynamic' have a null fields list, but they should |
| + // not wind up as the reflectees of ClassMirrors. |
|
siva
2013/07/23 21:14:39
One way to avoid this could be to store empty_arra
rmacnak
2013/07/23 22:57:34
Hm. This irregularity also affects LookupField/Loo
siva
2013/07/23 23:37:07
Need to debug this.
On 2013/07/23 22:57:34, Ryan
|
| + ASSERT(!fields.IsNull()); |
| + const intptr_t num_fields = fields.Length(); |
| + |
| + const Array& functions = Array::Handle(klass.functions()); |
| + // Some special types like 'dynamic' have a null functions list, but they |
| + // should not wind up as the reflectees of ClassMirrors. |
| + ASSERT(!functions.IsNull()); |
|
siva
2013/07/23 21:14:39
Ditto about storing empty_array() for functions.
|
| + const intptr_t num_functions = functions.Length(); |
| + |
| + Instance& member_mirror = Instance::Handle(); |
| + const GrowableObjectArray& member_mirrors = GrowableObjectArray::Handle( |
| + GrowableObjectArray::New(num_fields + num_functions)); |
|
siva
2013/07/23 21:14:39
Since you now the exact number of fields and funct
rmacnak
2013/07/23 22:57:34
We know an upper bound. Some of the functions are
siva
2013/07/23 23:37:07
True but the GrowableArray is going to allocate a
|
| + |
| + Field& field = Field::Handle(); |
| + for (intptr_t i = 0; i < num_fields; i++) { |
| + field ^= fields.At(i); |
| + member_mirror = CreateVariableMirror(field, owner_mirror); |
| + member_mirrors.Add(member_mirror); |
| + } |
| + |
| + Function& func = Function::Handle(); |
| + for (intptr_t i = 0; i < num_functions; i++) { |
| + func ^= functions.At(i); |
| + if (func.kind() == RawFunction::kRegularFunction || |
| + func.kind() == RawFunction::kGetterFunction || |
| + func.kind() == RawFunction::kSetterFunction) { |
| + member_mirror = CreateMethodMirror(func, owner_mirror); |
| + member_mirrors.Add(member_mirror); |
| + } |
| + } |
| + |
| + return member_mirrors.raw(); |
| +} |
| + |
| + |
| // Invoke the function, or noSuchMethod if it is null. Propagate any unhandled |
| // exceptions. Wrap and propagate any compilation errors. |
| static RawObject* ReflectivelyInvokeDynamicFunction(const Instance& receiver, |