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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 62373008: - Reverting mirror changes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | « pkg/unittest/lib/mirror_matchers.dart ('k') | runtime/tests/vm/dart/mirrored_compilation_error_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_impl.dart
===================================================================
--- runtime/lib/mirrors_impl.dart (revision 30028)
+++ runtime/lib/mirrors_impl.dart (working copy)
@@ -272,7 +272,7 @@
Function operator [](Symbol selector) {
bool found = false;
for (ClassMirror c = type; c != null; c = c.superclass) {
- var target = c._methods[selector];
+ var target = c.methods[selector];
if (target != null && !target.isStatic && target.isRegularMethod) {
found = true;
break;
@@ -364,6 +364,14 @@
return reflect(_apply(arguments, names));
}
+ Future<InstanceMirror> applyAsync(List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
+ return new Future(() {
+ return this.apply(_unwrapAsyncPositionals(positionalArguments),
+ _unwrapAsyncNamed(namedArguments));
+ });
+ }
+
InstanceMirror findInContext(Symbol name, {ifAbsent: null}) {
List<String> parts = _n(name).split(".").toList(growable: false);
if (parts.length > 3) {
@@ -519,52 +527,84 @@
return _mixin;
}
- Map<Symbol, DeclarationMirror> _cachedDeclarations;
+ Map<Symbol, DeclarationMirror> _declarations;
Map<Symbol, DeclarationMirror> get declarations {
- if (_cachedDeclarations != null) return _cachedDeclarations;
+ if (_declarations != null) return _declarations;
var decls = new Map<Symbol, DeclarationMirror>();
- decls.addAll(_members);
- decls.addAll(_constructors);
+ decls.addAll(members);
+ decls.addAll(constructors);
typeVariables.forEach((tv) => decls[tv.simpleName] = tv);
- return _cachedDeclarations =
+ return _declarations =
new _UnmodifiableMapView<Symbol, DeclarationMirror>(decls);
}
- Map<Symbol, Mirror> _cachedMembers;
- Map<Symbol, Mirror> get _members {
- if (_cachedMembers == null) {
+ Map<Symbol, Mirror> _members;
+ Map<Symbol, Mirror> get members {
+ if (_members == null) {
var whoseMembers = _isMixinTypedef ? _trueSuperclass : this;
- _cachedMembers = _makeMemberMap(mixin._computeMembers(whoseMembers._reflectee));
+ _members = _makeMemberMap(mixin._computeMembers(whoseMembers._reflectee));
}
- return _cachedMembers;
+ return _members;
}
- Map<Symbol, MethodMirror> _cachedConstructors;
- Map<Symbol, MethodMirror> get _constructors {
- if (_cachedConstructors == null) {
+ Map<Symbol, MethodMirror> _methods;
+ Map<Symbol, MethodMirror> get methods {
+ if (_methods == null) {
+ _methods = _filterMap(
+ members,
+ (key, value) => (value is MethodMirror && value.isRegularMethod));
+ }
+ return _methods;
+ }
+
+ Map<Symbol, MethodMirror> _getters;
+ Map<Symbol, MethodMirror> get getters {
+ if (_getters == null) {
+ _getters = _filterMap(
+ members,
+ (key, value) => (value is MethodMirror && value.isGetter));
+ }
+ return _getters;
+ }
+
+ Map<Symbol, MethodMirror> _setters;
+ Map<Symbol, MethodMirror> get setters {
+ if (_setters == null) {
+ _setters = _filterMap(
+ members,
+ (key, value) => (value is MethodMirror && value.isSetter));
+ }
+ return _setters;
+ }
+
+ Map<Symbol, VariableMirror> _variables;
+ Map<Symbol, VariableMirror> get variables {
+ if (_variables == null) {
+ _variables = _filterMap(
+ members,
+ (key, value) => (value is VariableMirror));
+ }
+ return _variables;
+ }
+
+ Map<Symbol, MethodMirror> _constructors;
+ Map<Symbol, MethodMirror> get constructors {
+ if (_constructors == null) {
var constructorsList = _computeConstructors(_reflectee);
var stringName = _n(simpleName);
constructorsList.forEach((c) => c._patchConstructorName(stringName));
- _cachedConstructors = _makeMemberMap(constructorsList);
+ _constructors = _makeMemberMap(constructorsList);
}
- return _cachedConstructors;
+ return _constructors;
}
- get _methods {
- var result = new Map();
- declarations.forEach((k, v) {
- if (v is MethodMirror && !v.isConstructor) result[k] = v;
- });
- return result;
- }
-
bool get _isAnonymousMixinApplication {
if (_isMixinTypedef) return false; // Named mixin application.
if (mixin == this) return false; // Not a mixin application.
return true;
}
- List<TypeVariableMirror> _typeVariables;
+ List<TypeVariableMirror> _typeVariables = null;
List<TypeVariableMirror> get typeVariables {
if (_typeVariables == null) {
if (_isAnonymousMixinApplication) return _typeVariables = emptyList;
@@ -583,7 +623,7 @@
return _typeVariables;
}
- List<TypeMirror> _typeArguments;
+ List<TypeMirror> _typeArguments = null;
List<TypeMirror> get typeArguments {
if(_typeArguments == null) {
if(_isGenericDeclaration || _isAnonymousMixinApplication) {
@@ -609,7 +649,7 @@
String toString() => "ClassMirror on '${MirrorSystem.getName(simpleName)}'";
Function operator [](Symbol selector) {
- var target = _methods[selector];
+ var target = methods[selector];
if (target == null || !target.isStatic || !target.isRegularMethod) {
throw new ArgumentError(
"${MirrorSystem.getName(simpleName)} has no static method "
@@ -645,6 +685,16 @@
names));
}
+ Future<InstanceMirror> newInstanceAsync(Symbol constructorName,
+ List positionalArguments,
+ [Map<Symbol, dynamic> namedArguments]) {
+ return new Future(() {
+ return this.newInstance(constructorName,
+ _unwrapAsyncPositionals(positionalArguments),
+ _unwrapAsyncNamed(namedArguments));
+ });
+ }
+
List<InstanceMirror> get metadata {
// Get the metadata objects, convert them into InstanceMirrors using
// reflect() and then make them into a Dart list.
@@ -1006,22 +1056,70 @@
final Uri uri;
- Map<Symbol, DeclarationMirror> _cachedDeclarations;
+ Map<Symbol, DeclarationMirror> _declarations;
Map<Symbol, DeclarationMirror> get declarations {
- if (_cachedDeclarations != null) return _cachedDeclarations;
- return _cachedDeclarations =
- new _UnmodifiableMapView<Symbol, DeclarationMirror>(
- _makeMemberMap(_computeMembers(_reflectee)));
+ if (_declarations != null) return _declarations;
+ return _declarations =
+ new _UnmodifiableMapView<Symbol, DeclarationMirror>(members);
}
- get _functions {
- var result = new Map();
- declarations.forEach((k, v) {
- if (v is MethodMirror) result[k] = v;
- });
- return result;
+ Map<Symbol, Mirror> _members;
+ Map<Symbol, Mirror> get members {
+ if (_members == null) {
+ _members = _makeMemberMap(_computeMembers(_reflectee));
+ }
+ return _members;
}
+ Map<Symbol, ClassMirror> _types;
+ Map<Symbol, TypeMirror> get types {
+ if (_types == null) {
+ _types = _filterMap(members, (key, value) => (value is TypeMirror));
+ }
+ return _types;
+ }
+
+ Map<Symbol, ClassMirror> _classes;
+ Map<Symbol, ClassMirror> get classes {
+ if (_classes == null) {
+ _classes = _filterMap(members, (key, value) => (value is ClassMirror));
+ }
+ return _classes;
+ }
+
+ Map<Symbol, MethodMirror> _functions;
+ Map<Symbol, MethodMirror> get functions {
+ if (_functions == null) {
+ _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));
+ }
+ return _getters;
+ }
+
+ Map<Symbol, MethodMirror> _setters;
+ Map<Symbol, MethodMirror> get setters {
+ if (_setters == null) {
+ _setters = _filterMap(functions, (key, value) => (value.isSetter));
+ }
+ return _setters;
+ }
+
+ Map<Symbol, VariableMirror> _variables;
+ Map<Symbol, VariableMirror> get variables {
+ if (_variables == null) {
+ _variables = _filterMap(members,
+ (key, value) => (value is VariableMirror));
+ }
+ return _variables;
+ }
+
List<InstanceMirror> get metadata {
// Get the metadata objects, convert them into InstanceMirrors using
// reflect() and then make them into a Dart list.
@@ -1038,7 +1136,7 @@
String toString() => "LibraryMirror on '${_n(simpleName)}'";
Function operator [](Symbol selector) {
- var target = _functions[selector];
+ var target = functions[selector];
if (target == null || !target.isRegularMethod) {
throw new ArgumentError(
"${MirrorSystem.getName(simpleName)} has no top-level method "
« no previous file with comments | « pkg/unittest/lib/mirror_matchers.dart ('k') | runtime/tests/vm/dart/mirrored_compilation_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698