16 changed files with 325 additions and 18 deletions
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a specialized IEvent (e.g. after type substitution).
|
||||
/// </summary>
|
||||
public class SpecializedEvent : DefaultEvent |
||||
{ |
||||
readonly IMember memberDefinition; |
||||
IType declaringType; |
||||
|
||||
public SpecializedEvent(IEvent e) : base(e) |
||||
{ |
||||
this.memberDefinition = e.MemberDefinition; |
||||
this.declaringType = e.DeclaringType; |
||||
} |
||||
|
||||
public override IType DeclaringType { |
||||
get { return declaringType; } |
||||
} |
||||
|
||||
public void SetDeclaringType(IType declaringType) |
||||
{ |
||||
CheckBeforeMutation(); |
||||
this.declaringType = declaringType; |
||||
} |
||||
|
||||
public override IMember MemberDefinition { |
||||
get { return memberDefinition; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a specialized IField (e.g. after type substitution).
|
||||
/// </summary>
|
||||
public class SpecializedField : DefaultField |
||||
{ |
||||
readonly IMember memberDefinition; |
||||
IType declaringType; |
||||
|
||||
public SpecializedField(IField f) : base(f) |
||||
{ |
||||
this.memberDefinition = f.MemberDefinition; |
||||
this.declaringType = f.DeclaringType; |
||||
} |
||||
|
||||
public override IType DeclaringType { |
||||
get { return declaringType; } |
||||
} |
||||
|
||||
public void SetDeclaringType(IType declaringType) |
||||
{ |
||||
CheckBeforeMutation(); |
||||
this.declaringType = declaringType; |
||||
} |
||||
|
||||
public override IMember MemberDefinition { |
||||
get { return memberDefinition; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a specialized IMethod (e.g. after type substitution).
|
||||
/// </summary>
|
||||
public class SpecializedMethod : DefaultMethod |
||||
{ |
||||
readonly IMember memberDefinition; |
||||
IType declaringType; |
||||
|
||||
public SpecializedMethod(IMethod m) : base(m) |
||||
{ |
||||
this.memberDefinition = m.MemberDefinition; |
||||
this.declaringType = m.DeclaringType; |
||||
} |
||||
|
||||
public override IType DeclaringType { |
||||
get { return declaringType; } |
||||
} |
||||
|
||||
public void SetDeclaringType(IType declaringType) |
||||
{ |
||||
CheckBeforeMutation(); |
||||
this.declaringType = declaringType; |
||||
} |
||||
|
||||
public override IMember MemberDefinition { |
||||
get { return memberDefinition; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Performts type substitution in parameter types and in the return type.
|
||||
/// </summary>
|
||||
public void SubstituteTypes(ITypeResolveContext context, TypeVisitor substitution) |
||||
{ |
||||
this.ReturnType = this.ReturnType.Resolve(context).AcceptVisitor(substitution); |
||||
var p = this.Parameters; |
||||
for (int i = 0; i < p.Count; i++) { |
||||
IType newType = p[i].Type.Resolve(context).AcceptVisitor(substitution); |
||||
if (newType != p[i].Type) { |
||||
p[i] = new DefaultParameter(p[i]) { Type = newType }; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a specialized IProperty (e.g. after type substitution).
|
||||
/// </summary>
|
||||
public class SpecializedProperty : DefaultProperty |
||||
{ |
||||
readonly IMember memberDefinition; |
||||
IType declaringType; |
||||
|
||||
public SpecializedProperty(IProperty p) : base(p) |
||||
{ |
||||
this.memberDefinition = p.MemberDefinition; |
||||
this.declaringType = p.DeclaringType; |
||||
} |
||||
|
||||
public override IType DeclaringType { |
||||
get { return declaringType; } |
||||
} |
||||
|
||||
public void SetDeclaringType(IType declaringType) |
||||
{ |
||||
CheckBeforeMutation(); |
||||
this.declaringType = declaringType; |
||||
} |
||||
|
||||
public override IMember MemberDefinition { |
||||
get { return memberDefinition; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Performts type substitution in parameter types and in the return type.
|
||||
/// </summary>
|
||||
public void SubstituteTypes(ITypeResolveContext context, TypeVisitor substitution) |
||||
{ |
||||
this.ReturnType = this.ReturnType.Resolve(context).AcceptVisitor(substitution); |
||||
var p = this.Parameters; |
||||
for (int i = 0; i < p.Count; i++) { |
||||
IType newType = p[i].Type.Resolve(context).AcceptVisitor(substitution); |
||||
if (newType != p[i].Type) { |
||||
p[i] = new DefaultParameter(p[i]) { Type = newType }; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue