Set svn:eol-style=native, delete svn:executable.
[mono.git] / mcs / class / corlib / System.Reflection.Emit / MethodBuilder.cs
old mode 100755 (executable)
new mode 100644 (file)
index 915549a..4c1c11d
@@ -57,10 +57,11 @@ namespace System.Reflection.Emit {
                private MethodInfo override_method;
                private string pi_dll;
                private string pi_entry;
-               private CharSet ncharset;
+               private CharSet ncharset; /* this also encodes set_last_error etc */
                private CallingConvention native_cc;
                private CallingConventions call_conv;
                private bool init_locals = true;
+               private IntPtr generic_container;
 #if NET_2_0 || BOOTSTRAP_NET_2_0
                private GenericTypeParameterBuilder[] generic_params;
 #else
@@ -86,6 +87,10 @@ namespace System.Reflection.Emit {
                        if ((attributes & MethodAttributes.Static) == 0)
                                this.call_conv |= CallingConventions.HasThis;
                        if (parameterTypes != null) {
+                               for (int i = 0; i < parameterTypes.Length; ++i)
+                                       if (parameterTypes [i] == null)
+                                               throw new ArgumentException ("Elements of the parameterTypes array cannot be null", "parameterTypes");
+
                                this.parameters = new Type [parameterTypes.Length];
                                System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
                        }
@@ -139,6 +144,20 @@ namespace System.Reflection.Emit {
                        }
                }
 
+               /* Used by mcs */
+               internal bool BestFitMapping {
+                       set {
+                               ncharset = (CharSet)(((int)ncharset & ~0x30) | (value ? 0x10 : 0x20));
+                       }
+               }
+
+               /* Used by mcs */
+               internal bool ThrowOnUnmappableChar {
+                       set {
+                               ncharset = (CharSet)(((int)ncharset & ~0x3000) | (value ? 0x1000 : 0x2000));
+                       }
+               }
+
                public MethodToken GetToken() {
                        return new MethodToken(0x06000000 | table_idx);
                }
@@ -150,6 +169,8 @@ namespace System.Reflection.Emit {
                        return iattrs;
                }
                public override ParameterInfo[] GetParameters() {
+                       if (!type.is_created)
+                               throw NotSupported ();
                        if (parameters == null)
                                return null;
 
@@ -233,6 +254,10 @@ namespace System.Reflection.Emit {
                }
 
                internal void fixup () {
+                       if (((attrs & (MethodAttributes.Abstract | MethodAttributes.PinvokeImpl)) == 0) && ((iattrs & (MethodImplAttributes.Runtime | MethodImplAttributes.InternalCall)) == 0)) {
+                               if (((ilgen == null) || (ILGenerator.Mono_GetCurrentOffset (ilgen) == 0)) && (code == null))
+                                       throw new InvalidOperationException ("Method '" + Name + "' does not have a method body.");
+                       }
                        if (ilgen != null)
                                ilgen.label_fixup ();
                }
@@ -373,7 +398,7 @@ namespace System.Reflection.Emit {
                        return result;
                }
 
-               public GenericTypeParameterBuilder[] DefineGenericParameters (string[] names)
+               public GenericTypeParameterBuilder[] DefineGenericParameters (params string[] names)
                {
                        generic_params = new GenericTypeParameterBuilder [names.Length];
                        for (int i = 0; i < names.Length; i++)