3 // System.Reflection.Emit/SignatureHelper.cs
6 // Paolo Molaro (lupus@ximian.com)
8 // (C) 2001 Ximian, Inc. http://www.ximian.com
12 using System.Reflection;
13 using System.Reflection.Emit;
14 using System.Globalization;
15 using System.Runtime.CompilerServices;
16 using System.Runtime.InteropServices;
18 namespace System.Reflection.Emit {
20 public sealed class SignatureHelper {
21 internal enum SignatureHelperType {
28 private ModuleBuilder module;
29 private Type[] arguments;
30 private SignatureHelperType type;
31 private Type returnType;
32 private CallingConventions callConv;
33 private CallingConvention unmanagedCallConv;
35 internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
41 public static SignatureHelper GetFieldSigHelper (Module mod)
43 if (!(mod is ModuleBuilder))
44 throw new NotImplementedException ();
46 return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
49 public static SignatureHelper GetLocalVarSigHelper (Module mod)
51 if (!(mod is ModuleBuilder))
52 throw new NotImplementedException ();
54 return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
57 public static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callingConvention, Type returnType)
59 return GetMethodSigHelper (mod, callingConvention, (CallingConvention)0, returnType, null);
62 public static SignatureHelper GetMethodSigHelper( Module mod, CallingConvention unmanagedCallingConvention, Type returnType)
64 return GetMethodSigHelper (mod, CallingConventions.Standard, unmanagedCallingConvention, returnType, null);
67 public static SignatureHelper GetMethodSigHelper( Module mod, Type returnType, Type[] parameterTypes)
69 return GetMethodSigHelper (mod, CallingConventions.Standard,
70 (CallingConvention)0, returnType,
74 public static SignatureHelper GetPropertySigHelper( Module mod, Type returnType, Type[] parameterTypes)
76 throw new NotImplementedException ();
79 public void AddArgument (Type clsArgument)
81 if (arguments != null) {
82 Type[] new_a = new Type [arguments.Length + 1];
83 System.Array.Copy (arguments, new_a, arguments.Length);
84 new_a [arguments.Length] = clsArgument;
87 arguments = new Type [1];
88 arguments [0] = clsArgument;
92 public void AddSentinel ()
94 throw new NotImplementedException ();
97 public override bool Equals (object obj)
99 throw new NotImplementedException ();
102 public override int GetHashCode ()
104 throw new NotImplementedException ();
107 [MethodImplAttribute(MethodImplOptions.InternalCall)]
108 internal extern byte[] get_signature_local ();
110 [MethodImplAttribute(MethodImplOptions.InternalCall)]
111 internal extern byte[] get_signature_field ();
113 public byte[] GetSignature ()
116 case SignatureHelperType.HELPER_LOCAL:
117 return get_signature_local ();
118 case SignatureHelperType.HELPER_FIELD:
119 return get_signature_field ();
121 throw new NotImplementedException ();
125 public override string ToString() {
126 return "SignatureHelper";
129 internal static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callConv, CallingConvention unmanagedCallConv, Type returnType,
132 if (!(mod is ModuleBuilder))
133 throw new NotImplementedException ();
135 SignatureHelper helper =
136 new SignatureHelper ((ModuleBuilder)mod, SignatureHelperType.HELPER_METHOD);
137 helper.returnType = returnType;
138 helper.callConv = callConv;
139 helper.unmanagedCallConv = unmanagedCallConv;
141 if (parameters != null) {
142 helper.arguments = new Type [parameters.Length];
143 for (int i = 0; i < parameters.Length; ++i)
144 helper.arguments [i] = parameters [i];