IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
FieldSignature.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 Jeroen Frijters
3
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.
7
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:
11
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.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
27
28namespace IKVM.Reflection
29{
30
32 {
33
34 readonly Type fieldType;
35 readonly CustomModifiers mods;
36
37 internal static FieldSignature Create(Type fieldType, CustomModifiers customModifiers)
38 {
39 return new FieldSignature(fieldType, customModifiers);
40 }
41
47 private FieldSignature(Type fieldType, CustomModifiers mods)
48 {
49 this.fieldType = fieldType;
50 this.mods = mods;
51 }
52
53 public override bool Equals(object obj)
54 {
55 var other = obj as FieldSignature;
56 return other != null
57 && other.fieldType.Equals(fieldType)
58 && other.mods.Equals(mods);
59 }
60
61 public override int GetHashCode()
62 {
63 return fieldType.GetHashCode() ^ mods.GetHashCode();
64 }
65
66 internal Type FieldType
67 {
68 get { return fieldType; }
69 }
70
71 internal CustomModifiers GetCustomModifiers()
72 {
73 return mods;
74 }
75
76 internal FieldSignature ExpandTypeParameters(Type declaringType)
77 {
78 return new FieldSignature(
79 fieldType.BindTypeParameters(declaringType),
80 mods.Bind(declaringType));
81 }
82
83 internal static FieldSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
84 {
85 if (br.ReadByte() != FIELD)
86 throw new BadImageFormatException();
87
88 var mods = CustomModifiers.Read(module, br, context);
89 var fieldType = ReadType(module, br, context);
90 return new FieldSignature(fieldType, mods);
91 }
92
93 internal override void Write(ModuleBuilder module, ByteBuffer bb)
94 {
95 bb.Write(FIELD);
96 WriteCustomModifiers(module, bb, mods);
97 WriteType(module, bb, fieldType);
98 }
99
100 }
101
102}
IKVM.Reflection.Type Type
override bool Equals(object obj)
static Type ReadType(ModuleReader module, ByteReader br, IGenericContext context)
Definition Signature.cs:202
static void WriteCustomModifiers(ModuleBuilder module, ByteBuffer bb, CustomModifiers modifiers)
Definition Signature.cs:419
static void WriteType(ModuleBuilder module, ByteBuffer bb, Type type)
Definition Signature.cs:339