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

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

Issue 26472002: Add TypeVariable object on runtime to support reflection on type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 7 years, 2 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/lib/js_rti.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4d0fe517fc221b9a484387446e254ede35b54dcb..6de7be4fec097cb38108bc17acdbd5b2a5a3cfd5 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -27,7 +27,8 @@ import 'dart:_js_helper' show
getMangledTypeName,
throwInvalidReflectionError,
hasReflectableProperty,
- runtimeTypeToString;
+ runtimeTypeToString,
+ TypeVariable;
import 'dart:_interceptors' show
Interceptor,
JSExtendableArray;
@@ -181,11 +182,13 @@ abstract class JsDeclarationMirror extends JsMirror
}
class JsTypeVariableMirror extends JsTypeMirror implements TypeVariableMirror {
- final TypeMirror upperBound;
final DeclarationMirror owner;
+ final TypeVariable _typeVariable;
+ TypeMirror _cachedUpperBound;
- JsTypeVariableMirror(Symbol simpleName, this.upperBound, this.owner)
- : super(simpleName);
+ JsTypeVariableMirror(TypeVariable typeVariable, this.owner)
+ : this._typeVariable = typeVariable,
+ super(s(typeVariable.name));
bool operator ==(other) {
return (other is JsTypeVariableMirror &&
@@ -201,6 +204,12 @@ class JsTypeVariableMirror extends JsTypeMirror implements TypeVariableMirror {
}
String get _prettyName => 'TypeVariableMirror';
+
+ TypeMirror get upperBound {
+ if (_cachedUpperBound != null) return _cachedUpperBound;
+ return _cachedUpperBound = typeMirrorFromRuntimeTypeRepresentation(
+ JS('', 'init.metadata[#]', _typeVariable.bound));
+ }
}
class JsTypeMirror extends JsDeclarationMirror implements TypeMirror {
@@ -818,6 +827,7 @@ class JsTypeBoundClassMirror implements ClassMirror {
List<TypeMirror> get typeArguments {
if (_typeArgs is! String) return _typeArgs;
List result = new List();
+
if (_typeArgs.indexOf('<') == -1) {
for (String s in _typeArgs.split(',')) {
result.add(reflectClassByMangledName(s.trim()));
@@ -1311,13 +1321,9 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
List typeVars =
JS('JSExtendableArray|Null', '#.prototype["<>"]', _jsConstructor);
if (typeVars == null) return result;
- for (int i = 0; i < typeVars.length; i += 2) {
- TypeMirror upperBound =
- typeMirrorFromRuntimeTypeRepresentation(JS('', 'init.metadata[#]',
- typeVars[i+1]));
- var typeMirror =
- new JsTypeVariableMirror(s(typeVars[i]), upperBound, this);
- result.add(typeMirror);
+ for (int i = 0; i < typeVars.length; i++) {
+ TypeVariable typeVariable = JS('', 'init.metadata[#]', typeVars[i]);
+ result.add(new JsTypeVariableMirror(typeVariable, this));
}
return _cachedTypeVariables = new UnmodifiableListView(result);
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/lib/js_rti.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698