* AssemblyBuilder.cs: added GetToken (SignatureHelper).
* ILGenerator.cs: implemented EmitCalli() methods
* SignatureHelper.cs: implemented GetMethoSigHelper() methods.
svn path=/trunk/mcs/; revision=11191
private static extern int getUSIndex (AssemblyBuilder ab, string str);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int getToken (AssemblyBuilder ab, MemberInfo member);
+ private static extern int getToken (AssemblyBuilder ab, object obj);
internal int GetToken (string str) {
if (us_string_cache.Contains (str))
internal int GetToken (MemberInfo member) {
return getToken (this, member);
}
-
+
+ internal int GetToken (SignatureHelper helper) {
+ return getToken (this, helper);
+ }
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int getDataChunk (AssemblyBuilder ab, byte[] buf, int offset);
+2003-02-04 Zoltan Varga <vargaz@freemail.hu>
+
+ * AssemblyBuilder.cs: added GetToken (SignatureHelper).
+
+ * ILGenerator.cs: implemented EmitCalli() methods
+
+ * SignatureHelper.cs: implemented GetMethoSigHelper() methods.
2003-01-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
using System;
using System.Collections;
using System.Diagnostics.SymbolStore;
+using System.Runtime.InteropServices;
namespace System.Reflection.Emit {
}
}
public virtual void Emit (OpCode opcode, MethodInfo method) {
+ if (method == null)
+ throw new ArgumentNullException ("method");
+
int token = abuilder.GetToken (method);
make_room (6);
ll_emit (opcode);
code [code_len++] = (byte)val;
}
- [MonoTODO]
public virtual void Emit (OpCode opcode, SignatureHelper shelper) {
- int token = 0; // FIXME: request a token from the modulebuilder
+ int token = abuilder.GetToken (shelper);
make_room (6);
ll_emit (opcode);
emit_int (token);
public void EmitCall (OpCode opcode, MethodInfo methodinfo, Type[] optionalParamTypes) {
throw new NotImplementedException ();
}
- public void EmitCalli (OpCode opcode, CallingConventions call_conv, Type returnType, Type[] paramTypes, Type[] optionalParamTypes) {
- throw new NotImplementedException ();
+
+ public void EmitCalli (OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type[] paramTypes) {
+ SignatureHelper helper
+ = SignatureHelper.GetMethodSigHelper (module, 0, unmanagedCallConv, returnType, paramTypes);
+ Emit (opcode, helper);
}
+ public void EmitCalli (OpCode opcode, CallingConventions callConv, Type returnType, Type[] paramTypes, Type[] optionalParamTypes) {
+ if (optionalParamTypes != null)
+ throw new NotImplementedException ();
+
+ SignatureHelper helper
+ = SignatureHelper.GetMethodSigHelper (module, callConv, 0, returnType, paramTypes);
+ Emit (opcode, helper);
+ }
+
public virtual void EmitWriteLine (FieldInfo field) {
throw new NotImplementedException ();
}
private ModuleBuilder module;
private Type[] arguments;
private SignatureHelperType type;
+ private Type returnType;
+ private CallingConventions callConv;
+ private CallingConvention unmanagedCallConv;
internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
{
return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
}
+
public static SignatureHelper GetLocalVarSigHelper (Module mod)
{
if (!(mod is ModuleBuilder))
return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
}
- [MonoTODO]
+
public static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callingConvention, Type returnType)
{
- throw new NotImplementedException ();
+ return GetMethodSigHelper (mod, callingConvention, (CallingConvention)0, returnType, null);
}
- [MonoTODO]
+
+ public static SignatureHelper GetMethodSigHelper( Module mod, CallingConvention unmanagedCallingConvention, Type returnType)
+ {
+ return GetMethodSigHelper (mod, CallingConventions.Standard, unmanagedCallingConvention, returnType, null);
+ }
+
public static SignatureHelper GetMethodSigHelper( Module mod, Type returnType, Type[] parameterTypes)
{
- throw new NotImplementedException ();
+ return GetMethodSigHelper (mod, CallingConventions.Standard,
+ (CallingConvention)0, returnType,
+ parameterTypes);
}
[MonoTODO]
public static SignatureHelper GetPropertySigHelper( Module mod, Type returnType, Type[] parameterTypes)
{
throw new NotImplementedException ();
}
+
public void AddArgument (Type clsArgument)
{
if (arguments != null) {
return "SignatureHelper";
}
+ internal static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callConv, CallingConvention unmanagedCallConv, Type returnType,
+ Type [] parameters)
+ {
+ if (!(mod is ModuleBuilder))
+ throw new NotImplementedException ();
+
+ SignatureHelper helper =
+ new SignatureHelper ((ModuleBuilder)mod, SignatureHelperType.HELPER_METHOD);
+ helper.returnType = returnType;
+ helper.callConv = callConv;
+ helper.unmanagedCallConv = unmanagedCallConv;
+
+ if (parameters != null) {
+ helper.arguments = new Type [parameters.Length];
+ for (int i = 0; i < parameters.Length; ++i)
+ helper.arguments [i] = parameters [i];
+ }
+
+ return helper;
+ }
}