IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
MissingType.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2011-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*/
24using System;
25
26namespace IKVM.Reflection
27{
28
29 sealed class MissingType : Type
30 {
31
32 readonly Module module;
33 readonly Type declaringType;
34 readonly string ns;
35 readonly string name;
36 Type[] typeArgs;
37 int token;
38 int flags;
39 bool cyclicTypeForwarder;
40 bool cyclicTypeSpec;
41
49 internal MissingType(Module module, Type declaringType, string ns, string name)
50 {
51 this.module = module;
52 this.declaringType = declaringType;
53 this.ns = ns;
54 this.name = name;
55 MarkKnownType(ns, name);
56 }
57
58 internal override MethodBase FindMethod(string name, MethodSignature signature)
59 {
60 var method = new MissingMethod(this, name, signature);
61 if (name == ".ctor")
62 return new ConstructorInfoImpl(method);
63
64 return method;
65 }
66
67 internal override FieldInfo FindField(string name, FieldSignature signature)
68 {
69 return new MissingField(this, name, signature);
70 }
71
72 internal override Type FindNestedType(TypeName name)
73 {
74 return null;
75 }
76
77 internal override Type FindNestedTypeIgnoreCase(TypeName lowerCaseName)
78 {
79 return null;
80 }
81
82 public override bool __IsMissing
83 {
84 get { return true; }
85 }
86
87 public override Type DeclaringType
88 {
89 get { return declaringType; }
90 }
91
92 internal override TypeName TypeName
93 {
94 get { return new TypeName(ns, name); }
95 }
96
97 public override string Name
98 {
99 get { return TypeNameParser.Escape(name); }
100 }
101
102 public override string FullName
103 {
104 get { return GetFullName(); }
105 }
106
107 public override Module Module
108 {
109 get { return module; }
110 }
111
112 public override int MetadataToken
113 {
114 get { return token; }
115 }
116
117 protected override bool IsValueTypeImpl
118 {
119 get
120 {
121 switch (typeFlags & (TypeFlags.ValueType | TypeFlags.NotValueType))
122 {
123 case TypeFlags.ValueType:
124 return true;
125 case TypeFlags.NotValueType:
126 return false;
127 default:
128 if (module.Universe.ResolveMissingTypeIsValueType(this))
129 typeFlags |= TypeFlags.ValueType;
130 else
131 typeFlags |= TypeFlags.NotValueType;
132
133 return (typeFlags & TypeFlags.ValueType) != 0;
134 }
135 }
136 }
137
138 public override Type BaseType
139 {
140 get { throw new MissingMemberException(this); }
141 }
142
143 public override TypeAttributes Attributes
144 {
145 get { throw new MissingMemberException(this); }
146 }
147
148 public override Type[] __GetDeclaredTypes()
149 {
150 throw new MissingMemberException(this);
151 }
152
153 public override Type[] __GetDeclaredInterfaces()
154 {
155 throw new MissingMemberException(this);
156 }
157
158 public override MethodBase[] __GetDeclaredMethods()
159 {
160 throw new MissingMemberException(this);
161 }
162
163 public override __MethodImplMap __GetMethodImplMap()
164 {
165 throw new MissingMemberException(this);
166 }
167
168 public override FieldInfo[] __GetDeclaredFields()
169 {
170 throw new MissingMemberException(this);
171 }
172
173 public override EventInfo[] __GetDeclaredEvents()
174 {
175 throw new MissingMemberException(this);
176 }
177
178 public override PropertyInfo[] __GetDeclaredProperties()
179 {
180 throw new MissingMemberException(this);
181 }
182
183 public override CustomModifiers __GetCustomModifiers()
184 {
185 throw new MissingMemberException(this);
186 }
187
188 public override Type[] GetGenericArguments()
189 {
190 throw new MissingMemberException(this);
191 }
192
193 public override CustomModifiers[] __GetGenericArgumentsCustomModifiers()
194 {
195 throw new MissingMemberException(this);
196 }
197
198 public override bool __GetLayout(out int packingSize, out int typeSize)
199 {
200 throw new MissingMemberException(this);
201 }
202
203 public override bool IsGenericType
204 {
205 get { throw new MissingMemberException(this); }
206 }
207
208 public override bool IsGenericTypeDefinition
209 {
210 get { throw new MissingMemberException(this); }
211 }
212
213 internal override Type GetGenericTypeArgument(int index)
214 {
215 if (typeArgs == null)
216 typeArgs = new Type[index + 1];
217 else if (typeArgs.Length <= index)
218 Array.Resize(ref typeArgs, index + 1);
219
220 return typeArgs[index] ?? (typeArgs[index] = new MissingTypeParameter(this, index));
221 }
222
223 internal override Type BindTypeParameters(IGenericBinder binder)
224 {
225 return this;
226 }
227
228 internal override Type SetMetadataTokenForMissing(int token, int flags)
229 {
230 this.token = token;
231 this.flags = flags;
232 return this;
233 }
234
235 internal override Type SetCyclicTypeForwarder()
236 {
237 this.cyclicTypeForwarder = true;
238 return this;
239 }
240
241 internal override Type SetCyclicTypeSpec()
242 {
243 this.cyclicTypeSpec = true;
244 return this;
245 }
246
247 internal override bool IsBaked
248 {
249 get { throw new MissingMemberException(this); }
250 }
251
252 public override bool __IsTypeForwarder
253 {
254 // CorTypeAttr.tdForwarder
255 get { return (flags & 0x00200000) != 0; }
256 }
257
258 public override bool __IsCyclicTypeForwarder
259 {
260 get { return cyclicTypeForwarder; }
261 }
262
263 public override bool __IsCyclicTypeSpec
264 {
265 get { return cyclicTypeSpec; }
266 }
267
268 }
269
270}
IKVM.Reflection.Type Type
global::java.lang.invoke.LambdaForm.Name Name
Represents a method signature from IL metadadata.
override bool __IsCyclicTypeSpec
override MethodBase[] __GetDeclaredMethods()
override Type[] GetGenericArguments()
override bool IsGenericTypeDefinition
override CustomModifiers[] __GetGenericArgumentsCustomModifiers()
override TypeAttributes Attributes
override Type[] __GetDeclaredInterfaces()
override PropertyInfo[] __GetDeclaredProperties()
override EventInfo[] __GetDeclaredEvents()
override __MethodImplMap __GetMethodImplMap()
override FieldInfo[] __GetDeclaredFields()
override Type[] __GetDeclaredTypes()
override bool __IsTypeForwarder
override CustomModifiers __GetCustomModifiers()
override bool __IsCyclicTypeForwarder
override bool __GetLayout(out int packingSize, out int typeSize)