IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
MethodBase.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*/
24namespace IKVM.Reflection
25{
26
27 internal abstract class MethodBase : MemberInfo
28 {
29
33 internal MethodBase()
34 {
35
36 }
37
38 internal abstract MethodSignature MethodSignature { get; }
39 internal abstract int ParameterCount { get; }
40 public abstract ParameterInfo[] GetParameters();
41
42 internal abstract Type[] GetParameterTypes();
43
44 public abstract MethodAttributes Attributes { get; }
45 public abstract MethodImplAttributes GetMethodImplementationFlags();
46 public abstract MethodBody GetMethodBody();
47 public abstract CallingConventions CallingConvention { get; }
48 public abstract int __MethodRVA { get; }
49
50 public bool IsConstructor
51 {
52 get
53 {
54 if ((Attributes & MethodAttributes.RTSpecialName) != 0)
55 {
56 var name = Name;
57 return name == ConstructorInfo.ConstructorName || name == ConstructorInfo.TypeConstructorName;
58 }
59
60 return false;
61 }
62 }
63
64 public bool IsStatic
65 {
66 get { return (Attributes & MethodAttributes.Static) != 0; }
67 }
68
69 public bool IsVirtual
70 {
71 get { return (Attributes & MethodAttributes.Virtual) != 0; }
72 }
73
74 public bool IsAbstract
75 {
76 get { return (Attributes & MethodAttributes.Abstract) != 0; }
77 }
78
79 public bool IsFinal
80 {
81 get { return (Attributes & MethodAttributes.Final) != 0; }
82 }
83
84 public bool IsPublic
85 {
86 get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; }
87 }
88
89 public bool IsFamily
90 {
91 get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; }
92 }
93
94 public bool IsFamilyOrAssembly
95 {
96 get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; }
97 }
98
99 public bool IsAssembly
100 {
101 get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; }
102 }
103
104 public bool IsFamilyAndAssembly
105 {
106 get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; }
107 }
108
109 public bool IsPrivate
110 {
111 get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; }
112 }
113
114 public bool IsSpecialName
115 {
116 get { return (Attributes & MethodAttributes.SpecialName) != 0; }
117 }
118
119 public bool IsHideBySig
120 {
121 get { return (Attributes & MethodAttributes.HideBySig) != 0; }
122 }
123
124 public MethodImplAttributes MethodImplementationFlags
125 {
126 get { return GetMethodImplementationFlags(); }
127 }
128
129 public virtual Type[] GetGenericArguments()
130 {
131 return Type.EmptyTypes;
132 }
133
134 public virtual bool IsGenericMethod
135 {
136 get { return false; }
137 }
138
139 public virtual bool IsGenericMethodDefinition
140 {
141 get { return false; }
142 }
143
144 public virtual bool ContainsGenericParameters
145 {
146 get { return IsGenericMethodDefinition; }
147 }
148
149 public virtual MethodBase __GetMethodOnTypeDefinition()
150 {
151 return this;
152 }
153
154 // This goes to the (uninstantiated) MethodInfo on the (uninstantiated) Type. For constructors
155 // it also has the effect of removing the ConstructorInfo wrapper and returning the underlying MethodInfo.
156 internal abstract MethodInfo GetMethodOnTypeDefinition();
157
158 internal abstract int ImportTo(Emit.ModuleBuilder module);
159
160 internal abstract MethodBase BindTypeParameters(Type type);
161
162 internal sealed override bool BindingFlagsMatch(BindingFlags flags)
163 {
164 return BindingFlagsMatch(IsPublic, flags, BindingFlags.Public, BindingFlags.NonPublic)
165 && BindingFlagsMatch(IsStatic, flags, BindingFlags.Static, BindingFlags.Instance);
166 }
167
168 internal sealed override bool BindingFlagsMatchInherited(BindingFlags flags)
169 {
170 return (Attributes & MethodAttributes.MemberAccessMask) > MethodAttributes.Private
171 && BindingFlagsMatch(IsPublic, flags, BindingFlags.Public, BindingFlags.NonPublic)
172 && BindingFlagsMatch(IsStatic, flags, BindingFlags.Static | BindingFlags.FlattenHierarchy, BindingFlags.Instance);
173 }
174
175 }
176
177}
IKVM.Reflection.Type Type
IKVM.Reflection.ConstructorInfo ConstructorInfo
IKVM.Reflection.MemberInfo MemberInfo
IKVM.Reflection.MethodInfo MethodInfo
IKVM.Reflection.ParameterInfo ParameterInfo
IKVM.Reflection.MethodBase MethodBase
global::java.lang.invoke.LambdaForm.Name Name
System.Runtime.InteropServices.CallingConvention CallingConvention
Definition Signature.cs:35