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

Unified Diff: sdk/lib/_internal/lib/js_mirrors.dart

Issue 24197003: Support typeVariables in ClassMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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: sdk/lib/_internal/lib/js_mirrors.dart
diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart
index cf002e88be5d901b078f78bd40cbee001919c69e..c77c2e531ac128415e891e184ae61e5a3024ae18 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -178,6 +178,23 @@ abstract class JsDeclarationMirror extends JsMirror
SourceLocation get location => throw new UnimplementedError();
}
+class JsTypeVariableMirror extends JsTypeMirror {
+
ahe 2013/09/23 08:17:03 Remove extra line.
zarah 2013/09/23 11:17:02 Done.
+ final TypeMirror upperBound;
+ final DeclarationMirror owner;
+
+ JsTypeVariableMirror(Symbol simpleName, this.upperBound, this.owner)
+ : super(simpleName);
+
+ bool operator ==(other) {
+ return (other is JsTypeVariableMirror &&
+ simpleName == other.simpleName &&
+ owner == other.owner);
+ }
+
+ String get _prettyName => 'TypeVariableMirror';
+}
+
class JsTypeMirror extends JsDeclarationMirror implements TypeMirror {
JsTypeMirror(Symbol simpleName)
: super(simpleName);
@@ -899,6 +916,7 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
UnmodifiableMapView<Symbol, Mirror> _cachedMembers;
UnmodifiableListView<InstanceMirror> _cachedMetadata;
UnmodifiableListView<ClassMirror> _cachedSuperinterfaces;
+ UnmodifiableListView<TypeVariableMirror> _cachedTypeVariables;
// Set as side-effect of accessing JsLibraryMirror.classes.
JsLibraryMirror _owner;
@@ -1243,9 +1261,23 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
new UnmodifiableListView<ClassMirror>(result);
}
- // TODO(ahe): Implement these.
- List<TypeVariableMirror> get typeVariables
- => throw new UnimplementedError();
+ List<TypeVariableMirror> get typeVariables {
+ if (_cachedTypeVariables != null) return _cachedTypeVariables;
+ List result = new List();
+ List typeVars =
+ JS('JSExtendableArray|Null', '#.prototype["<>"]', _jsConstructor);
+ if (typeVars == null) return result;
+ for (int i = 0; i < typeVars.length; i += 2) {
+ var upperBound =
ahe 2013/09/23 08:17:03 Please add a type.
zarah 2013/09/23 11:17:02 Done.
+ typeMirrorFromRuntimeTypeRepresentation(JS('', 'init.metadata[#]',
+ typeVars[i+1]));
+ var typeMirror =
ahe 2013/09/23 08:17:03 Weird indentation.
zarah 2013/09/23 11:17:02 Done.
+ new JsTypeVariableMirror(s(typeVars[i]), upperBound, this);
+ result.add(typeMirror);
ahe 2013/09/23 08:17:03 Weird indentation.
zarah 2013/09/23 11:17:02 Done.
+ }
+ return _cachedTypeVariables = new UnmodifiableListView(result);
+ }
+
List<TypeMirror> get typeArguments => new List();
}

Powered by Google App Engine
This is Rietveld 408576698