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

Unified Diff: dart/runtime/lib/mirrors_impl.dart

Issue 14251021: Move invokeOn to InstanceMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: dart/runtime/lib/mirrors_impl.dart
diff --git a/dart/runtime/lib/mirrors_impl.dart b/dart/runtime/lib/mirrors_impl.dart
index 7757847ccc919213a17adc1c290efb0be60ad281..4546ab05a2afd9751d29acd167727b9caadf070d 100644
--- a/dart/runtime/lib/mirrors_impl.dart
+++ b/dart/runtime/lib/mirrors_impl.dart
@@ -298,6 +298,9 @@ String _dartEscape(String str) {
class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
implements InstanceMirror {
+ // TODO(ahe): This is a hack, see delegate below.
+ static Function _invokeOnClosure;
+
_LocalInstanceMirrorImpl(ref,
this._type,
this._reflectee) : super(ref) {}
@@ -316,6 +319,21 @@ class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
var _reflectee;
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.
+ _LocalInstanceMirrorImpl mirror =
+ _Mirrors.makeLocalInstanceMirror(invocation);
+ _invokeOnClosure =
+ _LocalObjectMirrorImpl._getField(mirror.type, '_invokeOnClosure')
+ .reflectee;
+ }
+ return _invokeOnClosure(reflectee, invocation);
+ }
+
String toString() {
if (_isSimpleValue(_reflectee)) {
if (_reflectee is String) {
« no previous file with comments | « dart/runtime/lib/invocation_mirror_patch.dart ('k') | dart/sdk/lib/_internal/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698