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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 23451052: Mirrors cleanup. No semantic changes. (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
« no previous file with comments | « no previous file | no next file » | 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 acc701d7ed3ee3e7625c2799352a5a5402755c90..ccdb2c9dd0ff41e306501cb20fefa3e10d58e670 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -21,11 +21,8 @@ Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) {
return new_map;
}
-Map _makeMemberMap(List mirrors) {
- Map result = new Map<Symbol, dynamic>();
- mirrors.forEach((mirror) => result[mirror.simpleName] = mirror);
- return result;
-}
+Map _makeMemberMap(List mirrors) => new Map.fromIterable(
+ mirrors, key: (e) => e.simpleName);
String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
@@ -39,13 +36,6 @@ Symbol _computeQualifiedName(DeclarationMirror owner, Symbol simpleName) {
return _s('${_n(owner.qualifiedName)}.${_n(simpleName)}');
}
-Map<Symbol, dynamic> _convertStringToSymbolMap(Map<String, dynamic> map) {
Michael Lippautz (Google) 2013/09/11 23:04:11 unused
- if (map == null) return null;
- Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();
- map.forEach((name, value) => result[_s(name)] = value);
- return result;
-}
-
String _makeSignatureString(TypeMirror returnType,
List<ParameterMirror> parameters) {
StringBuffer buf = new StringBuffer();
@@ -83,18 +73,12 @@ String _makeSignatureString(TypeMirror returnType,
return buf.toString();
}
-Map<Uri, LibraryMirror> _createLibrariesMap(List<LibraryMirror> list) {
Michael Lippautz (Google) 2013/09/11 23:04:11 only 1 caller
- var map = new Map<Uri, LibraryMirror>();
- list.forEach((LibraryMirror mirror) => map[mirror.uri] = mirror);
- return map;
-}
-
List _metadata(reflectee)
native 'DeclarationMirror_metadata';
// This will verify the argument types, unwrap them, and ensure we have a fixed
// array.
-List _unwarpAsyncPositionals(wrappedArgs) {
+List _unwrapAsyncPositionals(wrappedArgs) {
List unwrappedArgs = new List(wrappedArgs.length);
for(int i = 0; i < wrappedArgs.length; i++){
var wrappedArg = wrappedArgs[i];
@@ -109,7 +93,8 @@ List _unwarpAsyncPositionals(wrappedArgs) {
}
return unwrappedArgs;
}
-Map _unwarpAsyncNamed(wrappedArgs) {
+
+Map _unwrapAsyncNamed(wrappedArgs) {
if (wrappedArgs==null) return null;
Map unwrappedArgs = new Map();
wrappedArgs.forEach((name, wrappedArg){
@@ -128,13 +113,12 @@ Map _unwarpAsyncNamed(wrappedArgs) {
class _LocalMirrorSystemImpl extends MirrorSystem {
// Change parameter back to "this.libraries" when native code is changed.
_LocalMirrorSystemImpl(List<LibraryMirror> libraries, this.isolate)
- : this.libraries = _createLibrariesMap(libraries);
+ : this.libraries = new Map.fromIterable(libraries, key: (e) => e.uri);
final Map<Uri, LibraryMirror> libraries;
final IsolateMirror isolate;
TypeMirror _dynamicType = null;
-
TypeMirror get dynamicType {
if (_dynamicType == null) {
_dynamicType = new _SpecialTypeMirrorImpl('dynamic');
@@ -143,7 +127,6 @@ class _LocalMirrorSystemImpl extends MirrorSystem {
}
TypeMirror _voidType = null;
-
TypeMirror get voidType {
if (_voidType == null) {
_voidType = new _SpecialTypeMirrorImpl('void');
@@ -166,7 +149,7 @@ abstract class _LocalMirrorImpl implements Mirror {
class _LocalIsolateMirrorImpl extends _LocalMirrorImpl
implements IsolateMirror {
- _LocalIsolateMirrorImpl(this.debugName, this.rootLibrary) {}
+ _LocalIsolateMirrorImpl(this.debugName, this.rootLibrary);
final String debugName;
final bool isCurrent = true;
@@ -223,8 +206,8 @@ abstract class _LocalObjectMirrorImpl extends _LocalMirrorImpl
[Map<Symbol, dynamic> namedArguments]) {
return new Future(() {
return this.invoke(memberName,
- _unwarpAsyncPositionals(positionalArguments),
- _unwarpAsyncNamed(namedArguments));
+ _unwrapAsyncPositionals(positionalArguments),
+ _unwrapAsyncNamed(namedArguments));
});
}
@@ -416,8 +399,8 @@ class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
Future<InstanceMirror> applyAsync(List positionalArguments,
[Map<Symbol, dynamic> namedArguments]) {
return new Future(() {
- return this.apply(_unwarpAsyncPositionals(positionalArguments),
- _unwarpAsyncNamed(namedArguments));
+ return this.apply(_unwrapAsyncPositionals(positionalArguments),
+ _unwrapAsyncNamed(namedArguments));
});
}
@@ -488,8 +471,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
final bool isTopLevel = true;
SourceLocation get location {
- throw new UnimplementedError(
- 'ClassMirror.location is not implemented');
+ throw new UnimplementedError('ClassMirror.location is not implemented');
}
// TODO(rmacnak): Remove these left-overs from the days of separate interfaces
@@ -554,7 +536,6 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
}
Map<Symbol, Mirror> _members;
-
Map<Symbol, Mirror> get members {
if (_members == null) {
var whoseMembers = _isMixinTypedef ? _trueSuperclass : this;
@@ -563,11 +544,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
return _members;
}
- Map<Symbol, MethodMirror> _methods = null;
- Map<Symbol, MethodMirror> _getters = null;
- Map<Symbol, MethodMirror> _setters = null;
- Map<Symbol, VariableMirror> _variables = null;
-
+ Map<Symbol, MethodMirror> _methods;
Map<Symbol, MethodMirror> get methods {
if (_methods == null) {
_methods = _filterMap(
@@ -577,6 +554,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
return _methods;
}
+ Map<Symbol, MethodMirror> _getters;
Map<Symbol, MethodMirror> get getters {
if (_getters == null) {
_getters = _filterMap(
@@ -586,6 +564,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
return _getters;
}
+ Map<Symbol, MethodMirror> _setters;
Map<Symbol, MethodMirror> get setters {
if (_setters == null) {
_setters = _filterMap(
@@ -595,6 +574,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
return _setters;
}
+ Map<Symbol, VariableMirror> _variables;
Map<Symbol, VariableMirror> get variables {
if (_variables == null) {
_variables = _filterMap(
@@ -605,7 +585,6 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
}
Map<Symbol, MethodMirror> _constructors;
-
Map<Symbol, MethodMirror> get constructors {
if (_constructors == null) {
var constructorsList = _computeConstructors(_reflectee);
@@ -617,7 +596,6 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
}
Map<Symbol, TypeVariableMirror> _typeVariables = null;
-
Map<Symbol, TypeVariableMirror> get typeVariables {
if (_typeVariables == null) {
List params = _ClassMirror_type_variables(_reflectee);
@@ -639,16 +617,14 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
_typeArguments = new LinkedHashMap<Symbol, TypeMirror>();
} else {
_typeArguments =
- new LinkedHashMap<Symbol, TypeMirror>.fromIterables(typeVariables.keys,
- _computeTypeArguments(_reflectedType));
+ new LinkedHashMap<Symbol, TypeMirror>.fromIterables(
+ typeVariables.keys, _computeTypeArguments(_reflectedType));
}
}
return _typeArguments;
}
- bool get isOriginalDeclaration {
- return !_isGeneric || _reflectedType == null;
- }
+ bool get isOriginalDeclaration => !_isGeneric || _reflectedType == null;
ClassMirror get originalDeclaration {
if (isOriginalDeclaration) {
@@ -658,9 +634,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
}
}
- String toString() {
- return "ClassMirror on '${_n(simpleName)}'";
- }
+ String toString() => "ClassMirror on '${_n(simpleName)}'";
InstanceMirror newInstance(Symbol constructorName,
List positionalArguments,
@@ -693,8 +667,8 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
[Map<Symbol, dynamic> namedArguments]) {
return new Future(() {
return this.newInstance(constructorName,
- _unwarpAsyncPositionals(positionalArguments),
- _unwarpAsyncNamed(namedArguments));
+ _unwrapAsyncPositionals(positionalArguments),
+ _unwrapAsyncNamed(namedArguments));
});
}
@@ -893,9 +867,13 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl
this._owner)
: super(reflectee, _s(simpleName));
+ final bool isTopLevel = true;
+
// TODO(12282): Deal with generic typedefs.
bool get _isGeneric => false;
+ bool get isPrivate => false;
+
DeclarationMirror _owner;
DeclarationMirror get owner {
if (_owner == null) {
@@ -904,13 +882,8 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl
return _owner;
}
- bool get isPrivate => false;
-
- final bool isTopLevel = true;
-
SourceLocation get location {
- throw new UnimplementedError(
- 'TypedefMirror.location is not implemented');
+ throw new UnimplementedError('TypedefMirror.location is not implemented');
}
TypeMirror _referent = null;
@@ -953,14 +926,12 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
final bool isTopLevel = false;
SourceLocation get location {
- throw new UnimplementedError(
- 'LibraryMirror.location is not implemented');
+ throw new UnimplementedError('LibraryMirror.location is not implemented');
}
final Uri uri;
Map<Symbol, Mirror> _members;
-
Map<Symbol, Mirror> get members {
if (_members == null) {
_members = _makeMemberMap(_computeMembers(_reflectee));
@@ -968,12 +939,7 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
return _members;
}
- Map<Symbol, ClassMirror> _classes = null;
- Map<Symbol, MethodMirror> _functions = null;
- Map<Symbol, MethodMirror> _getters = null;
- Map<Symbol, MethodMirror> _setters = null;
- Map<Symbol, VariableMirror> _variables = null;
-
+ Map<Symbol, ClassMirror> _classes;
Map<Symbol, ClassMirror> get classes {
if (_classes == null) {
_classes = _filterMap(members,
@@ -982,30 +948,31 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
return _classes;
}
+ Map<Symbol, MethodMirror> _functions;
Map<Symbol, MethodMirror> get functions {
if (_functions == null) {
- _functions = _filterMap(members,
- (key, value) => (value is MethodMirror));
+ _functions = _filterMap(members, (key, value) => (value is MethodMirror));
}
return _functions;
}
+ Map<Symbol, MethodMirror> _getters;
Map<Symbol, MethodMirror> get getters {
if (_getters == null) {
- _getters = _filterMap(functions,
- (key, value) => (value.isGetter));
+ _getters = _filterMap(functions, (key, value) => (value.isGetter));
}
return _getters;
}
+ Map<Symbol, MethodMirror> _setters;
Map<Symbol, MethodMirror> get setters {
if (_setters == null) {
- _setters = _filterMap(functions,
- (key, value) => (value.isSetter));
+ _setters = _filterMap(functions, (key, value) => (value.isSetter));
}
return _setters;
}
+ Map<Symbol, VariableMirror> _variables;
Map<Symbol, VariableMirror> get variables {
if (_variables == null) {
_variables = _filterMap(members,
@@ -1020,8 +987,6 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
return _metadata(_reflectee).map(reflect).toList(growable:false);
}
- String toString() => "LibraryMirror on '${_n(simpleName)}'";
-
bool operator ==(other) {
return this.runtimeType == other.runtimeType &&
this._reflectee == other._reflectee;
@@ -1029,6 +994,8 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
int get hashCode => simpleName.hashCode;
+ String toString() => "LibraryMirror on '${_n(simpleName)}'";
+
_invoke(reflectee, memberName, arguments, argumentNames)
native 'LibraryMirror_invoke';
@@ -1083,16 +1050,13 @@ class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl
return _owner;
}
- bool get isPrivate {
- return _n(simpleName).startsWith('_') ||
- _n(constructorName).startsWith('_');
- }
+ bool get isPrivate => _n(simpleName).startsWith('_') ||
+ _n(constructorName).startsWith('_');
bool get isTopLevel => owner is LibraryMirror;
SourceLocation get location {
- throw new UnimplementedError(
- 'MethodMirror.location is not implemented');
+ throw new UnimplementedError('MethodMirror.location is not implemented');
}
TypeMirror _returnType = null;
@@ -1183,18 +1147,15 @@ class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl
: super(reflectee, _s(simpleName));
final DeclarationMirror owner;
+ final bool isStatic;
+ final bool isFinal;
- bool get isPrivate {
- return _n(simpleName).startsWith('_');
- }
+ bool get isPrivate => _n(simpleName).startsWith('_');
- bool get isTopLevel {
- return owner is LibraryMirror;
- }
+ bool get isTopLevel => owner is LibraryMirror;
SourceLocation get location {
- throw new UnimplementedError(
- 'VariableMirror.location is not implemented');
+ throw new UnimplementedError('VariableMirror.location is not implemented');
}
TypeMirror _type;
@@ -1205,9 +1166,6 @@ class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl
return _type;
}
- final bool isStatic;
- final bool isFinal;
-
String toString() => "VariableMirror on '${_n(simpleName)}'";
static _VariableMirror_type(reflectee)
@@ -1276,24 +1234,17 @@ class _SpecialTypeMirrorImpl extends _LocalMirrorImpl
_SpecialTypeMirrorImpl(String name) : simpleName = _s(name);
final bool isPrivate = false;
+ final DeclarationMirror owner = null;
+ final Symbol simpleName;
final bool isTopLevel = true;
-
// Fixed length 0, therefore immutable.
final List<InstanceMirror> metadata = new List(0);
- final DeclarationMirror owner = null;
- final Symbol simpleName;
-
SourceLocation get location {
- throw new UnimplementedError(
- 'TypeMirror.location is not implemented');
+ throw new UnimplementedError('TypeMirror.location is not implemented');
}
- Symbol get qualifiedName {
- return simpleName;
- }
-
- String toString() => "TypeMirror on '${_n(simpleName)}'";
+ Symbol get qualifiedName => simpleName;
// TODO(11955): Remove once dynamicType and voidType are canonical objects in
// the object store.
@@ -1305,6 +1256,8 @@ class _SpecialTypeMirrorImpl extends _LocalMirrorImpl
}
int get hashCode => simpleName.hashCode;
+
+ String toString() => "TypeMirror on '${_n(simpleName)}'";
}
class _Mirrors {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698