1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using ICSharpCode.NRefactory.TypeSystem.Implementation;
22
namespace ICSharpCode.NRefactory.TypeSystem
24
public sealed class ByReferenceType : TypeWithElementType
26
public ByReferenceType(IType elementType) : base(elementType)
30
public override TypeKind Kind {
31
get { return TypeKind.ByReference; }
34
public override string NameSuffix {
40
public override bool? IsReferenceType {
44
public override int GetHashCode()
46
return elementType.GetHashCode() ^ 91725813;
49
public override bool Equals(IType other)
51
ByReferenceType a = other as ByReferenceType;
52
return a != null && elementType.Equals(a.elementType);
55
public override IType AcceptVisitor(TypeVisitor visitor)
57
return visitor.VisitByReferenceType(this);
60
public override IType VisitChildren(TypeVisitor visitor)
62
IType e = elementType.AcceptVisitor(visitor);
66
return new ByReferenceType(e);
69
public override ITypeReference ToTypeReference()
71
return new ByReferenceTypeReference(elementType.ToTypeReference());
76
public sealed class ByReferenceTypeReference : ITypeReference, ISupportsInterning
78
ITypeReference elementType;
80
public ByReferenceTypeReference(ITypeReference elementType)
82
if (elementType == null)
83
throw new ArgumentNullException("elementType");
84
this.elementType = elementType;
87
public ITypeReference ElementType {
88
get { return elementType; }
91
public IType Resolve(ITypeResolveContext context)
93
return new ByReferenceType(elementType.Resolve(context));
96
public override string ToString()
98
return elementType.ToString() + "&";
101
void ISupportsInterning.PrepareForInterning(IInterningProvider provider)
103
elementType = provider.Intern(elementType);
106
int ISupportsInterning.GetHashCodeForInterning()
108
return elementType.GetHashCode() ^ 91725814;
111
bool ISupportsInterning.EqualsForInterning(ISupportsInterning other)
113
ByReferenceTypeReference brt = other as ByReferenceTypeReference;
114
return brt != null && this.elementType == brt.elementType;