+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.
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;
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");*/
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) {
private TypeAttributes attrs;
private int table_idx;
private ModuleBuilder pmodule;
+ private int class_size;
private PackingSize packing_size;
public const int UnspecifiedTypeSize = -1;
}
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; } }
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) {