Merge pull request #704 from jgagnon/master
[mono.git] / mcs / class / corlib / System.Reflection.Emit / SignatureHelper.cs
index bd9ff73c441b189af5e22771c8c60c2437edc978..924eb674e154ef2c487f892e5d54a897fa502f3c 100644 (file)
@@ -31,6 +31,7 @@
 // (C) 2001 Ximian, Inc.  http://www.ximian.com
 //
 
+#if !FULL_AOT_RUNTIME
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -39,11 +40,10 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit {
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterface (typeof (_SignatureHelper))]
-#endif
        [ClassInterface (ClassInterfaceType.None)]
+       [StructLayout (LayoutKind.Sequential)]
        public sealed class SignatureHelper : _SignatureHelper {
                internal enum SignatureHelperType {
                        HELPER_FIELD,
@@ -58,8 +58,10 @@ namespace System.Reflection.Emit {
                private Type returnType;
                private CallingConventions callConv;
                private CallingConvention unmanagedCallConv;
+#pragma warning disable 649
                private Type[][] modreqs;
                private Type[][] modopts;
+#pragma warning restore 649
 
                internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
                {
@@ -83,7 +85,6 @@ namespace System.Reflection.Emit {
                        return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
                }
 
-#if NET_2_0
                public static SignatureHelper GetLocalVarSigHelper ()
                {
                        return new SignatureHelper (null, SignatureHelperType.HELPER_LOCAL);
@@ -98,28 +99,52 @@ namespace System.Reflection.Emit {
                {
                        return GetMethodSigHelper (null, CallingConventions.Standard, unmanagedCallingConvention, returnType, null);
                }
-#endif
 
-               public static SignatureHelper GetMethodSigHelper (Module mod, CallingConventions unmanagedCallConv, Type returnType)
+               public static SignatureHelper GetMethodSigHelper (Module mod, CallingConventions callingConvention, Type returnType)
                {
-                       return GetMethodSigHelper (mod, unmanagedCallConv, (CallingConvention)0, returnType, null);
+                       return GetMethodSigHelper (mod, callingConvention, (CallingConvention)0, returnType, null);
                }
 
-               public static SignatureHelper GetMethodSigHelper (Module mod, CallingConvention unmanagedCallingConvention, Type returnType)
+               public static SignatureHelper GetMethodSigHelper (Module mod, CallingConvention unmanagedCallConv, Type returnType)
                {
-                       return GetMethodSigHelper (mod, CallingConventions.Standard, unmanagedCallingConvention, returnType, null);
+                       return GetMethodSigHelper (mod, CallingConventions.Standard, unmanagedCallConv, returnType, null);
                }
 
                public static SignatureHelper GetMethodSigHelper (Module mod, Type returnType, Type[] parameterTypes)
                {
                        return GetMethodSigHelper (mod, CallingConventions.Standard, (CallingConvention)0, returnType, parameterTypes);
                }
+
                [MonoTODO("Not implemented")]
                public static SignatureHelper GetPropertySigHelper (Module mod, Type returnType, Type[] parameterTypes)
                {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO("Not implemented")]
+               public static SignatureHelper GetPropertySigHelper (Module mod, Type returnType,
+                                                                   Type [] requiredReturnTypeCustomModifiers,
+                                                                   Type [] optionalReturnTypeCustomModifiers,
+                                                                   Type [] parameterTypes,
+                                                                   Type [] [] requiredParameterTypeCustomModifiers,
+                                                                   Type [] [] optionalParameterTypeCustomModifiers)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO("Not implemented")]
+               public static SignatureHelper GetPropertySigHelper (Module mod,
+                                                                       CallingConventions callingConvention,
+                                                                       Type returnType,
+                                                                   Type [] requiredReturnTypeCustomModifiers,
+                                                                   Type [] optionalReturnTypeCustomModifiers,
+                                                                   Type [] parameterTypes,
+                                                                   Type [] [] requiredParameterTypeCustomModifiers,
+                                                                   Type [] [] optionalParameterTypeCustomModifiers)
+               {
+                       throw new NotImplementedException ();
+               }
+
                //
                // Grows the given array, and returns the index where the element
                // was added
@@ -139,7 +164,6 @@ namespace System.Reflection.Emit {
                        }
                }
 
-#if NET_2_0
                //
                // Appends the given type array @t into the @array passed at
                // position @pos.   If there is no array, it gets created
@@ -238,18 +262,6 @@ namespace System.Reflection.Emit {
                                AppendArrayAt (ref modopts, optionalCustomModifiers, p);
                }
 
-               [MonoTODO("Not implemented")]
-               public static SignatureHelper GetPropertySigHelper (Module mod, Type returnType,
-                                                                   Type [] requiredReturnTypeCustomModifiers,
-                                                                   Type [] optionalReturnTypeCustomModifiers,
-                                                                   Type [] parameterTypes,
-                                                                   Type [] [] requiredParameterTypeCustomModifiers,
-                                                                   Type [] [] optionalParameterTypeCustomModifiers)
-               {
-                       throw new NotImplementedException ();
-               }
-#endif
-
                public void AddArgument (Type clsArgument)
                {
                        if (clsArgument == null)
@@ -363,7 +375,7 @@ namespace System.Reflection.Emit {
                        return "SignatureHelper";
                }
 
-               internal static SignatureHelper GetMethodSigHelper (Module mod, CallingConventions callConv, CallingConvention unmanagedCallConv, Type returnType,
+               internal static SignatureHelper GetMethodSigHelper (Module mod, CallingConventions callingConvention, CallingConvention unmanagedCallingConvention, Type returnType,
                                                                                                                   Type [] parameters)
                {
                        if (mod != null && !(mod is ModuleBuilder))
@@ -372,11 +384,20 @@ namespace System.Reflection.Emit {
                        if (returnType == null)
                                returnType = typeof (void);
 
+                       if (returnType.IsUserType)
+                               throw new NotSupportedException ("User defined subclasses of System.Type are not yet supported.");
+                       if (parameters != null) {
+                               for (int i = 0; i < parameters.Length; ++i)
+                                       if (parameters [i].IsUserType)
+                                               throw new NotSupportedException ("User defined subclasses of System.Type are not yet supported.");
+
+                       }
+
                        SignatureHelper helper = 
                                new SignatureHelper ((ModuleBuilder)mod, SignatureHelperType.HELPER_METHOD);
                        helper.returnType = returnType;
-                       helper.callConv = callConv;
-                       helper.unmanagedCallConv = unmanagedCallConv;
+                       helper.callConv = callingConvention;
+                       helper.unmanagedCallConv = unmanagedCallingConvention;
 
                        if (parameters != null) {
                                helper.arguments = new Type [parameters.Length];
@@ -408,3 +429,4 @@ namespace System.Reflection.Emit {
                 }
        }
 }
+#endif