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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 114713002: VM: Support calling through getters in InstanceMirror.delegate. Implement without accessing private… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/invocation_mirror_patch.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_impl.dart
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index e057fd223886d1cdbe22a722c0487d4c3a40d3a1..63f1828b32b894c76a6c78a0379e3c7e57590078 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -283,17 +283,22 @@ class _LocalInstanceMirror extends _LocalObjectMirror
get reflectee => _reflectee;
delegate(Invocation invocation) {
- if (_invokeOnClosure == null) {
- // TODO(ahe): This is a total hack. We're using the mirror
- // system to access a private field in a different library. For
- // some reason, that works. On the other hand, calling a
- // private method does not work.
- ClassMirror invocationImplClass = reflect(invocation).type;
- Symbol fieldName = MirrorSystem.getSymbol('_invokeOnClosure',
- invocationImplClass.owner);
- _invokeOnClosure = invocationImplClass.getField(fieldName).reflectee;
- }
- return _invokeOnClosure(reflectee, invocation);
+ if (invocation.isMethod) {
+ return this.invoke(invocation.memberName,
+ invocation.positionalArguments,
+ invocation.namedArguments).reflectee;
+ }
+ if (invocation.isGetter) {
+ return this.getField(invocation.memberName).reflectee;
+ }
+ if (invocation.isSetter) {
+ var unwrapped = _n(invocation.memberName);
+ var withoutEqual = _s(unwrapped.substring(0, unwrapped.length - 1));
+ var arg = invocation.positionalArguments[0];
+ this.setField(withoutEqual, arg).reflectee;
+ return arg;
+ }
+ throw "UNREACHABLE";
}
String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}';
« no previous file with comments | « runtime/lib/invocation_mirror_patch.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698