~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ikvm/reflect/MethodBase.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

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