IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
GenericTypeParameter.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*/
24using System.Collections.Generic;
25
27
29{
30
32 {
33
34 readonly ModuleReader module;
35 readonly int index;
36
43 internal GenericTypeParameter(ModuleReader module, int index, byte sigElementType) :
44 base(sigElementType)
45 {
46 this.module = module;
47 this.index = index;
48 }
49
50 public override bool Equals(object obj)
51 {
52 return base.Equals(obj);
53 }
54
55 public override int GetHashCode()
56 {
57 return base.GetHashCode();
58 }
59
60 public override string Namespace
61 {
62 get { return DeclaringType.Namespace; }
63 }
64
65 public override string Name
66 {
67 get { return module.GetString(module.GenericParamTable.records[index].Name); }
68 }
69
70 public override Module Module
71 {
72 get { return module; }
73 }
74
75 public override int MetadataToken
76 {
77 get { return (GenericParamTable.Index << 24) + index + 1; }
78 }
79
80 public override int GenericParameterPosition
81 {
82 get { return module.GenericParamTable.records[index].Number; }
83 }
84
85 public override Type DeclaringType
86 {
87 get
88 {
89 var owner = module.GenericParamTable.records[index].Owner;
90 return (owner >> 24) == TypeDefTable.Index ? module.ResolveType(owner) : null;
91 }
92 }
93
94 public override MethodBase DeclaringMethod
95 {
96 get
97 {
98 var owner = module.GenericParamTable.records[index].Owner;
99 return (owner >> 24) == MethodDefTable.Index ? module.ResolveMethod(owner) : null;
100 }
101 }
102
103 public override Type[] GetGenericParameterConstraints()
104 {
105 var context = (DeclaringMethod as IGenericContext) ?? DeclaringType;
106 var list = new List<Type>();
107 foreach (int i in module.GenericParamConstraint.Filter(MetadataToken))
108 list.Add(module.ResolveType(module.GenericParamConstraint.records[i].Constraint, context));
109
110 return list.ToArray();
111 }
112
113 public override CustomModifiers[] __GetGenericParameterConstraintCustomModifiers()
114 {
115 var context = (this.DeclaringMethod as IGenericContext) ?? DeclaringType;
116 var list = new List<CustomModifiers>();
117 foreach (var i in module.GenericParamConstraint.Filter(MetadataToken))
118 {
119 var mods = new CustomModifiers();
120 var metadataToken = module.GenericParamConstraint.records[i].Constraint;
121 if ((metadataToken >> 24) == TypeSpecTable.Index)
122 {
123 var index = (metadataToken & 0xFFFFFF) - 1;
124 mods = CustomModifiers.Read(module, module.GetBlobReader(module.TypeSpecTable.records[index]), context);
125 }
126
127 list.Add(mods);
128 }
129
130 return list.ToArray();
131 }
132
133 public override GenericParameterAttributes GenericParameterAttributes
134 {
135 get { return (GenericParameterAttributes)module.GenericParamTable.records[index].Flags; }
136 }
137
138 internal override Type BindTypeParameters(IGenericBinder binder)
139 {
140 var owner = module.GenericParamTable.records[index].Owner;
141 if ((owner >> 24) == MethodDefTable.Index)
142 {
143 return binder.BindMethodParameter(this);
144 }
145 else
146 {
147 return binder.BindTypeParameter(this);
148 }
149 }
150
151 internal override bool IsBaked
152 {
153 get { return true; }
154 }
155
156 }
157
158}
global::java.lang.invoke.LambdaForm.Name Name
override CustomModifiers[] __GetGenericParameterConstraintCustomModifiers()
Type BindMethodParameter(Type type)
Type BindTypeParameter(Type type)