2003-02-04 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Tue, 4 Feb 2003 10:33:54 +0000 (10:33 -0000)
committerZoltan Varga <vargaz@gmail.com>
Tue, 4 Feb 2003 10:33:54 +0000 (10:33 -0000)
* AssemblyBuilder.cs: added GetToken (SignatureHelper).

* ILGenerator.cs: implemented EmitCalli() methods

* SignatureHelper.cs: implemented GetMethoSigHelper() methods.

svn path=/trunk/mcs/; revision=11191

mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
mcs/class/corlib/System.Reflection.Emit/SignatureHelper.cs

index e1116e1ef11ce9e3303da9c0a132f68dcda0d694..1d3ea52c6a0cc817b27312161b21a79069334fe0 100755 (executable)
@@ -240,7 +240,7 @@ namespace System.Reflection.Emit {
                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))
@@ -253,7 +253,11 @@ namespace System.Reflection.Emit {
                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);
 
index e24b1d8a9ac917ac42168f7ec665f5bdbd9f2897..20e632af018f096800ddc816de0571979c92a5a2 100644 (file)
@@ -1,3 +1,10 @@
+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>
 
index 6276b3677e079f94d0caf6bf9ae4afeea68e9730..f8d893b083bb8fb89d36bebd43a6098f2c6a35f6 100644 (file)
@@ -11,6 +11,7 @@
 using System;
 using System.Collections;
 using System.Diagnostics.SymbolStore;
+using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit {
 
@@ -503,6 +504,9 @@ 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);
@@ -522,9 +526,8 @@ namespace System.Reflection.Emit {
                        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);
@@ -560,10 +563,22 @@ namespace System.Reflection.Emit {
                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 ();
                }
index 40e3b566a22f5f9a51e8bd3667b0503f486dee3a..58d54ec53dbb6c5b4b4702568699c8e524ccdcb0 100755 (executable)
@@ -28,6 +28,9 @@ namespace System.Reflection.Emit {
                private ModuleBuilder module;
                private Type[] arguments;
                private SignatureHelperType type;
+               private Type returnType;
+               private CallingConventions callConv;
+               private CallingConvention unmanagedCallConv;
 
                internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
                {
@@ -42,6 +45,7 @@ namespace System.Reflection.Emit {
 
                        return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
                }
+
                public static SignatureHelper GetLocalVarSigHelper (Module mod)
                {
                        if (!(mod is ModuleBuilder))
@@ -49,21 +53,29 @@ namespace System.Reflection.Emit {
 
                        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) {
@@ -114,6 +126,26 @@ namespace System.Reflection.Emit {
                        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;
+               }
 
 
        }