Tue Apr 16 13:02:28 CEST 2002 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Tue, 16 Apr 2002 07:15:06 +0000 (07:15 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Tue, 16 Apr 2002 07:15:06 +0000 (07:15 -0000)
* AssemblyBuilder.cs: pad output file to file alignment.
* FieldBuilder.cs: ReflectedType.
* ModuleBuilder.cs: added guid generation and array method creation.
* MonoArrayMethod.cs: array method support code.

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

mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs [new file with mode: 0755]

index 9cc7e721e9c281715a3ddd7f48f115b80d53ed14..1f44ad40ebd4d1d4c87a60a609f18d024fd25c09 100755 (executable)
@@ -196,7 +196,7 @@ namespace System.Reflection.Emit {
                {
                        byte[] buf = new byte [2048];
                        FileStream file;
-                       int count, data_size;
+                       int count, data_size, total;
 
                        if (dir != null) {
                                assemblyFileName = String.Format ("{0}{1}{2}", dir, System.IO.Path.DirectorySeparatorChar, assemblyFileName);
@@ -204,11 +204,17 @@ namespace System.Reflection.Emit {
 
                        file = new FileStream (assemblyFileName, FileMode.Create, FileAccess.Write);
 
-                       count = getPEHeader (this, buf, out data_size);
+                       total = count = getPEHeader (this, buf, out data_size);
                        file.Write (buf, 0, count);
                        buf = new byte [data_size];
                        count = getDataChunk (this, buf);
                        file.Write (buf, 0, count);
+                       // pad to file alignment
+                       total += count;
+                       total %= 512;
+                       total = 512 - total;
+                       buf = new byte [total];
+                       file.Write (buf, 0, total);
 
                        file.Close ();
                }
index 81be836a994b6bf5244c3b711eeef5ebb5ca1570..47d3365b18c338118858fc31ba24bbf01f5da382 100644 (file)
@@ -1,7 +1,14 @@
 
+Tue Apr 16 13:02:28 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+       * AssemblyBuilder.cs: pad output file to file alignment.
+       * FieldBuilder.cs: ReflectedType.
+       * ModuleBuilder.cs: added guid generation and array method creation.
+       * MonoArrayMethod.cs: array method support code.
+       
 Wed Apr 10 12:57:31 CEST 2002 Paolo Molaro <lupus@ximian.com>
 
-       * ILGenerator,cs: use a stack to keep track of exception blocks.
+       * ILGenerator.cs: use a stack to keep track of exception blocks.
 
 Mon Apr  8 06:19:01  2002 Piers Haken <piersh@friskit.com>
 
index 32ac52c5e93c2dcdab2c674bec888f7939e409b3..0a1a9e91d96d9c17158ab722e9a13e339e541edf 100755 (executable)
@@ -52,7 +52,7 @@ namespace System.Reflection.Emit {
                        get {return name;}
                }
                public override Type ReflectedType {
-                       get {return null;}
+                       get {return typeb;}
                }
 
                public override object[] GetCustomAttributes(bool inherit) {
index b0ae320ae0e8a15de681019675ccf392a20a5b1d..3e0d1253dad81075bcec2e181d9fddc687662be9 100644 (file)
@@ -20,6 +20,7 @@ namespace System.Reflection.Emit {
        public class ModuleBuilder : Module {
                private TypeBuilder[] types;
                private CustomAttributeBuilder[] cattrs;
+               private byte[] guid;
                private int table_idx;
                private AssemblyBuilder assemblyb;
                private ISymbolWriter symbol_writer;
@@ -29,6 +30,7 @@ namespace System.Reflection.Emit {
                        this.name = this.scopename = name;
                        this.fqname = fullyqname;
                        this.assembly = this.assemblyb = assb;
+                       guid = Guid.NewGuid().ToByteArray ();
                        table_idx = get_next_table_index (0x00, true);
                        name_cache = new Hashtable ();
 
@@ -113,7 +115,7 @@ namespace System.Reflection.Emit {
                }
 
                public MethodInfo GetArrayMethod( Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
-                       return null;
+                       return new MonoArrayMethod (arrayClass, methodName, callingConvention, returnType, parameterTypes);
                }
 
                public EnumBuilder DefineEnum( string name, TypeAttributes visibility, Type underlyingType) {
diff --git a/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs b/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs
new file mode 100755 (executable)
index 0000000..130cd3e
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// System.Reflection/MonoMethod.cs
+// The class used to represent methods from the mono runtime.
+//
+// Author:
+//   Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection {
+       internal class MonoArrayMethod: MethodInfo {
+               internal RuntimeMethodHandle mhandle;
+               internal Type parent;
+               internal Type ret;
+               internal Type[] parameters;
+               internal string name;
+               internal int table_idx;
+               internal CallingConventions call_conv;
+
+               internal MonoArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+                       name = methodName;
+                       parent = arrayClass;
+                       ret = returnType;
+                       parameters = (Type[])parameterTypes.Clone();
+                       call_conv = callingConvention;
+               }
+               
+               [MonoTODO]
+               public override MethodInfo GetBaseDefinition() {
+                       return this; /* FIXME */
+               }
+               public override Type ReturnType {
+                       get {
+                               return ret;
+                       }
+               }
+               [MonoTODO]
+               public override ICustomAttributeProvider ReturnTypeCustomAttributes { 
+                       get {return null;}
+               }
+               
+               [MonoTODO]
+               public override MethodImplAttributes GetMethodImplementationFlags() {
+                       return (MethodImplAttributes)0;
+               }
+
+               [MonoTODO]
+               public override ParameterInfo[] GetParameters() {
+                       return new ParameterInfo [0];
+               }
+
+               [MonoTODO]
+               public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
+                       throw new NotImplementedException ();
+               }
+
+               public override RuntimeMethodHandle MethodHandle { 
+                       get {return mhandle;} 
+               }
+               [MonoTODO]
+               public override MethodAttributes Attributes { 
+                       get {
+                               return (MethodAttributes)0;
+                       } 
+               }
+               
+               public override Type ReflectedType {
+                       get {
+                               return parent;
+                       }
+               }
+               public override Type DeclaringType {
+                       get {
+                               return parent;
+                       }
+               }
+               public override string Name {
+                       get {
+                               return name;
+                       }
+               }
+               
+               public override bool IsDefined (Type attributeType, bool inherit) {
+                       return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
+               }
+
+               public override object[] GetCustomAttributes( bool inherit) {
+                       return MonoCustomAttrs.GetCustomAttributes (this, inherit);
+               }
+               public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
+                       return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
+               }
+
+               public override string ToString () {
+                       string parms = "";
+                       ParameterInfo[] p = GetParameters ();
+                       for (int i = 0; i < p.Length; ++i) {
+                               if (i > 0)
+                                       parms = parms + ", ";
+                               parms = parms + p [i].ParameterType.Name;
+                       }
+                       return ReturnType.Name+" "+Name+"("+parms+")";
+               }
+       }
+}