using System;
+using System.Collections;
namespace Mono.ILASM {
- public class FieldDef {
+ public class FieldDef : ICustomAttrTarget {
private string name;
- private ITypeRef type;
+ private BaseTypeRef type;
private PEAPI.FieldAttr attr;
private PEAPI.FieldDef field_def;
+ private ArrayList customattr_list;
+ private PEAPI.NativeType native_type;
private bool offset_set;
- private bool datavalue_set;
+// private bool datavalue_set;
private bool value_set;
private bool is_resolved;
private string at_data_id;
public FieldDef (PEAPI.FieldAttr attr, string name,
- ITypeRef type)
+ BaseTypeRef type)
{
this.attr = attr;
this.name = name;
this.type = type;
offset_set = false;
- datavalue_set = false;
+// datavalue_set = false;
value_set = false;
at_data_id = null;
set { attr = value; }
}
+ public BaseTypeRef Type {
+ get { return type; }
+ }
+
public void SetOffset (uint val)
{
offset_set = true;
this.at_data_id = at_data_id;
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public void AddMarshalInfo (PEAPI.NativeType native_type)
+ {
+ this.native_type = native_type;
+ }
+
public PEAPI.FieldDef Resolve (CodeGen code_gen)
{
if (is_resolved)
type.Resolve (code_gen);
field_def = classdef.AddField (attr, name, type.PeapiType);
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list)
+ customattr.AddTo (code_gen, field_def);
+
+ if (native_type != null)
+ field_def.SetMarshalInfo (native_type);
+
is_resolved = true;
return field_def;