2 // Mono.ILASM.PropertyDef
5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All right reserved
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class PropertyDef : ICustomAttrTarget {
18 private FeatureAttr attr;
20 private BaseTypeRef type;
21 private ArrayList arg_list;
22 private PEAPI.Property prop_def;
23 private bool is_resolved;
24 private ArrayList customattr_list;
26 private MethodRef _get;
27 private MethodRef _set;
28 private MethodRef other;
29 private PEAPI.Constant init_value;
31 public PropertyDef (FeatureAttr attr, BaseTypeRef type, string name, ArrayList arg_list)
36 this.arg_list = arg_list;
40 public void AddCustomAttribute (CustomAttr customattr)
42 if (customattr_list == null)
43 customattr_list = new ArrayList ();
45 customattr_list.Add (customattr);
48 public PEAPI.Property Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
53 PEAPI.Type[] type_list = new PEAPI.Type[arg_list.Count];
55 for (int i=0; i<type_list.Length; i++) {
56 BaseTypeRef arg_type = (BaseTypeRef) arg_list[i];
57 arg_type.Resolve (code_gen);
58 type_list[i] = arg_type.PeapiType;
61 type.Resolve (code_gen);
62 prop_def = classdef.AddProperty (name, type.PeapiType, type_list);
64 if ((attr & FeatureAttr.Rtspecialname) != 0)
65 prop_def.SetRTSpecialName ();
67 if ((attr & FeatureAttr.Specialname) != 0)
68 prop_def.SetSpecialName ();
70 prop_def.SetInstance ((attr & FeatureAttr.Instance) != 0);
72 if (customattr_list != null)
73 foreach (CustomAttr customattr in customattr_list)
74 customattr.AddTo (code_gen, prop_def);
82 public void Define (CodeGen code_gen, PEAPI.ClassDef classdef)
85 Resolve (code_gen, classdef);
88 _get.Resolve (code_gen);
89 prop_def.AddGetter ((PEAPI.MethodDef) _get.PeapiMethod);
93 _set.Resolve (code_gen);
94 prop_def.AddSetter ((PEAPI.MethodDef) _set.PeapiMethod);
98 other.Resolve (code_gen);
99 prop_def.AddOther ((PEAPI.MethodDef) other.PeapiMethod);
102 if (init_value != null)
103 prop_def.AddInitValue (init_value);
106 public void AddGet (MethodRef _get)
111 public void AddSet (MethodRef _set)
116 public void AddOther (MethodRef other)
121 public void AddInitValue (PEAPI.Constant init_value)
123 this.init_value = init_value;