IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
Field.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*/
24using System;
25
27
29{
30
31 sealed class FieldDefImpl : FieldInfo
32 {
33
34 readonly ModuleReader module;
35 readonly TypeDefImpl declaringType;
36 readonly int index;
37
38 FieldSignature lazyFieldSig;
39
46 internal FieldDefImpl(ModuleReader module, TypeDefImpl declaringType, int index)
47 {
48 this.module = module;
49 this.declaringType = declaringType;
50 this.index = index;
51 }
52
53 public override FieldAttributes Attributes
54 {
55 get { return (FieldAttributes)module.FieldTable.records[index].Flags; }
56 }
57
58 public override Type DeclaringType
59 {
60 get { return declaringType.IsModulePseudoType ? null : declaringType; }
61 }
62
63 public override string Name
64 {
65 get { return module.GetString(module.FieldTable.records[index].Name); }
66 }
67
68 public override string ToString()
69 {
70 return this.FieldType.Name + " " + this.Name;
71 }
72
73 public override Module Module
74 {
75 get { return module; }
76 }
77
78 public override int MetadataToken
79 {
80 get { return (FieldTable.Index << 24) + index + 1; }
81 }
82
83 public override object GetRawConstantValue()
84 {
85 return module.ConstantTable.GetRawConstantValue(module, this.MetadataToken);
86 }
87
88 public override bool __TryGetFieldOffset(out int offset)
89 {
90 foreach (int i in this.Module.FieldLayoutTable.Filter(index + 1))
91 {
92 offset = Module.FieldLayoutTable.records[i].Offset;
93 return true;
94 }
95
96 offset = 0;
97 return false;
98 }
99
100 internal override FieldSignature FieldSignature
101 {
102 get { return lazyFieldSig ??= FieldSignature.ReadSig(module, module.GetBlobReader(module.FieldTable.records[index].Signature), declaringType); }
103 }
104
105 internal override int ImportTo(Emit.ModuleBuilder module)
106 {
107 return module.ImportMethodOrField(declaringType, this.Name, this.FieldSignature);
108 }
109
110 internal override int GetCurrentToken()
111 {
112 return this.MetadataToken;
113 }
114
115 internal override bool IsBaked
116 {
117 get { return true; }
118 }
119
120 }
121
122}
global::java.lang.invoke.LambdaForm.Name Name
override object GetRawConstantValue()
Definition Field.cs:83
override string ToString()
Definition Field.cs:68
override bool __TryGetFieldOffset(out int offset)
Definition Field.cs:88
override FieldAttributes Attributes
Definition Field.cs:54