Index: runtime/lib/mirrors_impl.dart |
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart |
index 3c6d6958e8a054db39cdfc82bd2dcd2c3651f659..b08b1fd2003036cfe57502d2f7fe40c7e842e6af 100644 |
--- a/runtime/lib/mirrors_impl.dart |
+++ b/runtime/lib/mirrors_impl.dart |
@@ -125,19 +125,8 @@ class _LocalMirrorSystemImpl extends MirrorSystem { |
final Map<String, FunctionTypeMirror> _functionTypes; |
FunctionTypeMirror _lookupFunctionTypeMirror( |
rmacnak
2013/07/31 20:24:37
Dead code.
Michael Lippautz (Google)
2013/07/31 20:33:25
Done.
|
- reflectee, |
- TypeMirror returnType, |
- List<ParameterMirror> parameters) { |
- var sigString = _makeSignatureString(returnType, parameters); |
- var mirror = _functionTypes[sigString]; |
- if (mirror == null) { |
- mirror = new _LocalFunctionTypeMirrorImpl(reflectee, |
- sigString, |
- returnType, |
- parameters); |
- _functionTypes[sigString] = mirror; |
- } |
- return mirror; |
+ reflectee) { |
+ return new _LocalFunctionTypeMirrorImpl(reflectee); |
} |
String toString() => "MirrorSystem for isolate '${isolate.debugName}'"; |
@@ -368,33 +357,6 @@ class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl |
native 'ClosureMirror_function'; |
} |
-class _LazyTypeMirror { |
- _LazyTypeMirror(String this.libraryUrl, String typeName) |
- : this.typeName = _s(typeName); |
- |
- TypeMirror resolve(MirrorSystem mirrors) { |
- if (libraryUrl == null) { |
- if (typeName == const Symbol('dynamic')) { |
- return mirrors.dynamicType; |
- } else if (typeName == const Symbol('void')) { |
- return mirrors.voidType; |
- } else { |
- throw new UnimplementedError( |
- "Mirror for type '$typeName' is not implemented"); |
- } |
- } |
- var resolved = mirrors.libraries[Uri.parse(libraryUrl)].members[typeName]; |
- if (resolved == null) { |
- throw new UnimplementedError( |
- "Mirror for type '$typeName' is not implemented"); |
- } |
- return resolved; |
- } |
- |
- final String libraryUrl; |
- final Symbol typeName; |
-} |
- |
class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
implements ClassMirror { |
_LocalClassMirrorImpl(reflectee, |
@@ -631,44 +593,46 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
native "ClassMirror_type_variables"; |
} |
-class _LazyFunctionTypeMirror { |
- _LazyFunctionTypeMirror(this.reflectee, this.returnType, this.parameters) {} |
- |
- ClassMirror resolve(MirrorSystem mirrors) { |
- return mirrors._lookupFunctionTypeMirror(reflectee, |
- returnType.resolve(mirrors), |
- parameters); |
- } |
- |
- final reflectee; |
- final returnType; |
- final List<ParameterMirror> parameters; |
-} |
- |
class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl |
implements FunctionTypeMirror { |
- _LocalFunctionTypeMirrorImpl(reflectee, |
- simpleName, |
- this._returnType, |
- this.parameters) |
- : super(reflectee, |
- simpleName); |
+ _LocalFunctionTypeMirrorImpl(reflectee) : super(reflectee, null); |
- Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); |
- Map<Symbol, MethodMirror> get constructors => new Map<Symbol,MethodMirror>(); |
+ // FunctionTypeMirrors have a simpleName generated from their signature. |
+ Symbol _simpleName = null; |
+ Symbol get simpleName { |
+ if (_simpleName == null) { |
+ _simpleName = _s(_makeSignatureString(returnType, parameters)); |
+ } |
+ return _simpleName; |
+ } |
- var _returnType; |
+ TypeMirror _returnType = null; |
TypeMirror get returnType { |
- if (_returnType is! Mirror) { |
- _returnType = _returnType.resolve(mirrors); |
+ if (_returnType == null) { |
+ _returnType = _FunctionTypeMirror_return_type(_reflectee); |
} |
return _returnType; |
} |
- final List<ParameterMirror> parameters; |
+ List<ParameterMirror> _parameters = null; |
+ List<ParameterMirror> get parameters { |
+ if (_parameters == null) { |
+ _parameters = _FunctionTypeMirror_parameters(_reflectee); |
+ } |
+ return _parameters; |
+ } |
+ |
+ Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); |
+ Map<Symbol, MethodMirror> get constructors => new Map<Symbol,MethodMirror>(); |
final Map<Symbol, TypeVariableMirror> typeVariables = const {}; |
String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; |
+ |
+ static TypeMirror _FunctionTypeMirror_return_type(reflectee) |
+ native "FunctionTypeMirror_return_type"; |
+ |
+ static List<ParameterMirror> _FunctionTypeMirror_parameters(reflectee) |
+ native "FunctionTypeMirror_parameters"; |
} |
abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl |
@@ -694,19 +658,6 @@ abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl |
} |
} |
-class _LazyTypeVariableMirror { |
- _LazyTypeVariableMirror(String variableName, this._owner) |
- : this._variableName = _s(variableName); |
- |
- TypeVariableMirror resolve(MirrorSystem mirrors) { |
- ClassMirror owner = _owner.resolve(mirrors); |
- return owner.typeVariables[_variableName]; |
- } |
- |
- final Symbol _variableName; |
- final _LazyTypeMirror _owner; |
-} |
- |
class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl |
implements TypeVariableMirror { |
_LocalTypeVariableMirrorImpl(reflectee, |
@@ -762,8 +713,7 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl |
implements TypedefMirror { |
_LocalTypedefMirrorImpl(reflectee, |
String simpleName, |
- this._owner, |
- this._referent) |
+ this._owner) |
: super(reflectee, _s(simpleName)); |
var _owner; |
@@ -786,26 +736,19 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl |
'TypedefMirror.location is not implemented'); |
} |
- var _referent; |
+ TypeMirror _referent = null; |
TypeMirror get referent { |
- if (_referent is! Mirror) { |
- _referent = _referent.resolve(mirrors); |
+ if (_referent == null) { |
+ return new _LocalFunctionTypeMirrorImpl( |
+ _TypedefMirror_referent(_reflectee)); |
} |
return _referent; |
} |
String toString() => "TypedefMirror on '${_n(simpleName)}'"; |
-} |
- |
- |
-class _LazyLibraryMirror { |
- _LazyLibraryMirror(String this.libraryUrl); |
- |
- LibraryMirror resolve(MirrorSystem mirrors) { |
- return mirrors.libraries[Uri.parse(libraryUrl)]; |
- } |
- final String libraryUrl; |
+ static _TypedefMirror_referent(_reflectee) |
+ native "TypedefMirror_referent"; |
} |
class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |