2 // Mono.ILASM.PeapiTypeRef
5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class PeapiTypeRef {
18 private PEAPI.Type peapi_type;
19 private bool is_pinned;
20 private bool is_array;
22 private bool use_type_spec;
24 public PeapiTypeRef (PEAPI.Type peapi_type)
26 this.peapi_type = peapi_type;
30 use_type_spec = false;
33 public bool IsPinned {
34 get { return is_pinned; }
38 get { return is_array; }
42 get { return is_ref; }
45 public bool UseTypeSpec {
46 get { return use_type_spec; }
49 public PEAPI.Type PeapiType {
50 get { return peapi_type; }
53 public void MakeArray ()
56 peapi_type = new PEAPI.ZeroBasedArray (peapi_type);
60 public void MakeBoundArray (ArrayList bound_list)
64 int dimen = bound_list.Count;
65 int[] lower_array = new int[dimen];
66 int[] size_array = new int[dimen];
67 bool lower_set = false;
68 bool size_set = false;
69 bool prev_lower_set = true;
70 bool prev_size_set = true;
72 // TODO: There should probably be an error reported if
73 // something like [3...,3...5] is done
74 for (int i=0; i<dimen; i++) {
75 DictionaryEntry bound = (DictionaryEntry) bound_list[i];
77 if (bound.Key != TypeRef.Ellipsis && prev_lower_set) {
78 lower_array[i] = (int) bound.Key;
81 prev_lower_set = false;
83 if (bound.Value != TypeRef.Ellipsis && prev_size_set) {
84 size_array[i] = (int) bound.Value;
87 prev_size_set = false;
90 if (lower_set && size_set) {
91 peapi_type = new PEAPI.BoundArray (peapi_type,
92 (uint) dimen, lower_array, size_array);
93 } else if (size_set) {
94 peapi_type = new PEAPI.BoundArray (peapi_type,
95 (uint) dimen, size_array);
97 peapi_type = new PEAPI.BoundArray (peapi_type, (uint) dimen);
102 public void MakeManagedPointer ()
104 use_type_spec = true;
106 peapi_type = new PEAPI.ManagedPointer (peapi_type);
110 public void MakeUnmanagedPointer ()
112 use_type_spec = true;
114 peapi_type = new PEAPI.UnmanagedPointer (peapi_type);
117 public void MakeCustomModified (CodeGen code_gen, PEAPI.CustomModifier modifier,
120 use_type_spec = true;
122 klass.Resolve (code_gen);
123 peapi_type = new PEAPI.CustomModifiedType (peapi_type,
124 modifier, klass.PeapiClass);
127 public void MakePinned ()
129 use_type_spec = true;
133 public void Resolve (CodeGen code_gen)