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

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

Issue 21430002: Allow InstanceMirror.invoke to find private members. Resolves issue 11771. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | tests/lib/lib.status » ('j') | tests/lib/mirrors/invoke_private_test.dart » ('J')
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 "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"
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 Array::Handle(Array::New(number_of_arguments + 1)); // Plus receiver. 726 Array::Handle(Array::New(number_of_arguments + 1)); // Plus receiver.
727 Object& arg = Object::Handle(); 727 Object& arg = Object::Handle();
728 args.SetAt(0, reflectee); 728 args.SetAt(0, reflectee);
729 for (int i = 0; i < number_of_arguments; i++) { 729 for (int i = 0; i < number_of_arguments; i++) {
730 arg = positional_args.At(i); 730 arg = positional_args.At(i);
731 args.SetAt(i + 1, arg); // Plus receiver. 731 args.SetAt(i + 1, arg); // Plus receiver.
732 } 732 }
733 733
734 ArgumentsDescriptor args_desc( 734 ArgumentsDescriptor args_desc(
735 Array::Handle(ArgumentsDescriptor::New(args.Length()))); 735 Array::Handle(ArgumentsDescriptor::New(args.Length())));
736 // TODO(11771): This won't find private members. 736
737 const Function& function = Function::Handle( 737 Class& klass = Class::Handle(reflectee.clazz());
738 Resolver::ResolveDynamic(reflectee, 738 Function& function = Function::Handle();
739 function_name, 739 while (!klass.IsNull()) {
740 args_desc)); 740 function = klass.LookupDynamicFunctionAllowPrivate(function_name);
741 if (!function.IsNull()) {
742 break;
743 }
744 klass = klass.SuperClass();
745 }
746
747 if (!function.IsNull() &&
748 !function.AreValidArguments(args_desc, NULL)) {
749 function = Function::null();
750 }
741 751
742 return ReflectivelyInvokeDynamicFunction(reflectee, 752 return ReflectivelyInvokeDynamicFunction(reflectee,
743 function, 753 function,
744 function_name, 754 function_name,
745 args); 755 args);
746 } 756 }
747 757
748 758
749 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeGetter, 3) { 759 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeGetter, 3) {
750 // Argument 0 is the mirror, which is unused by the native. It exists 760 // Argument 0 is the mirror, which is unused by the native. It exists
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1324
1315 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1325 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1316 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1326 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1317 const Field& field = Field::Handle(ref.GetFieldReferent()); 1327 const Field& field = Field::Handle(ref.GetFieldReferent());
1318 1328
1319 const AbstractType& type = AbstractType::Handle(field.type()); 1329 const AbstractType& type = AbstractType::Handle(field.type());
1320 return CreateTypeMirror(type); 1330 return CreateTypeMirror(type);
1321 } 1331 }
1322 1332
1323 } // namespace dart 1333 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | tests/lib/mirrors/invoke_private_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698