[ilasm] Clenup warnings
[mono.git] / mcs / ilasm / codegen / FieldDef.cs
index 9377f746de88afe375d1bb76424ec898d8556d7a..456b9a5ee239bccfc8984545a759ca195eda8a26 100644 (file)
@@ -9,18 +9,21 @@
 
 
 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;
@@ -30,14 +33,14 @@ namespace Mono.ILASM {
                 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;
@@ -62,6 +65,10 @@ namespace Mono.ILASM {
                         set { attr = value; }
                 }
 
+                public BaseTypeRef Type {
+                        get { return type; }
+                }
+
                 public void SetOffset (uint val)
                 {
                         offset_set = true;
@@ -79,6 +86,19 @@ namespace Mono.ILASM {
                         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)
@@ -100,6 +120,13 @@ namespace Mono.ILASM {
                         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;