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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 111643012: Partially implement LibraryMirror.topLevelMembers. (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 | « no previous file | tests/lib/lib.status » ('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 fd2d1d7589e477faa2d3b570dc560e1eaa2ceafd..ff7a0e2f61d06b1c0595902e705901145ff87073 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -1075,11 +1075,34 @@ class _LocalLibraryMirror extends _LocalObjectMirror implements LibraryMirror {
new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members);
}
+
+ var _cachedTopLevelMembers;
Map<Symbol, MethodMirror> get topLevelMembers {
- throw new UnimplementedError(
- 'LibraryMirror.topLevelMembers is not implemented');
+ if (_cachedTopLevelMembers != null) return _cachedTopLevelMembers;
+ var result = new Map<Symbol, MethodMirror>();
+ declarations.values.forEach((decl) {
+ if (decl is MethodMirror && !decl.isAbstract) {
+ result[decl.simpleName] = decl;
+ }
+ if (decl is VariableMirror) {
+ var getterName = decl.simpleName;
+ result[getterName] =
+ new _SyntheticAccessor(this, getterName, true, true, true, decl);
+ if (!decl.isFinal) {
+ var setterName = _asSetter(decl.simpleName, this);
+ result[setterName] = new _SyntheticAccessor(
+ this, setterName, false, true, true, decl);
+ }
+ }
+ // if (decl is TypeMirror) {
+ // var getterName = decl.simpleName;
+ // result[getterName] = new _SyntheticTypeGetter(this, getterName, decl);
+ // }
+ });
+ return _cachedTopLevelMembers = result;
}
+
Map<Symbol, Mirror> _cachedMembers;
Map<Symbol, Mirror> get _members {
if (_cachedMembers == null) {
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698