2003-02-26 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Wed, 26 Feb 2003 14:40:21 +0000 (14:40 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 26 Feb 2003 14:40:21 +0000 (14:40 -0000)
* TypeBuilder.cs (DefineInitializedData): Removed unnecessary assignments.

* ModuleBuilder.cs (DefineInitializedData): Do not call
TypeBuilder::DefineInitializedData since that would mean defining a
nested type of the global type, which is wrong. Instead define a
new public type as MS does.

* ModuleBuilder.cs (DefineUninitializedData): Ditto.

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

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs

index 85271ea7c755ba70eed0a594061a2aab194104ae..ac50b513dc91686f6d484b3d9436809953df2523 100644 (file)
@@ -1,3 +1,13 @@
+2003-02-26  Zoltan Varga  <vargaz@freemail.hu>
+
+       * TypeBuilder.cs (DefineInitializedData): Removed unnecessary assignments.
+
+       * ModuleBuilder.cs (DefineInitializedData): Do not call 
+       TypeBuilder::DefineInitializedData since that would mean defining a
+       nested type of the global type, which is wrong. Instead define a
+       new public type as MS does.
+
+       * ModuleBuilder.cs (DefineUninitializedData): Ditto.
 
 Thu Feb 13 18:40:52 CET 2003 Paolo Molaro <lupus@ximian.com>
 
index 7d7b7f1e853987a144ec0912fca911fc20de339c..9589f9eb660996a925b2a1a0b801f7f438c4a5f5 100644 (file)
@@ -95,6 +95,8 @@ namespace System.Reflection.Emit {
                                global_type_created = global_type.CreateType ();
                }
 
+               // Same as under MS.NET
+               static int GlobalDataCount = 10000;
 
                public FieldBuilder DefineInitializedData( string name, byte[] data, FieldAttributes attributes) {
                        if (name == null)
@@ -104,7 +106,14 @@ namespace System.Reflection.Emit {
                        if (global_type == null)
                                global_type = new TypeBuilder (this, 0);
 
-                       FieldBuilder fb = global_type.DefineInitializedData (name, data, attributes);
+                       TypeBuilder datablobtype = DefineType (
+                               "$ArrayType$" + GlobalDataCount.ToString(),
+                               TypeAttributes.Public|TypeAttributes.ExplicitLayout|TypeAttributes.Sealed,
+                               assemblyb.corlib_value_type, null, PackingSize.Size1, data.Length);
+                       datablobtype.CreateType ();
+                       GlobalDataCount ++;
+                       FieldBuilder fb = global_type.DefineField (name, datablobtype, attributes|FieldAttributes.Assembly|FieldAttributes.Static|FieldAttributes.HasFieldRVA);
+                       fb.SetRVAData (data);
 
                        if (global_fields != null) {
                                FieldBuilder[] new_fields = new FieldBuilder [global_fields.Length+1];
@@ -126,8 +135,16 @@ namespace System.Reflection.Emit {
                        if (global_type == null)
                                global_type = new TypeBuilder (this, 0);
 
-                       FieldBuilder fb = global_type.DefineUninitializedData (name, size, attributes);
+                       TypeBuilder datablobtype = DefineType (
+                               "$ArrayType$" + GlobalDataCount.ToString(),
+                               TypeAttributes.Public|TypeAttributes.ExplicitLayout|TypeAttributes.Sealed,
+                               assemblyb.corlib_value_type, null, PackingSize.Size1, size);
+                       datablobtype.CreateType ();
+                       GlobalDataCount ++;
 
+                       throw new NotImplementedException ();
+
+                       /*
                        if (global_fields != null) {
                                FieldBuilder[] new_fields = new FieldBuilder [global_fields.Length+1];
                                System.Array.Copy (global_fields, new_fields, global_fields.Length);
@@ -138,6 +155,7 @@ namespace System.Reflection.Emit {
                                global_fields [0] = fb;
                        }
                        return fb;
+                       */
                }
 
                public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
index e242c48609cde8c6e9174dc6b7820213cfd3bbe8..a3c9f8596c8aaf2f6af3c9afade32dc0a45a9227 100644 (file)
@@ -816,8 +816,6 @@ namespace System.Reflection.Emit {
                        TypeBuilder datablobtype = DefineNestedType ("$ArrayType$"+InitializedDataCount.ToString(),
                                TypeAttributes.NestedPrivate|TypeAttributes.ExplicitLayout|TypeAttributes.Sealed,
                                pmodule.assemblyb.corlib_value_type, null, PackingSize.Size1, data.Length);
-                       datablobtype.packing_size = PackingSize.Size1;
-                       datablobtype.class_size = data.Length;
                        datablobtype.CreateType ();
                        FieldBuilder res = DefineField (name, datablobtype, attributes|FieldAttributes.Assembly|FieldAttributes.Static|FieldAttributes.HasFieldRVA);
                        res.SetRVAData (data);