2
Copyright (C) 2009 Jeroen Frijters
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
2. Altered source versions must be plainly marked as such, and must not be
17
misrepresented as being the original software.
18
3. This notice may not be removed or altered from any source distribution.
25
using System.Collections.Generic;
28
using IKVM.Reflection.Emit;
29
using IKVM.Reflection.Writer;
30
using IKVM.Reflection.Reader;
32
namespace IKVM.Reflection
34
sealed class FieldSignature : Signature
36
private readonly Type fieldType;
37
private readonly CustomModifiers mods;
39
internal static FieldSignature Create(Type fieldType, CustomModifiers customModifiers)
41
return new FieldSignature(fieldType, customModifiers);
44
private FieldSignature(Type fieldType, CustomModifiers mods)
46
this.fieldType = fieldType;
50
public override bool Equals(object obj)
52
FieldSignature other = obj as FieldSignature;
54
&& other.fieldType.Equals(fieldType)
55
&& other.mods.Equals(mods);
58
public override int GetHashCode()
60
return fieldType.GetHashCode() ^ mods.GetHashCode();
63
internal Type FieldType
65
get { return fieldType; }
68
internal CustomModifiers GetCustomModifiers()
73
internal FieldSignature ExpandTypeParameters(Type declaringType)
75
return new FieldSignature(
76
fieldType.BindTypeParameters(declaringType),
77
mods.Bind(declaringType));
80
internal static FieldSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
82
if (br.ReadByte() != FIELD)
84
throw new BadImageFormatException();
86
CustomModifiers mods = CustomModifiers.Read(module, br, context);
87
Type fieldType = ReadType(module, br, context);
88
return new FieldSignature(fieldType, mods);
91
internal override void WriteSig(ModuleBuilder module, ByteBuffer bb)
94
WriteCustomModifiers(module, bb, mods);
95
WriteType(module, bb, fieldType);