IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
PropertyInfoImpl.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2012 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*/
25
27{
28
29 sealed class PropertyInfoImpl : PropertyInfo
30 {
31
32 readonly ModuleReader module;
33 readonly Type declaringType;
34 readonly int index;
35
37 bool isPublic;
38 bool isNonPrivate;
39 bool isStatic;
40 bool flagsCached;
41
48 internal PropertyInfoImpl(ModuleReader module, Type declaringType, int index)
49 {
50 this.module = module;
51 this.declaringType = declaringType;
52 this.index = index;
53 }
54
55 public override bool Equals(object obj)
56 {
57 return obj is PropertyInfoImpl other && other.DeclaringType == declaringType && other.index == index;
58 }
59
60 public override int GetHashCode() => declaringType.GetHashCode() * 77 + index;
61
62 internal override PropertySignature PropertySignature => sig ??= PropertySignature.ReadSig(module, module.GetBlobReader(module.PropertyTable.records[index].Type), declaringType);
63
64 public override PropertyAttributes Attributes => (PropertyAttributes)module.PropertyTable.records[index].Flags;
65
66 public override object GetRawConstantValue() => module.ConstantTable.GetRawConstantValue(module, this.MetadataToken);
67
68 public override bool CanRead => GetGetMethod(true) != null;
69
70 public override bool CanWrite => GetSetMethod(true) != null;
71
72 public override MethodInfo GetGetMethod(bool nonPublic)
73 {
74 return module.MethodSemanticsTable.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Getter);
75 }
76
77 public override MethodInfo GetSetMethod(bool nonPublic)
78 {
79 return module.MethodSemanticsTable.GetMethod(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Setter);
80 }
81
82 public override MethodInfo[] GetAccessors(bool nonPublic)
83 {
84 return module.MethodSemanticsTable.GetMethods(module, this.MetadataToken, nonPublic, MethodSemanticsTable.Getter | MethodSemanticsTable.Setter | MethodSemanticsTable.Other);
85 }
86
87 public override Type DeclaringType => declaringType;
88
89 public override Module Module => module;
90
91 public override int MetadataToken => (PropertyTable.Index << 24) + index + 1;
92
93 public override string Name => module.GetString(module.PropertyTable.records[index].Name);
94
95 internal override bool IsPublic
96 {
97 get
98 {
99 if (!flagsCached)
100 ComputeFlags();
101
102 return isPublic;
103 }
104 }
105
106 internal override bool IsNonPrivate
107 {
108 get
109 {
110 if (!flagsCached)
111 ComputeFlags();
112
113 return isNonPrivate;
114 }
115 }
116
117 internal override bool IsStatic
118 {
119 get
120 {
121 if (!flagsCached)
122 ComputeFlags();
123
124 return isStatic;
125 }
126 }
127
128 void ComputeFlags()
129 {
130 module.MethodSemanticsTable.ComputeFlags(module, MetadataToken, out isPublic, out isNonPrivate, out isStatic);
131 flagsCached = true;
132 }
133
134 internal override bool IsBaked
135 {
136 get { return true; }
137 }
138
139 internal override int GetCurrentToken()
140 {
141 return this.MetadataToken;
142 }
143
144 }
145
146}
global::java.lang.invoke.LambdaForm.Name Name
override PropertyAttributes Attributes
override MethodInfo GetSetMethod(bool nonPublic)
override MethodInfo GetGetMethod(bool nonPublic)
override MethodInfo[] GetAccessors(bool nonPublic)