IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IkvmReflectionMethodBaseSymbol.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics;
3using System.Linq;
4using System.Threading;
5
8
10{
11
13 {
14
15 readonly MethodBase _underlyingMethodBase;
16
17 ParameterInfo[]? _parametersSource;
18 IkvmReflectionParameterSymbol?[]? _parameters;
19 IkvmReflectionParameterSymbol? _returnParameter;
20
29 base(context, module, type, underlyingMethodBase)
30 {
31 _underlyingMethodBase = underlyingMethodBase ?? throw new ArgumentNullException(nameof(underlyingMethodBase));
32 }
33
39 internal IkvmReflectionParameterSymbol GetOrCreateParameterSymbol(ParameterInfo parameter)
40 {
41 if (parameter is null)
42 throw new ArgumentNullException(nameof(parameter));
43
44 Debug.Assert(parameter.Member == _underlyingMethodBase);
45
46 if (_parametersSource == null)
47 Interlocked.CompareExchange(ref _parametersSource, _underlyingMethodBase.GetParameters().OrderBy(i => i.Position).ToArray(), null);
48 if (_parameters == null)
49 Interlocked.CompareExchange(ref _parameters, new IkvmReflectionParameterSymbol?[_parametersSource.Length], null);
50
51 // index of current record
52 var idx = parameter.Position;
53 Debug.Assert(idx >= -1);
54 Debug.Assert(idx < _parametersSource.Length);
55
56 // check that our list is long enough to contain the entire table
57 if (idx >= 0 && _parameters.Length < idx)
58 throw new IndexOutOfRangeException();
59
60 // if not yet created, create, allow multiple instances, but only one is eventually inserted
61 ref var rec = ref _returnParameter;
62 if (idx >= 0)
63 rec = ref _parameters[idx];
64 if (rec == null)
65 Interlocked.CompareExchange(ref rec, new IkvmReflectionParameterSymbol(Context, this, parameter), null);
66
67 // this should never happen
68 if (rec is not IkvmReflectionParameterSymbol sym)
69 throw new InvalidOperationException();
70
71 return sym;
72 }
73
74 public global::System.Reflection.MethodAttributes Attributes => (global::System.Reflection.MethodAttributes)_underlyingMethodBase.Attributes;
75
76 public global::System.Reflection.CallingConventions CallingConvention => (global::System.Reflection.CallingConventions)_underlyingMethodBase.CallingConvention;
77
78 public bool ContainsGenericParameters => _underlyingMethodBase.ContainsGenericParameters;
79
80 public bool IsAbstract => _underlyingMethodBase.IsAbstract;
81
82 public bool IsAssembly => _underlyingMethodBase.IsAssembly;
83
84 public bool IsConstructor => _underlyingMethodBase.IsConstructor;
85
86 public bool IsFamily => _underlyingMethodBase.IsFamily;
87
88 public bool IsFamilyAndAssembly => _underlyingMethodBase.IsFamilyAndAssembly;
89
90 public bool IsFamilyOrAssembly => _underlyingMethodBase.IsFamilyOrAssembly;
91
92 public bool IsFinal => _underlyingMethodBase.IsFinal;
93
94 public bool IsGenericMethod => _underlyingMethodBase.IsGenericMethod;
95
96 public bool IsGenericMethodDefinition => _underlyingMethodBase.IsGenericMethodDefinition;
97
98 public bool IsHideBySig => _underlyingMethodBase.IsHideBySig;
99
100 public bool IsPrivate => _underlyingMethodBase.IsPrivate;
101
102 public bool IsPublic => _underlyingMethodBase.IsPublic;
103
104 public bool IsSpecialName => _underlyingMethodBase.IsSpecialName;
105
106 public bool IsStatic => _underlyingMethodBase.IsStatic;
107
108 public bool IsVirtual => _underlyingMethodBase.IsVirtual;
109
110 public global::System.Reflection.MethodImplAttributes MethodImplementationFlags => (global::System.Reflection.MethodImplAttributes)_underlyingMethodBase.MethodImplementationFlags;
111
113 {
114 return ResolveTypeSymbols(_underlyingMethodBase.GetGenericArguments());
115 }
116
117 public global::System.Reflection.MethodImplAttributes GetMethodImplementationFlags()
118 {
119 return (global::System.Reflection.MethodImplAttributes)_underlyingMethodBase.GetMethodImplementationFlags();
120 }
121
123 {
124 return ResolveParameterSymbols(_underlyingMethodBase.GetParameters());
125 }
126
127 }
128
129}
System.Threading.Interlocked Interlocked
IKVM.Reflection.ParameterInfo ParameterInfo
IKVM.Reflection.MethodBase MethodBase
System.Runtime.InteropServices.CallingConvention CallingConvention
Definition Signature.cs:35
bool IsAssembly
Gets a value indicating whether the potential visibility of this method or constructor is described b...
bool IsPrivate
Gets a value indicating whether this member is private.
global::System.Reflection.MethodImplAttributes MethodImplementationFlags
Gets the MethodImplAttributes flags that specify the attributes of a method implementation.
IParameterSymbol[] GetParameters()
When overridden in a derived class, gets the parameters of the specified method or constructor.
bool IsHideBySig
Gets a value indicating whether only a member of the same kind with exactly the same signature is hid...
bool ContainsGenericParameters
Gets a value indicating whether the generic method contains unassigned generic type parameters.
bool IsFamilyAndAssembly
Gets a value indicating whether the visibility of this method or constructor is described by FamANDAs...
bool IsSpecialName
Gets a value indicating whether this method has a special name.
global::System.Reflection.MethodImplAttributes GetMethodImplementationFlags()
When overridden in a derived class, returns the MethodImplAttributes flags.
IkvmReflectionMethodBaseSymbol(IkvmReflectionSymbolContext context, IkvmReflectionModuleSymbol module, IkvmReflectionTypeSymbol? type, MethodBase underlyingMethodBase)
Initializes a new instance.
bool IsStatic
Gets a value indicating whether the method is static.
bool IsGenericMethod
Gets a value indicating whether the method is generic.
bool IsConstructor
Gets a value indicating whether the method is a constructor.
bool IsFamilyOrAssembly
Gets a value indicating whether the potential visibility of this method or constructor is described b...
bool IsGenericMethodDefinition
Gets a value indicating whether the method is a generic method definition.
bool IsPublic
Gets a value indicating whether this is a public method.
bool IsAbstract
Gets a value indicating whether the method is abstract.
bool IsFinal
Gets a value indicating whether this method is final.
global::System.Reflection.MethodAttributes Attributes
Gets the attributes associated with this method.
bool IsFamily
Gets a value indicating whether the visibility of this method or constructor is described by Family; ...
bool IsVirtual
Gets a value indicating whether the method is virtual.
ITypeSymbol[] GetGenericArguments()
Returns an array of ITypeSymbol objects that represent the type arguments of a generic method or the ...
Implementation of IModuleSymbol derived from System.Reflection.
Holds references to symbols derived from System.Reflection.
IkvmReflectionSymbolContext Context
Gets the associated IkvmReflectionSymbolContext.
Provides information about methods and constructors.
Discovers the attributes of a parameter and provides access to parameter metadata.
Represents type declarations: class types, interface types, array types, value types,...