IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
GenericFieldInstance.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009, 2010 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*/
24namespace IKVM.Reflection
25{
26
27 sealed class GenericFieldInstance : FieldInfo
28 {
29
30 readonly Type declaringType;
31 readonly FieldInfo field;
32
38 internal GenericFieldInstance(Type declaringType, FieldInfo field)
39 {
40 this.declaringType = declaringType;
41 this.field = field;
42 }
43
44 public override bool Equals(object obj)
45 {
46 var other = obj as GenericFieldInstance;
47 return other != null && other.declaringType.Equals(declaringType) && other.field.Equals(field);
48 }
49
50 public override int GetHashCode()
51 {
52 return declaringType.GetHashCode() * 3 ^ field.GetHashCode();
53 }
54
55 public override FieldAttributes Attributes
56 {
57 get { return field.Attributes; }
58 }
59
60 public override string Name
61 {
62 get { return field.Name; }
63 }
64
65 public override Type DeclaringType
66 {
67 get { return declaringType; }
68 }
69
70 public override Module Module
71 {
72 get { return declaringType.Module; }
73 }
74
75 public override int MetadataToken
76 {
77 get { return field.MetadataToken; }
78 }
79
80 public override object GetRawConstantValue()
81 {
82 return field.GetRawConstantValue();
83 }
84
85 public override bool __TryGetFieldOffset(out int offset)
86 {
87 return field.__TryGetFieldOffset(out offset);
88 }
89
90 public override FieldInfo __GetFieldOnTypeDefinition()
91 {
92 return field;
93 }
94
95 internal override FieldSignature FieldSignature
96 {
97 get { return field.FieldSignature.ExpandTypeParameters(declaringType); }
98 }
99
100 internal override int ImportTo(Emit.ModuleBuilder module)
101 {
102 return module.ImportMethodOrField(declaringType, field.Name, field.FieldSignature);
103 }
104
105 internal override FieldInfo BindTypeParameters(Type type)
106 {
107 return new GenericFieldInstance(declaringType.BindTypeParameters(type), field);
108 }
109
110 internal override int GetCurrentToken()
111 {
112 return field.GetCurrentToken();
113 }
114
115 internal override bool IsBaked
116 {
117 get { return field.IsBaked; }
118 }
119
120 }
121
122}
IKVM.Reflection.Type Type
IKVM.Reflection.FieldInfo FieldInfo
global::java.lang.invoke.LambdaForm.Name Name
override bool __TryGetFieldOffset(out int offset)