| 1 |
/* |
| 2 |
Copyright (C) 2008-2011 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 |
[email protected] |
| 22 |
|
| 23 |
*/ |
| 24 |
using System; |
| 25 |
using System.Collections.Generic; |
| 26 |
|
| 27 |
namespace IKVM.Reflection.Emit |
| 28 |
{ |
| 29 |
public sealed class ConstructorBuilder : ConstructorInfo |
| 30 |
{ |
| 31 |
private readonly MethodBuilder methodBuilder; |
| 32 |
|
| 33 |
internal ConstructorBuilder(MethodBuilder mb) |
| 34 |
{ |
| 35 |
this.methodBuilder = mb; |
| 36 |
} |
| 37 |
|
| 38 |
public override bool Equals(object obj) |
| 39 |
{ |
| 40 |
ConstructorBuilder other = obj as ConstructorBuilder; |
| 41 |
return other != null && other.methodBuilder.Equals(methodBuilder); |
| 42 |
} |
| 43 |
|
| 44 |
public override int GetHashCode() |
| 45 |
{ |
| 46 |
return methodBuilder.GetHashCode(); |
| 47 |
} |
| 48 |
|
| 49 |
public void __SetSignature(Type returnType, CustomModifiers returnTypeCustomModifiers, Type[] parameterTypes, CustomModifiers[] parameterTypeCustomModifiers) |
| 50 |
{ |
| 51 |
methodBuilder.__SetSignature(returnType, returnTypeCustomModifiers, parameterTypes, parameterTypeCustomModifiers); |
| 52 |
} |
| 53 |
|
| 54 |
[Obsolete("Please use __SetSignature(Type, CustomModifiers, Type[], CustomModifiers[]) instead.")] |
| 55 |
public void __SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) |
| 56 |
{ |
| 57 |
methodBuilder.SetSignature(returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); |
| 58 |
} |
| 59 |
|
| 60 |
public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName) |
| 61 |
{ |
| 62 |
return methodBuilder.DefineParameter(position, attributes, strParamName); |
| 63 |
} |
| 64 |
|
| 65 |
public void SetCustomAttribute(CustomAttributeBuilder customBuilder) |
| 66 |
{ |
| 67 |
methodBuilder.SetCustomAttribute(customBuilder); |
| 68 |
} |
| 69 |
|
| 70 |
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) |
| 71 |
{ |
| 72 |
methodBuilder.SetCustomAttribute(con, binaryAttribute); |
| 73 |
} |
| 74 |
|
| 75 |
public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder) |
| 76 |
{ |
| 77 |
methodBuilder.__AddDeclarativeSecurity(customBuilder); |
| 78 |
} |
| 79 |
|
| 80 |
#if !CORECLR |
| 81 |
public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet) |
| 82 |
{ |
| 83 |
methodBuilder.AddDeclarativeSecurity(securityAction, permissionSet); |
| 84 |
} |
| 85 |
#endif |
| 86 |
|
| 87 |
public void SetImplementationFlags(MethodImplAttributes attributes) |
| 88 |
{ |
| 89 |
methodBuilder.SetImplementationFlags(attributes); |
| 90 |
} |
| 91 |
|
| 92 |
public ILGenerator GetILGenerator() |
| 93 |
{ |
| 94 |
return methodBuilder.GetILGenerator(); |
| 95 |
} |
| 96 |
|
| 97 |
public ILGenerator GetILGenerator(int streamSize) |
| 98 |
{ |
| 99 |
return methodBuilder.GetILGenerator(streamSize); |
| 100 |
} |
| 101 |
|
| 102 |
public void __ReleaseILGenerator() |
| 103 |
{ |
| 104 |
methodBuilder.__ReleaseILGenerator(); |
| 105 |
} |
| 106 |
|
| 107 |
public Type ReturnType |
| 108 |
{ |
| 109 |
get { return methodBuilder.ReturnType; } |
| 110 |
} |
| 111 |
|
| 112 |
public Module GetModule() |
| 113 |
{ |
| 114 |
return methodBuilder.GetModule(); |
| 115 |
} |
| 116 |
|
| 117 |
public MethodToken GetToken() |
| 118 |
{ |
| 119 |
return methodBuilder.GetToken(); |
| 120 |
} |
| 121 |
|
| 122 |
public bool InitLocals |
| 123 |
{ |
| 124 |
get { return methodBuilder.InitLocals; } |
| 125 |
set { methodBuilder.InitLocals = value; } |
| 126 |
} |
| 127 |
|
| 128 |
public void SetMethodBody(byte[] il, int maxStack, byte[] localSignature, IEnumerable<ExceptionHandler> exceptionHandlers, IEnumerable<int> tokenFixups) |
| 129 |
{ |
| 130 |
methodBuilder.SetMethodBody(il, maxStack, localSignature, exceptionHandlers, tokenFixups); |
| 131 |
} |
| 132 |
|
| 133 |
internal override MethodInfo GetMethodInfo() |
| 134 |
{ |
| 135 |
return methodBuilder; |
| 136 |
} |
| 137 |
|
| 138 |
internal override MethodInfo GetMethodOnTypeDefinition() |
| 139 |
{ |
| 140 |
return methodBuilder; |
| 141 |
} |
| 142 |
} |
| 143 |
} |