Thu Feb 14 18:55:52 CET 2002 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Thu, 14 Feb 2002 14:18:02 +0000 (14:18 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Thu, 14 Feb 2002 14:18:02 +0000 (14:18 -0000)
* FieldBuilder.cs: Add SetRVAData().
* ILGenerator.cs: speed up code array growth.
* TypeBuilder.cs: fix IsValueTypeImpl(). Add class_size member.
Implement DefineInitializedData().

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

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs

index fe15381f0e6652e5ad12757688a03fbb53fb40df..d8dc865a28f1ac0a57630e0657cacdd79ad6f0b1 100644 (file)
@@ -1,4 +1,11 @@
 
+Thu Feb 14 18:55:52 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+       * FieldBuilder.cs: Add SetRVAData().
+       * ILGenerator.cs: speed up code array growth.
+       * TypeBuilder.cs: fix IsValueTypeImpl(). Add class_size member.
+       Implement DefineInitializedData().
+
 Tue Jan 22 23:01:11 CET 2002 Paolo Molaro <lupus@ximian.com>
 
        * EnumBuilder.cs, TypeBuilder.cs: updates for changes in Type.cs.
index be1513ed54d789a208c42cf4dbc95fa1c2ab1f84..40c78a5580df115d4904b8b409cf9d526997b2a2 100755 (executable)
@@ -24,6 +24,7 @@ namespace System.Reflection.Emit {
                private int offset;
                private int table_idx;
                internal TypeBuilder typeb;
+               private byte[] rva_data;
 
                internal FieldBuilder (TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes) {
                        attrs = attributes;
@@ -68,6 +69,9 @@ namespace System.Reflection.Emit {
                public override bool IsDefined( Type attributeType, bool inherit) {
                        return false;
                }
+               internal void SetRVAData (byte[] data) {
+                       rva_data = (byte[])data.Clone ();
+               }
                public void SetConstant( object defaultValue) {
                        /*if (defaultValue.GetType() != type)
                                throw new ArgumentException ("Constant doesn't match field type");*/
index 258aca72a4d40815c0701970d0ef4d76e33a2748..14d21be099048e0aa4b25a951492d235767094cf 100644 (file)
@@ -111,8 +111,8 @@ namespace System.Reflection.Emit {
                private void make_room (int nbytes) {
                        if (code_len + nbytes < code.Length)
                                return;
-                       byte[] new_code = new byte [code.Length + 128];
-                       System.Array.Copy (code, new_code, code.Length);
+                       byte[] new_code = new byte [code.Length * 2 + 128];
+                       System.Array.Copy (code, 0, new_code, 0, code.Length);
                        code = new_code;
                }
                private void emit_int (int val) {
index 26605d5e25585fcc802f7b4377313b05895713d3..06fa66caecbf16fb77a6eeb6486858583cd38423 100644 (file)
@@ -28,6 +28,7 @@ namespace System.Reflection.Emit {
        private TypeAttributes attrs;
        private int table_idx;
        private ModuleBuilder pmodule;
+       private int class_size;
        private PackingSize packing_size;
 
        public const int UnspecifiedTypeSize = -1;
@@ -359,7 +360,7 @@ namespace System.Reflection.Emit {
                }
                protected override bool IsValueTypeImpl () {
                        // test this one
-                       return (Attributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ValueType;
+                       return type_is_subtype_of (this, typeof (System.ValueType));
                }
                
                public override RuntimeTypeHandle TypeHandle { get { return _impl; } }
@@ -373,8 +374,19 @@ namespace System.Reflection.Emit {
                        return null;
                }
 
+               static int InitializedDataCount = 0;
+               
                public FieldBuilder DefineInitializedData( string name, byte[] data, FieldAttributes attributes) {
-                       return null;
+                       TypeBuilder datablobtype = pmodule.DefineType ("$ArrayType$"+InitializedDataCount.ToString(),
+                               TypeAttributes.Public|TypeAttributes.ExplicitLayout|TypeAttributes.Sealed,
+                               typeof (System.ValueType), 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);
+                       InitializedDataCount++;
+                       return res;
                }
 
                public FieldBuilder DefineUninitializedData( string name, int size, FieldAttributes attributes) {