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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 23633002: Implementation for ClosureMirror.findInContext. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments + rebase Created 7 years, 3 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: runtime/lib/mirrors_impl.dart
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index e977653737ec927ca00664846cd12ad8100d683a..e20aa8874d603d414c29eaca193a54e8a4bcd9d7 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -403,9 +403,16 @@ class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
});
}
- Future<InstanceMirror> findInContext(Symbol name) {
- throw new UnimplementedError(
- 'ClosureMirror.findInContext() is not implemented');
+ InstanceMirror findInContext(Symbol name, {ifAbsent: null}) {
+ List<String> parts = _n(name).split(".").toList(growable: false);
+ if (parts.length > 3) {
+ throw new ArgumentError("Invalid symbol: ${name}");
+ }
+ List tuple = _computeFindInContext(_reflectee, parts);
+ if (tuple[0]) {
+ return reflect(tuple[1]);
+ }
+ return ifAbsent == null ? null : ifAbsent();
}
String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'";
@@ -415,6 +422,9 @@ class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
static _computeFunction(reflectee)
native 'ClosureMirror_function';
+
+ static _computeFindInContext(reflectee, name)
+ native 'ClosureMirror_find_in_context';
}
class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl

Powered by Google App Engine
This is Rietveld 408576698