Browse Source

Remove more dead TypeSystem code: ISymbolReference

pull/1108/head
Daniel Grunwald 8 years ago
parent
commit
4c45a41fdb
  1. 10
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpOperators.cs
  2. 38
      ICSharpCode.Decompiler/CSharp/Resolver/ReducedExtensionMethod.cs
  3. 5
      ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
  4. 5
      ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs
  5. 3
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  6. 2
      ICSharpCode.Decompiler/TypeSystem/IField.cs
  7. 13
      ICSharpCode.Decompiler/TypeSystem/IMember.cs
  8. 10
      ICSharpCode.Decompiler/TypeSystem/ISymbol.cs
  9. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs
  10. 16
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs
  11. 31
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
  12. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs
  13. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs
  14. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs
  15. 58
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultParameter.cs
  16. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedField.cs
  17. 13
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedMethod.cs
  18. 13
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedProperty.cs
  19. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs
  20. 61
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
  21. 7
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
  22. 30
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultVariable.cs
  23. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs
  24. 80
      ICSharpCode.Decompiler/TypeSystem/Implementation/ExplicitInterfaceImplementationMemberReference.cs
  25. 10
      ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
  26. 5
      ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
  27. 10
      ICSharpCode.Decompiler/TypeSystem/Implementation/NestedTypeReference.cs
  28. 21
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
  29. 23
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMethod.cs
  30. 67
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializingMemberReference.cs
  31. 7
      ICSharpCode.Decompiler/TypeSystem/Implementation/TypeParameterReference.cs
  32. 56
      ICSharpCode.Decompiler/TypeSystem/ProjectReference.cs
  33. 152
      ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
  34. 12
      ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs

10
ICSharpCode.Decompiler/CSharp/Resolver/CSharpOperators.cs

@ -214,16 +214,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -214,16 +214,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
get { return compilation.MainAssembly; }
}
ISymbolReference ISymbol.ToReference()
{
throw new NotSupportedException();
}
IMemberReference IMember.ToReference()
{
throw new NotSupportedException();
}
TypeParameterSubstitution IMember.Substitution {
get {
return TypeParameterSubstitution.Identity;

38
ICSharpCode.Decompiler/CSharp/Resolver/ReducedExtensionMethod.cs

@ -66,44 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -66,44 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
#region IMember implementation
[Serializable]
public sealed class ReducedExtensionMethodMemberReference : IMemberReference
{
readonly IMethod baseMethod;
public ReducedExtensionMethodMemberReference (IMethod baseMethod)
{
this.baseMethod = baseMethod;
}
public IMember Resolve(ITypeResolveContext context)
{
return new ReducedExtensionMethod ((IMethod)baseMethod.ToReference ().Resolve (context));
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
public ITypeReference DeclaringTypeReference {
get {
return baseMethod.ToReference ().DeclaringTypeReference;
}
}
}
public IMemberReference ToReference()
{
return new ReducedExtensionMethodMemberReference (baseMethod);
}
ISymbolReference ISymbol.ToReference()
{
return ToReference();
}
public IMember MemberDefinition {
get {
return baseMethod.MemberDefinition;

5
ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs

@ -201,11 +201,6 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -201,11 +201,6 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
{
return null;
}
public ISymbolReference ToReference()
{
return new MergedNamespaceReference(ExternAlias, ((INamespace)this).FullName);
}
}
}
}

5
ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs

@ -68,10 +68,5 @@ namespace ICSharpCode.Decompiler.Documentation @@ -68,10 +68,5 @@ namespace ICSharpCode.Decompiler.Documentation
}
return null;
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
}
}

3
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -489,7 +489,6 @@ @@ -489,7 +489,6 @@
<Compile Include="TypeSystem\Implementation\DefaultUnresolvedTypeParameter.cs" />
<Compile Include="TypeSystem\Implementation\DefaultVariable.cs" />
<Compile Include="TypeSystem\Implementation\DummyTypeParameter.cs" />
<Compile Include="TypeSystem\Implementation\ExplicitInterfaceImplementationMemberReference.cs" />
<Compile Include="TypeSystem\Implementation\GetClassTypeReference.cs" />
<Compile Include="TypeSystem\Implementation\GetMembersHelper.cs" />
<Compile Include="TypeSystem\Implementation\KnownTypeCache.cs" />
@ -505,7 +504,6 @@ @@ -505,7 +504,6 @@
<Compile Include="TypeSystem\Implementation\SpecializedMember.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedMethod.cs" />
<Compile Include="TypeSystem\Implementation\SpecializedProperty.cs" />
<Compile Include="TypeSystem\Implementation\SpecializingMemberReference.cs" />
<Compile Include="TypeSystem\Implementation\TypeParameterReference.cs" />
<Compile Include="TypeSystem\Implementation\TypeWithElementType.cs" />
<Compile Include="TypeSystem\Implementation\UnknownType.cs" />
@ -534,7 +532,6 @@ @@ -534,7 +532,6 @@
<Compile Include="TypeSystem\ParameterizedType.cs" />
<Compile Include="TypeSystem\ParameterListComparer.cs" />
<Compile Include="TypeSystem\PointerType.cs" />
<Compile Include="TypeSystem\ProjectReference.cs" />
<Compile Include="TypeSystem\ReflectionHelper.cs" />
<Compile Include="TypeSystem\ReflectionNameParseException.cs" />
<Compile Include="TypeSystem\SimpleTypeResolveContext.cs" />

2
ICSharpCode.Decompiler/TypeSystem/IField.cs

@ -85,7 +85,5 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -85,7 +85,5 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// If this is true, then ConstantValue contains the size of the buffer.
/// </summary>
bool IsFixed { get; }
new IMemberReference ToReference(); // solve ambiguity between IMember.ToReference() and IVariable.ToReference()
}
}

13
ICSharpCode.Decompiler/TypeSystem/IMember.cs

@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
IMember CreateResolved(ITypeResolveContext context);
}
public interface IMemberReference : ISymbolReference
public interface IMemberReference
{
/// <summary>
/// Gets the declaring type reference for the member.
@ -100,7 +100,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -100,7 +100,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <returns>
/// Returns the resolved member, or <c>null</c> if the member could not be found.
/// </returns>
new IMember Resolve(ITypeResolveContext context);
IMember Resolve(ITypeResolveContext context);
}
/// <summary>
@ -159,15 +159,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -159,15 +159,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </summary>
bool IsOverridable { get; }
/// <summary>
/// Creates a member reference that can be used to rediscover this member in another compilation.
/// </summary>
/// <remarks>
/// If this member is specialized using open generic types, the resulting member reference will need to be looked up in an appropriate generic context.
/// Otherwise, the main resolve context of a compilation is sufficient.
/// </remarks>
new IMemberReference ToReference();
/// <summary>
/// Gets the substitution belonging to this specialized member.
/// Returns TypeParameterSubstitution.Identity for not specialized members.

10
ICSharpCode.Decompiler/TypeSystem/ISymbol.cs

@ -84,15 +84,5 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -84,15 +84,5 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the short name of the symbol.
/// </summary>
string Name { get; }
/// <summary>
/// Creates a symbol reference that can be used to rediscover this symbol in another compilation.
/// </summary>
ISymbolReference ToReference();
}
public interface ISymbolReference
{
ISymbol Resolve(ITypeResolveContext context);
}
}

2
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedEntity.cs

@ -60,8 +60,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -60,8 +60,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public IReadOnlyList<IAttribute> Attributes { get; protected set; }
public abstract ISymbolReference ToReference();
public bool IsStatic { get { return unresolved.IsStatic; } }
public bool IsAbstract { get { return unresolved.IsAbstract; } }
public bool IsSealed { get { return unresolved.IsSealed; } }

16
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedMember.cs

@ -113,22 +113,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -113,22 +113,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public abstract IMember Specialize(TypeParameterSubstitution substitution);
IMemberReference IMember.ToReference()
{
return (IMemberReference)ToReference();
}
public override ISymbolReference ToReference()
{
var declType = this.DeclaringType;
var declTypeRef = declType != null ? declType.ToTypeReference() : SpecialType.UnknownType;
if (IsExplicitInterfaceImplementation && ImplementedInterfaceMembers.Count == 1) {
return new ExplicitInterfaceImplementationMemberReference(declTypeRef, ImplementedInterfaceMembers[0].ToReference());
} else {
return new DefaultMemberReference(this.SymbolKind, declTypeRef, this.Name);
}
}
internal IMethod GetAccessor(ref IMethod accessorField, IUnresolvedMethod unresolvedAccessor)
{
if (unresolvedAccessor == null)

31
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs

@ -364,41 +364,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -364,41 +364,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
return this == other; // use reference equality for type parameters
}
public virtual ISymbolReference ToReference()
{
if (owner == null)
return TypeParameterReference.Create(ownerType, index);
return new OwnedTypeParameterReference(owner.ToReference(), index);
}
public override string ToString()
{
return this.ReflectionName + " (owner=" + owner + ")";
}
}
public sealed class OwnedTypeParameterReference : ISymbolReference
{
ISymbolReference owner;
int index;
public OwnedTypeParameterReference(ISymbolReference owner, int index)
{
if (owner == null)
throw new ArgumentNullException("owner");
this.owner = owner;
this.index = index;
}
public ISymbol Resolve(ITypeResolveContext context)
{
var entity = owner.Resolve(context) as IEntity;
if (entity is ITypeDefinition)
return ((ITypeDefinition)entity).TypeParameters[index];
if (entity is IMethod)
return ((IMethod)entity).TypeParameters[index];
return null;
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/AbstractUnresolvedMember.cs

@ -152,11 +152,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -152,11 +152,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return Resolve(ExtendContextForType(context, this.DeclaringTypeDefinition), this.SymbolKind, this.Name, interfaceTypeReference);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return ((IUnresolvedMember)this).Resolve(context);
}
protected static ITypeResolveContext ExtendContextForType(ITypeResolveContext assemblyContext, IUnresolvedTypeDefinition typeDef)
{
if (typeDef == null)

5
ICSharpCode.Decompiler/TypeSystem/Implementation/AccessorOwnerMemberReference.cs

@ -47,10 +47,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -47,10 +47,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
else
return null;
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return ((IMemberReference)this).Resolve(context);
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultMemberReference.cs

@ -99,11 +99,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -99,11 +99,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return null;
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return ((IMemberReference)this).Resolve(context);
}
int ISupportsInterning.GetHashCodeForInterning()
{
return (int)symbolKind ^ typeReference.GetHashCode() ^ name.GetHashCode() ^ parameterTypes.GetHashCode();

58
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultParameter.cs

@ -133,63 +133,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -133,63 +133,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
return b.ToString();
}
public ISymbolReference ToReference()
{
if (owner == null)
return new ParameterReference(type.ToTypeReference(), name, isRef, isOut, isParams, isOptional, defaultValue);
return new OwnedParameterReference(owner.ToReference(), owner.Parameters.IndexOf(this));
}
}
sealed class OwnedParameterReference : ISymbolReference
{
readonly IMemberReference memberReference;
readonly int index;
public OwnedParameterReference(IMemberReference member, int index)
{
if (member == null)
throw new ArgumentNullException("member");
this.memberReference = member;
this.index = index;
}
public ISymbol Resolve(ITypeResolveContext context)
{
IParameterizedMember member = memberReference.Resolve(context) as IParameterizedMember;
if (member != null && index >= 0 && index < member.Parameters.Count)
return member.Parameters[index];
else
return null;
}
}
public sealed class ParameterReference : ISymbolReference
{
readonly ITypeReference type;
readonly string name;
readonly bool isRef, isOut, isParams, isOptional;
readonly object defaultValue;
public ParameterReference(ITypeReference type, string name, bool isRef, bool isOut, bool isParams, bool isOptional, object defaultValue)
{
if (type == null)
throw new ArgumentNullException("type");
if (name == null)
throw new ArgumentNullException("name");
this.type = type;
this.name = name;
this.isRef = isRef;
this.isOut = isOut;
this.isParams = isParams;
this.isOptional = isOptional;
this.defaultValue = defaultValue;
}
public ISymbol Resolve(ITypeResolveContext context)
{
return new DefaultParameter(type.Resolve(context), name, isRef: isRef, isOut: isOut, isParams: isParams, isOptional: isOptional, defaultValue: defaultValue);
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedField.cs

@ -81,10 +81,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -81,10 +81,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
substitution = new TypeParameterSubstitution(substitution.ClassTypeArguments, EmptyList<IType>.Instance);
return new SpecializedField(this, substitution);
}
IMemberReference IField.ToReference()
{
return (IMemberReference)ToReference();
}
}
}

13
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedMethod.cs

@ -228,19 +228,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -228,19 +228,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
public override ISymbolReference ToReference()
{
var declType = this.DeclaringType;
var declTypeRef = declType != null ? declType.ToTypeReference() : SpecialType.UnknownType;
if (IsExplicitInterfaceImplementation && ImplementedInterfaceMembers.Count == 1) {
return new ExplicitInterfaceImplementationMemberReference(declTypeRef, ImplementedInterfaceMembers[0].ToReference());
} else {
return new DefaultMemberReference(
this.SymbolKind, declTypeRef, this.Name, this.TypeParameters.Count,
this.Parameters.Select(p => p.Type.ToTypeReference()).ToList());
}
}
public override IMember Specialize(TypeParameterSubstitution substitution)
{
if (TypeParameterSubstitution.Identity.Equals(substitution))

13
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedProperty.cs

@ -84,19 +84,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -84,19 +84,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return unresolved.IsIndexer; }
}
public override ISymbolReference ToReference()
{
var declType = this.DeclaringType;
var declTypeRef = declType != null ? declType.ToTypeReference() : SpecialType.UnknownType;
if (IsExplicitInterfaceImplementation && ImplementedInterfaceMembers.Count == 1) {
return new ExplicitInterfaceImplementationMemberReference(declTypeRef, ImplementedInterfaceMembers[0].ToReference());
} else {
return new DefaultMemberReference(
this.SymbolKind, declTypeRef, this.Name, 0,
this.Parameters.Select(p => p.Type.ToTypeReference()).ToList());
}
}
public override IMember Specialize(TypeParameterSubstitution substitution)
{
if (TypeParameterSubstitution.Identity.Equals(substitution)

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs

@ -633,11 +633,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -633,11 +633,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
ISymbolReference ISymbol.ToReference()
{
return (ISymbolReference)ToTypeReference();
}
public IEnumerable<IType> GetNestedTypes(Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None)
{
const GetMemberOptions opt = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions;

61
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs

@ -567,68 +567,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -567,68 +567,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
else
return null;
}
public ISymbolReference ToReference()
{
return new NamespaceReference(new DefaultAssemblyReference(assembly.AssemblyName), ns.FullName);
}
}
}
}
public sealed class NamespaceReference : ISymbolReference
{
IAssemblyReference assemblyReference;
string fullName;
public NamespaceReference(IAssemblyReference assemblyReference, string fullName)
{
if (assemblyReference == null)
throw new ArgumentNullException("assemblyReference");
this.assemblyReference = assemblyReference;
this.fullName = fullName;
}
public ISymbol Resolve(ITypeResolveContext context)
{
IAssembly assembly = assemblyReference.Resolve(context);
INamespace parent = assembly.RootNamespace;
string[] parts = fullName.Split('.');
int i = 0;
while (i < parts.Length && parent != null) {
parent = parent.GetChildNamespace(parts[i]);
i++;
}
return parent;
}
}
public sealed class MergedNamespaceReference : ISymbolReference
{
string externAlias;
string fullName;
public MergedNamespaceReference(string externAlias, string fullName)
{
this.externAlias = externAlias;
this.fullName = fullName;
}
public ISymbol Resolve(ITypeResolveContext context)
{
string[] parts = fullName.Split('.');
INamespace parent = context.Compilation.GetNamespaceForExternAlias(externAlias);
int i = 0;
while (i < parts.Length && parent != null) {
parent = parent.GetChildNamespace(parts[i]);
i++;
}
return parent;
}
}
}

7
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultUnresolvedParameter.cs

@ -252,13 +252,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -252,13 +252,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
return DefaultParameter.ToString(this);
}
public ISymbolReference ToReference()
{
if (Owner == null)
return new ParameterReference(Type.ToTypeReference(), Name, IsRef, IsOut, IsParams, true, ConstantValue);
return new OwnedParameterReference(Owner.ToReference(), Owner.Parameters.IndexOf(this));
}
}
}
}

30
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultVariable.cs

@ -67,35 +67,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -67,35 +67,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public SymbolKind SymbolKind {
get { return SymbolKind.Variable; }
}
public ISymbolReference ToReference()
{
return new VariableReference(type.ToTypeReference(), name, isConst, constantValue);
}
}
public sealed class VariableReference : ISymbolReference
{
ITypeReference variableTypeReference;
string name;
bool isConst;
object constantValue;
public VariableReference(ITypeReference variableTypeReference, string name, bool isConst, object constantValue)
{
if (variableTypeReference == null)
throw new ArgumentNullException("variableTypeReference");
if (name == null)
throw new ArgumentNullException("name");
this.variableTypeReference = variableTypeReference;
this.name = name;
this.isConst = isConst;
this.constantValue = constantValue;
}
public ISymbol Resolve(ITypeResolveContext context)
{
return new DefaultVariable(variableTypeReference.Resolve(context), name, isConst, constantValue);
}
}
}

5
ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs

@ -237,10 +237,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -237,10 +237,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool ITypeParameter.HasValueTypeConstraint {
get { return false; }
}
public ISymbolReference ToReference()
{
return new TypeParameterReference(ownerType, index);
}
}
}

80
ICSharpCode.Decompiler/TypeSystem/Implementation/ExplicitInterfaceImplementationMemberReference.cs

@ -1,80 +0,0 @@ @@ -1,80 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
/// <summary>
/// References a member that is an explicit interface implementation.
/// </summary>
/// <remarks>
/// Resolving an ExplicitInterfaceImplementationMemberReference requires a context
/// that provides enough information for resolving the declaring type reference
/// and the interface member reference.
/// Note that the interface member reference is resolved in '<c>context.WithCurrentTypeDefinition(declaringType.GetDefinition())</c>'
/// - this is done to ensure that open generics in the interface member reference resolve to the type parameters of the
/// declaring type.
/// </remarks>
[Serializable]
public sealed class ExplicitInterfaceImplementationMemberReference : IMemberReference
{
ITypeReference typeReference;
IMemberReference interfaceMemberReference;
public ExplicitInterfaceImplementationMemberReference(ITypeReference typeReference, IMemberReference interfaceMemberReference)
{
if (typeReference == null)
throw new ArgumentNullException("typeReference");
if (interfaceMemberReference == null)
throw new ArgumentNullException("interfaceMemberReference");
this.typeReference = typeReference;
this.interfaceMemberReference = interfaceMemberReference;
}
public ITypeReference DeclaringTypeReference {
get { return typeReference; }
}
public IMember Resolve(ITypeResolveContext context)
{
IType declaringType = typeReference.Resolve(context);
IMember interfaceMember = interfaceMemberReference.Resolve(context.WithCurrentTypeDefinition(declaringType.GetDefinition()));
if (interfaceMember == null)
return null;
IEnumerable<IMember> members;
if (interfaceMember.SymbolKind == SymbolKind.Accessor) {
members = declaringType.GetAccessors(
m => m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
} else {
members = declaringType.GetMembers(
m => m.SymbolKind == interfaceMember.SymbolKind && m.IsExplicitInterfaceImplementation,
GetMemberOptions.IgnoreInheritedMembers);
}
return members.FirstOrDefault(m => m.ImplementedInterfaceMembers.Count == 1 && interfaceMember.Equals(m.ImplementedInterfaceMembers[0]));
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
}
}

10
ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// Type Reference used when the fully qualified type name is known.
/// </summary>
[Serializable]
public sealed class GetClassTypeReference : ITypeReference, ISymbolReference, ISupportsInterning
public sealed class GetClassTypeReference : ITypeReference, ISupportsInterning
{
readonly IAssemblyReference assembly;
readonly FullTypeName fullTypeName;
@ -124,14 +124,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -124,14 +124,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return type ?? new UnknownType(fullTypeName, isReferenceType);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
var type = Resolve(context);
if (type is ITypeDefinition)
return (ISymbol)type;
return null;
}
public override string ToString()
{
return fullTypeName.ToString() + (assembly != null ? ", " + assembly.ToString() : null);

5
ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs

@ -155,10 +155,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -155,10 +155,5 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return string.Format(CultureInfo.InvariantCulture, "[MergedNamespace {0}{1} (from {2} assemblies)]",
externAlias != null ? externAlias + "::" : null, this.FullName, this.namespaces.Length);
}
public ISymbolReference ToReference()
{
return new MergedNamespaceReference(externAlias, FullName);
}
}
}

10
ICSharpCode.Decompiler/TypeSystem/Implementation/NestedTypeReference.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// Type reference used to reference nested types.
/// </summary>
[Serializable]
public sealed class NestedTypeReference : ITypeReference, ISymbolReference, ISupportsInterning
public sealed class NestedTypeReference : ITypeReference, ISupportsInterning
{
readonly ITypeReference declaringTypeRef;
readonly string name;
@ -78,14 +78,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -78,14 +78,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return new UnknownType(null, name, additionalTypeParameterCount);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
var type = Resolve(context);
if (type is ITypeDefinition)
return (ISymbol)type;
return null;
}
public override string ToString()
{
if (additionalTypeParameterCount == 0)

21
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs

@ -58,27 +58,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -58,27 +58,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.substitution = TypeParameterSubstitution.Compose(newSubstitution, this.substitution);
}
public virtual IMemberReference ToReference()
{
return new SpecializingMemberReference(
baseMember.ToReference(),
ToTypeReference(substitution.ClassTypeArguments),
null);
}
ISymbolReference ISymbol.ToReference()
{
return ToReference();
}
internal static IList<ITypeReference> ToTypeReference(IReadOnlyList<IType> typeArguments)
{
if (typeArguments == null)
return null;
else
return typeArguments.Select(t => t.ToTypeReference()).ToArray();
}
internal IMethod WrapAccessor(ref IMethod cachingField, IMethod accessorDefinition)
{
if (accessorDefinition == null)

23
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMethod.cs

@ -147,29 +147,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -147,29 +147,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
accessorOwner = value;
}
}
public override IMemberReference ToReference()
{
// Pass the MethodTypeArguments to the SpecializingMemberReference only if
// the generic method itself is parameterized, not if the generic method is only
// specialized with class type arguments.
// This is necessary due to this part of the ToReference() contract:
// If this member is specialized using open generic types, the resulting member reference will need to be looked up in an appropriate generic context.
// Otherwise, the main resolve context of a compilation is sufficient.
// ->
// This means that if the method itself isn't specialized,
// we must not include TypeParameterReferences for the specialized type parameters
// in the resulting member reference.
if (isParameterized) {
return new SpecializingMemberReference(
baseMember.ToReference(),
ToTypeReference(base.Substitution.ClassTypeArguments),
ToTypeReference(base.Substitution.MethodTypeArguments));
} else {
return base.ToReference();
}
}
public override bool Equals(object obj)
{

67
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializingMemberReference.cs

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
[Serializable]
public sealed class SpecializingMemberReference : IMemberReference
{
IMemberReference memberDefinitionReference;
IList<ITypeReference> classTypeArgumentReferences;
IList<ITypeReference> methodTypeArgumentReferences;
public SpecializingMemberReference(IMemberReference memberDefinitionReference, IList<ITypeReference> classTypeArgumentReferences = null, IList<ITypeReference> methodTypeArgumentReferences = null)
{
if (memberDefinitionReference == null)
throw new ArgumentNullException("memberDefinitionReference");
this.memberDefinitionReference = memberDefinitionReference;
this.classTypeArgumentReferences = classTypeArgumentReferences;
this.methodTypeArgumentReferences = methodTypeArgumentReferences;
}
public IMember Resolve(ITypeResolveContext context)
{
var memberDefinition = memberDefinitionReference.Resolve(context);
if (memberDefinition == null)
return null;
return memberDefinition.Specialize(
new TypeParameterSubstitution(
classTypeArgumentReferences != null ? classTypeArgumentReferences.Resolve(context) : null,
methodTypeArgumentReferences != null ? methodTypeArgumentReferences.Resolve(context) : null
)
);
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context);
}
public ITypeReference DeclaringTypeReference {
get {
if (classTypeArgumentReferences != null)
return new ParameterizedTypeReference(memberDefinitionReference.DeclaringTypeReference, classTypeArgumentReferences);
else
return memberDefinitionReference.DeclaringTypeReference;
}
}
}
}

7
ICSharpCode.Decompiler/TypeSystem/Implementation/TypeParameterReference.cs

@ -23,7 +23,7 @@ using ICSharpCode.Decompiler.Util; @@ -23,7 +23,7 @@ using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
[Serializable]
public sealed class TypeParameterReference : ITypeReference, ISymbolReference
public sealed class TypeParameterReference : ITypeReference
{
static readonly TypeParameterReference[] classTypeParameterReferences = new TypeParameterReference[8];
static readonly TypeParameterReference[] methodTypeParameterReferences = new TypeParameterReference[8];
@ -80,11 +80,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -80,11 +80,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
ISymbol ISymbolReference.Resolve(ITypeResolveContext context)
{
return Resolve(context) as ISymbol;
}
public override string ToString()
{
if (ownerType == SymbolKind.Method)

56
ICSharpCode.Decompiler/TypeSystem/ProjectReference.cs

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.Decompiler.TypeSystem
{
/// <summary>
/// References another project content in the same solution.
/// Using the <see cref="ProjectReference"/> class requires that you
/// </summary>
[Serializable]
public class ProjectReference : IAssemblyReference
{
readonly string projectFileName;
/// <summary>
/// Creates a new reference to the specified project (must be part of the same solution).
/// </summary>
/// <param name="projectFileName">Full path to the file name. Must be identical to <see cref="IProjectContent.ProjectFileName"/> of the target project; do not use a relative path.</param>
public ProjectReference(string projectFileName)
{
this.projectFileName = projectFileName;
}
public IAssembly Resolve(ITypeResolveContext context)
{
var solution = context.Compilation.SolutionSnapshot;
var pc = solution.GetProjectContent(projectFileName);
if (pc != null)
return pc.Resolve(context);
else
return null;
}
public override string ToString()
{
return string.Format("[ProjectReference {0}]", projectFileName);
}
}
}

152
ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs

@ -208,69 +208,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -208,69 +208,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
#endregion
#region Import
/// <summary>
/// Imports a symbol from another compilation.
/// </summary>
public static ISymbol Import(this ICompilation compilation, ISymbol symbol)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (symbol == null)
return null;
switch (symbol.SymbolKind) {
case SymbolKind.TypeParameter:
return (ITypeParameter)Import(compilation, (IType)symbol);
case SymbolKind.Variable:
IVariable v = (IVariable)symbol;
return new DefaultVariable(
Import(compilation, v.Type),
v.Name, v.IsConst, v.ConstantValue
);
case SymbolKind.Parameter:
IParameter p = (IParameter)symbol;
if (p.Owner != null) {
int index = p.Owner.Parameters.IndexOf(p);
var owner = (IParameterizedMember)Import(compilation, p.Owner);
if (owner == null || index < 0 || index >= owner.Parameters.Count)
return null;
return owner.Parameters[index];
} else {
return new DefaultParameter(
Import(compilation, p.Type),
p.Name, null,
null, p.IsRef, p.IsOut, p.IsParams
);
}
case SymbolKind.Namespace:
return Import(compilation, (INamespace)symbol);
default:
if (symbol is IEntity)
return Import(compilation, (IEntity)symbol);
throw new NotSupportedException("Unsupported symbol kind: " + symbol.SymbolKind);
}
}
/// <summary>
/// Imports a type from another compilation.
/// </summary>
public static IType Import(this ICompilation compilation, IType type)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (type == null)
return null;
var compilationProvider = type as ICompilationProvider;
if (compilationProvider != null && compilationProvider.Compilation == compilation)
return type;
IEntity typeParameterOwner = GetTypeParameterOwner(type);
IEntity importedTypeParameterOwner = compilation.Import(typeParameterOwner);
if (importedTypeParameterOwner != null) {
return type.ToTypeReference().Resolve(new SimpleTypeResolveContext(importedTypeParameterOwner));
} else {
return type.ToTypeReference().Resolve(compilation.TypeResolveContext);
}
}
/// <summary>
/// Imports a type from another compilation.
/// </summary>
@ -284,95 +221,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -284,95 +221,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
return typeDefinition;
return typeDefinition.ToTypeReference().Resolve(compilation.TypeResolveContext).GetDefinition();
}
/// <summary>
/// Imports an entity from another compilation.
/// </summary>
public static IEntity Import(this ICompilation compilation, IEntity entity)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (entity == null)
return null;
if (entity.Compilation == compilation)
return entity;
if (entity is IMember)
return ((IMember)entity).ToReference().Resolve(compilation.TypeResolveContext);
else if (entity is ITypeDefinition)
return ((ITypeDefinition)entity).ToTypeReference().Resolve(compilation.TypeResolveContext).GetDefinition();
else
throw new NotSupportedException("Unknown entity type");
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IMember Import(this ICompilation compilation, IMember member)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (member == null)
return null;
if (member.Compilation == compilation)
return member;
return member.ToReference().Resolve(compilation.TypeResolveContext);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IMethod Import(this ICompilation compilation, IMethod method)
{
return (IMethod)compilation.Import((IMember)method);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IField Import(this ICompilation compilation, IField field)
{
return (IField)compilation.Import((IMember)field);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IEvent Import(this ICompilation compilation, IEvent ev)
{
return (IEvent)compilation.Import((IMember)ev);
}
/// <summary>
/// Imports a member from another compilation.
/// </summary>
public static IProperty Import(this ICompilation compilation, IProperty property)
{
return (IProperty)compilation.Import((IMember)property);
}
/// <summary>
/// Imports a namespace from another compilation.
/// </summary>
/// <remarks>
/// This method may return null if the namespace does not exist in the target compilation.
/// </remarks>
public static INamespace Import(this ICompilation compilation, INamespace ns)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (ns == null)
return null;
if (ns.ParentNamespace == null) {
// root namespace
return compilation.GetNamespaceForExternAlias(ns.ExternAlias);
} else {
INamespace parent = Import(compilation, ns.ParentNamespace);
if (parent != null)
return parent.GetChildNamespace(ns.Name);
else
return null;
}
}
#endregion
#region GetDelegateInvokeMethod

12
ICSharpCode.Decompiler/TypeSystem/VarArgInstanceMethod.cs

@ -164,11 +164,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -164,11 +164,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
#region IMember implementation
public IMemberReference ToReference()
{
throw new NotImplementedException();
}
IMember IMember.Specialize(TypeParameterSubstitution substitution)
{
return Specialize(substitution);
@ -213,12 +208,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -213,12 +208,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
#endregion
#region ISymbol implementation
ISymbolReference ISymbol.ToReference()
{
return ToReference();
}
public SymbolKind SymbolKind {
get { return baseMethod.SymbolKind; }
}

Loading…
Cancel
Save