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 if (bound_list
[i
] != null) {
76 DictionaryEntry bound
= (DictionaryEntry
) bound_list
[i
];
78 if (bound
.Key
!= TypeRef
.Ellipsis
&& prev_lower_set
) {
79 lower_array
[i
] = (int) bound
.Key
;
82 prev_lower_set
= false;
84 if (bound
.Value
!= TypeRef
.Ellipsis
&& prev_size_set
) {
85 size_array
[i
] = (int) bound
.Value
;
88 prev_size_set
= false;
92 if (lower_set
&& size_set
) {
93 peapi_type
= new PEAPI
.BoundArray (peapi_type
,
94 (uint) dimen
, lower_array
, size_array
);
95 } else if (size_set
) {
96 peapi_type
= new PEAPI
.BoundArray (peapi_type
,
97 (uint) dimen
, size_array
);
99 peapi_type
= new PEAPI
.BoundArray (peapi_type
, (uint) dimen
);
104 public void MakeManagedPointer ()
106 use_type_spec
= true;
108 peapi_type
= new PEAPI
.ManagedPointer (peapi_type
);
112 public void MakeUnmanagedPointer ()
114 use_type_spec
= true;
116 peapi_type
= new PEAPI
.UnmanagedPointer (peapi_type
);
119 public void MakeCustomModified (CodeGen code_gen
, PEAPI
.CustomModifier modifier
,
122 use_type_spec
= true;
124 klass
.Resolve (code_gen
);
125 peapi_type
= new PEAPI
.CustomModifiedType (peapi_type
,
126 modifier
, klass
.PeapiClass
);
129 public void MakePinned ()
131 use_type_spec
= true;
135 public void Resolve (CodeGen code_gen
)