diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc index 6d05f2569df..405c129cbac 100644 --- a/runtime/lib/mirrors.cc +++ b/runtime/lib/mirrors.cc @@ -202,7 +202,7 @@ static RawInstance* CreateParameterMirrorList(const Function& func, args.SetAt(6, is_final); args.SetAt(7, default_value); args.SetAt(8, metadata); - param ^= CreateMirror(Symbols::_LocalParameterMirrorImpl(), args); + param ^= CreateMirror(Symbols::_LocalParameterMirror(), args); results.SetAt(i, param); } results.MakeImmutable(); @@ -216,7 +216,7 @@ static RawInstance* CreateTypeVariableMirror(const TypeParameter& param, args.SetAt(0, param); args.SetAt(1, String::Handle(param.name())); args.SetAt(2, owner_mirror); - return CreateMirror(Symbols::_LocalTypeVariableMirrorImpl(), args); + return CreateMirror(Symbols::_LocalTypeVariableMirror(), args); } @@ -254,7 +254,7 @@ static RawInstance* CreateTypedefMirror(const Class& cls, args.SetAt(3, Bool::Get(cls.NumTypeParameters() != 0)); args.SetAt(4, cls.NumTypeParameters() == 0 ? Bool::False() : is_declaration); args.SetAt(5, owner_mirror); - return CreateMirror(Symbols::_LocalTypedefMirrorImpl(), args); + return CreateMirror(Symbols::_LocalTypedefMirror(), args); } @@ -263,7 +263,7 @@ static RawInstance* CreateFunctionTypeMirror(const Class& cls, const Array& args = Array::Handle(Array::New(2)); args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); args.SetAt(1, type); - return CreateMirror(Symbols::_LocalFunctionTypeMirrorImpl(), args); + return CreateMirror(Symbols::_LocalFunctionTypeMirror(), args); } @@ -289,7 +289,7 @@ static RawInstance* CreateMethodMirror(const Function& func, args.SetAt(10, Bool::Get(isConstructor && func.is_redirecting())); args.SetAt(11, Bool::Get(isConstructor && func.IsFactory())); - return CreateMirror(Symbols::_LocalMethodMirrorImpl(), args); + return CreateMirror(Symbols::_LocalMethodMirror(), args); } @@ -309,7 +309,7 @@ static RawInstance* CreateVariableMirror(const Field& field, args.SetAt(5, Bool::Get(field.is_final())); args.SetAt(6, Bool::Get(field.is_const())); - return CreateMirror(Symbols::_LocalVariableMirrorImpl(), args); + return CreateMirror(Symbols::_LocalVariableMirror(), args); } static RawFunction* CallMethod(const Class& cls) { @@ -363,7 +363,7 @@ static RawInstance* CreateClassMirror(const Class& cls, args.SetAt(4, is_generic); args.SetAt(5, is_mixin_app_alias); args.SetAt(6, cls.NumTypeParameters() == 0 ? Bool::False() : is_declaration); - return CreateMirror(Symbols::_LocalClassMirrorImpl(), args); + return CreateMirror(Symbols::_LocalClassMirror(), args); } @@ -375,7 +375,7 @@ static RawInstance* CreateLibraryMirror(const Library& lib) { args.SetAt(1, str); str = lib.url(); args.SetAt(2, str); - return CreateMirror(Symbols::_LocalLibraryMirrorImpl(), args); + return CreateMirror(Symbols::_LocalLibraryMirror(), args); } @@ -389,12 +389,12 @@ static RawInstance* CreateTypeMirror(const AbstractType& type) { Array& args = Array::Handle(Array::New(1)); args.SetAt(0, Symbols::Void()); // TODO(mlippautz): Create once in the VM isolate and retrieve from there. - return CreateMirror(Symbols::_SpecialTypeMirrorImpl(), args); + return CreateMirror(Symbols::_SpecialTypeMirror(), args); } else if (cls.IsDynamicClass()) { Array& args = Array::Handle(Array::New(1)); args.SetAt(0, Symbols::Dynamic()); // TODO(mlippautz): Create once in the VM isolate and retrieve from there. - return CreateMirror(Symbols::_SpecialTypeMirrorImpl(), args); + return CreateMirror(Symbols::_SpecialTypeMirror(), args); } return CreateClassMirror(cls, type, Bool::False(), Object::null_instance()); } else if (type.IsTypeParameter()) { @@ -421,7 +421,7 @@ static RawInstance* CreateIsolateMirror() { const Array& args = Array::Handle(Array::New(2)); args.SetAt(0, debug_name); args.SetAt(1, root_library_mirror); - return CreateMirror(Symbols::_LocalIsolateMirrorImpl(), args); + return CreateMirror(Symbols::_LocalIsolateMirror(), args); } @@ -446,7 +446,7 @@ static RawInstance* CreateMirrorSystem() { const Array& args = Array::Handle(Array::New(2)); args.SetAt(0, library_mirrors); args.SetAt(1, isolate_mirror); - return CreateMirror(Symbols::_LocalMirrorSystemImpl(), args); + return CreateMirror(Symbols::_LocalMirrorSystem(), args); } diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart index 25f546c3594..17e5d43247e 100644 --- a/runtime/lib/mirrors_impl.dart +++ b/runtime/lib/mirrors_impl.dart @@ -122,9 +122,9 @@ String _makeSignatureString(TypeMirror returnType, List _metadata(reflectee) native 'DeclarationMirror_metadata'; -class _LocalMirrorSystemImpl extends MirrorSystem { +class _LocalMirrorSystem extends MirrorSystem { // Change parameter back to "this.libraries" when native code is changed. - _LocalMirrorSystemImpl(List libraries, this.isolate) + _LocalMirrorSystem(List libraries, this.isolate) : this.libraries = new Map.fromIterable( libraries, key: (e) => e.uri); @@ -134,7 +134,7 @@ class _LocalMirrorSystemImpl extends MirrorSystem { TypeMirror _dynamicType = null; TypeMirror get dynamicType { if (_dynamicType == null) { - _dynamicType = new _SpecialTypeMirrorImpl('dynamic'); + _dynamicType = new _SpecialTypeMirror('dynamic'); } return _dynamicType; } @@ -142,7 +142,7 @@ class _LocalMirrorSystemImpl extends MirrorSystem { TypeMirror _voidType = null; TypeMirror get voidType { if (_voidType == null) { - _voidType = new _SpecialTypeMirrorImpl('void'); + _voidType = new _SpecialTypeMirror('void'); } return _voidType; } @@ -150,11 +150,10 @@ class _LocalMirrorSystemImpl extends MirrorSystem { String toString() => "MirrorSystem for isolate '${isolate.debugName}'"; } -abstract class _LocalMirrorImpl implements Mirror {} +abstract class _LocalMirror implements Mirror {} -class _LocalIsolateMirrorImpl extends _LocalMirrorImpl - implements IsolateMirror { - _LocalIsolateMirrorImpl(this.debugName, this.rootLibrary); +class _LocalIsolateMirror extends _LocalMirror implements IsolateMirror { + _LocalIsolateMirror (this.debugName, this.rootLibrary); final String debugName; final bool isCurrent = true; @@ -175,9 +174,8 @@ class _InvocationTrampoline implements Function { } } -abstract class _LocalObjectMirrorImpl extends _LocalMirrorImpl - implements ObjectMirror { - _LocalObjectMirrorImpl(this._reflectee); +abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror { + _LocalObjectMirror(this._reflectee); final _reflectee; // May be a MirrorReference or an ordinary object. @@ -219,12 +217,12 @@ abstract class _LocalObjectMirrorImpl extends _LocalMirrorImpl } } -class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl +class _LocalInstanceMirror extends _LocalObjectMirror implements InstanceMirror { // TODO(ahe): This is a hack, see delegate below. static Function _invokeOnClosure; - _LocalInstanceMirrorImpl(reflectee) : super(reflectee); + _LocalInstanceMirror(reflectee) : super(reflectee); ClassMirror _type; ClassMirror get type { @@ -247,11 +245,10 @@ class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl // system to access a private field in a different library. For // some reason, that works. On the other hand, calling a // private method does not work. - - _LocalInstanceMirrorImpl mirror = - reflect(invocation); - _invokeOnClosure = reflectClass(invocation.runtimeType) - .getField(MirrorSystem.getSymbol('_invokeOnClosure', mirror.type.owner)).reflectee; + ClassMirror invocationImplClass = reflect(invocation).type; + Symbol fieldName = MirrorSystem.getSymbol('_invokeOnClosure', + invocationImplClass.owner); + _invokeOnClosure = invocationImplClass.getField(fieldName).reflectee; } return _invokeOnClosure(reflectee, invocation); } @@ -259,7 +256,7 @@ class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}'; bool operator ==(other) { - return other is _LocalInstanceMirrorImpl && + return other is _LocalInstanceMirror && identical(_reflectee, other._reflectee); } @@ -325,9 +322,9 @@ class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl native 'InstanceMirror_computeType'; } -class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl +class _LocalClosureMirror extends _LocalInstanceMirror implements ClosureMirror { - _LocalClosureMirrorImpl(reflectee) : super(reflectee); + _LocalClosureMirror(reflectee) : super(reflectee); MethodMirror _function; MethodMirror get function { @@ -400,15 +397,15 @@ class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl native 'ClosureMirror_find_in_context'; } -class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl +class _LocalClassMirror extends _LocalObjectMirror implements ClassMirror { - _LocalClassMirrorImpl(reflectee, - reflectedType, - String simpleName, - this._owner, - this._isGeneric, - this._isMixinAlias, - this._isGenericDeclaration) + _LocalClassMirror(reflectee, + reflectedType, + String simpleName, + this._owner, + this._isGeneric, + this._isMixinAlias, + this._isGenericDeclaration) : this._simpleName = _s(simpleName), this._reflectedType = reflectedType, this._instantiator = reflectedType, @@ -613,7 +610,7 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl ClassMirror owner = originalDeclaration; var mirror; for (var i = 0; i < params.length; i += 2) { - mirror = new _LocalTypeVariableMirrorImpl( + mirror = new _LocalTypeVariableMirror( params[i + 1], params[i], owner); _typeVariables.add(mirror); } @@ -755,9 +752,9 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl native "ClassMirror_type_arguments"; } -class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl +class _LocalFunctionTypeMirror extends _LocalClassMirror implements FunctionTypeMirror { - _LocalFunctionTypeMirrorImpl(reflectee, reflectedType) + _LocalFunctionTypeMirror(reflectee, reflectedType) : super(reflectee, reflectedType, null, null, false, false, false); bool get _isAnonymousMixinApplication => false; @@ -817,9 +814,9 @@ class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl native "FunctionTypeMirror_parameters"; } -abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl +abstract class _LocalDeclarationMirror extends _LocalMirror implements DeclarationMirror { - _LocalDeclarationMirrorImpl(this._reflectee, this._simpleName); + _LocalDeclarationMirror(this._reflectee, this._simpleName); final _reflectee; @@ -848,11 +845,11 @@ abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl int get hashCode => simpleName.hashCode; } -class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl +class _LocalTypeVariableMirror extends _LocalDeclarationMirror implements TypeVariableMirror { - _LocalTypeVariableMirrorImpl(reflectee, - String simpleName, - this._owner) + _LocalTypeVariableMirror(reflectee, + String simpleName, + this._owner) : super(reflectee, _s(simpleName)); DeclarationMirror _owner; @@ -907,14 +904,14 @@ class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl } -class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl +class _LocalTypedefMirror extends _LocalDeclarationMirror implements TypedefMirror { - _LocalTypedefMirrorImpl(reflectee, - this._reflectedType, - String simpleName, - this._isGeneric, - this._isGenericDeclaration, - this._owner) + _LocalTypedefMirror(reflectee, + this._reflectedType, + String simpleName, + this._isGeneric, + this._isGenericDeclaration, + this._owner) : super(reflectee, _s(simpleName)); final Type _reflectedType; @@ -927,7 +924,7 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl DeclarationMirror _owner; DeclarationMirror get owner { if (_owner == null) { - _owner = _LocalClassMirrorImpl._library(_reflectee); + _owner = _LocalClassMirror._library(_reflectee); } return _owner; } @@ -959,11 +956,11 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl List get typeVariables { if (_typeVariables == null) { _typeVariables = new List(); - List params = _LocalClassMirrorImpl._ClassMirror_type_variables(_reflectee); + List params = _LocalClassMirror._ClassMirror_type_variables(_reflectee); TypedefMirror owner = originalDeclaration; var mirror; for (var i = 0; i < params.length; i += 2) { - mirror = new _LocalTypeVariableMirrorImpl( + mirror = new _LocalTypeVariableMirror( params[i + 1], params[i], owner); _typeVariables.add(mirror); } @@ -978,7 +975,7 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl _typeArguments = emptyList; } else { _typeArguments = new UnmodifiableListView( - _LocalClassMirrorImpl._computeTypeArguments(_reflectedType)); + _LocalClassMirror._computeTypeArguments(_reflectedType)); } } return _typeArguments; @@ -993,11 +990,11 @@ class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl native "TypedefMirror_declaration"; } -class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl +class _LocalLibraryMirror extends _LocalObjectMirror implements LibraryMirror { - _LocalLibraryMirrorImpl(reflectee, - String simpleName, - String url) + _LocalLibraryMirror(reflectee, + String simpleName, + String url) : this.simpleName = _s(simpleName), this.uri = Uri.parse(url), super(reflectee); @@ -1126,20 +1123,20 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl native "LibraryMirror_members"; } -class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl +class _LocalMethodMirror extends _LocalDeclarationMirror implements MethodMirror { - _LocalMethodMirrorImpl(reflectee, - String simpleName, - this._owner, - this.isStatic, - this.isAbstract, - this.isGetter, - this.isSetter, - this.isConstructor, - this.isConstConstructor, - this.isGenerativeConstructor, - this.isRedirectingConstructor, - this.isFactoryConstructor) + _LocalMethodMirror(reflectee, + String simpleName, + this._owner, + this.isStatic, + this.isAbstract, + this.isGetter, + this.isSetter, + this.isConstructor, + this.isConstConstructor, + this.isGenerativeConstructor, + this.isRedirectingConstructor, + this.isFactoryConstructor) : this.isOperator = _operators.contains(simpleName), super(reflectee, _s(simpleName)); @@ -1261,15 +1258,15 @@ class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl native "MethodMirror_source"; } -class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl +class _LocalVariableMirror extends _LocalDeclarationMirror implements VariableMirror { - _LocalVariableMirrorImpl(reflectee, - String simpleName, - this.owner, - this._type, - this.isStatic, - this.isFinal, - this.isConst) + _LocalVariableMirror(reflectee, + String simpleName, + this.owner, + this._type, + this.isStatic, + this.isFinal, + this.isConst) : super(reflectee, _s(simpleName)); final DeclarationMirror owner; @@ -1303,17 +1300,17 @@ class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl native "VariableMirror_type"; } -class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl +class _LocalParameterMirror extends _LocalVariableMirror implements ParameterMirror { - _LocalParameterMirrorImpl(reflectee, - String simpleName, - DeclarationMirror owner, - this._position, - this.isOptional, - this.isNamed, - bool isFinal, - this._defaultValueReflectee, - this._unmirroredMetadata) + _LocalParameterMirror(reflectee, + String simpleName, + DeclarationMirror owner, + this._position, + this.isOptional, + this.isNamed, + bool isFinal, + this._defaultValueReflectee, + this._unmirroredMetadata) : super(reflectee, simpleName, owner, @@ -1368,9 +1365,9 @@ class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl native "ParameterMirror_type"; } -class _SpecialTypeMirrorImpl extends _LocalMirrorImpl +class _SpecialTypeMirror extends _LocalMirror implements TypeMirror, DeclarationMirror { - _SpecialTypeMirrorImpl(String name) : simpleName = _s(name); + _SpecialTypeMirror(String name) : simpleName = _s(name); final bool isPrivate = false; final DeclarationMirror owner = null; @@ -1393,7 +1390,7 @@ class _SpecialTypeMirrorImpl extends _LocalMirrorImpl // TODO(11955): Remove once dynamicType and voidType are canonical objects in // the object store. bool operator ==(other) { - if (other is! _SpecialTypeMirrorImpl) { + if (other is! _SpecialTypeMirror) { return false; } return this.simpleName == other.simpleName; @@ -1425,8 +1422,8 @@ class _Mirrors { // Creates a new local mirror for some Object. static InstanceMirror reflect(Object reflectee) { return reflectee is Function - ? new _LocalClosureMirrorImpl(reflectee) - : new _LocalInstanceMirrorImpl(reflectee); + ? new _LocalClosureMirror(reflectee) + : new _LocalInstanceMirror(reflectee); } static ClassMirror makeLocalClassMirror(Type key) diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h index 481a058ce54..5401651bd14 100644 --- a/runtime/vm/symbols.h +++ b/runtime/vm/symbols.h @@ -282,17 +282,17 @@ class ObjectPointerVisitor; V(_state, "_state") \ V(_A, "_A") \ V(_stackTrace, "_stackTrace") \ - V(_SpecialTypeMirrorImpl, "_SpecialTypeMirrorImpl") \ - V(_LocalClassMirrorImpl, "_LocalClassMirrorImpl") \ - V(_LocalFunctionTypeMirrorImpl, "_LocalFunctionTypeMirrorImpl") \ - V(_LocalLibraryMirrorImpl, "_LocalLibraryMirrorImpl") \ - V(_LocalMethodMirrorImpl, "_LocalMethodMirrorImpl") \ - V(_LocalVariableMirrorImpl, "_LocalVariableMirrorImpl") \ - V(_LocalParameterMirrorImpl, "_LocalParameterMirrorImpl") \ - V(_LocalIsolateMirrorImpl, "_LocalIsolateMirrorImpl") \ - V(_LocalMirrorSystemImpl, "_LocalMirrorSystemImpl") \ - V(_LocalTypedefMirrorImpl, "_LocalTypedefMirrorImpl") \ - V(_LocalTypeVariableMirrorImpl, "_LocalTypeVariableMirrorImpl") \ + V(_SpecialTypeMirror, "_SpecialTypeMirror") \ + V(_LocalClassMirror, "_LocalClassMirror") \ + V(_LocalFunctionTypeMirror, "_LocalFunctionTypeMirror") \ + V(_LocalLibraryMirror, "_LocalLibraryMirror") \ + V(_LocalMethodMirror, "_LocalMethodMirror") \ + V(_LocalVariableMirror, "_LocalVariableMirror") \ + V(_LocalParameterMirror, "_LocalParameterMirror") \ + V(_LocalIsolateMirror, "_LocalIsolateMirror") \ + V(_LocalMirrorSystem, "_LocalMirrorSystem") \ + V(_LocalTypedefMirror, "_LocalTypedefMirror") \ + V(_LocalTypeVariableMirror, "_LocalTypeVariableMirror") \ V(hashCode, "get:hashCode") \ V(_leftShiftWithMask32, "_leftShiftWithMask32") \ V(OptimizedOut, "") \