2 // Mono.ILASM.GenericArguments
5 // Ankit Jain <jankit@novell.com>
7 // Copyright 2005 Novell, Inc (http://www.novell.com)
11 using System
.Collections
;
14 namespace Mono
.ILASM
{
16 public class GenericArguments
{
19 BaseTypeRef
[] type_arr
;
21 PEAPI
.Type
[] p_type_list
;
23 public GenericArguments ()
33 get { return type_list.Count; }
36 public void Add (BaseTypeRef type
)
39 throw new InternalErrorException ();
41 if (type_list
== null)
42 type_list
= new ArrayList ();
43 var prim
= PrimitiveTypeRef
.GetPrimitiveType (type
.FullName
);
52 public BaseTypeRef
[] ToArray ()
54 if (type_list
== null)
57 type_arr
= (BaseTypeRef
[]) type_list
.ToArray (typeof (BaseTypeRef
));
62 public PEAPI
.Type
[] Resolve (CodeGen code_gen
)
68 p_type_list
= new PEAPI
.Type
[type_list
.Count
];
69 foreach (BaseTypeRef type
in type_list
) {
70 type
.Resolve (code_gen
);
71 p_type_list
[i
++] = type
.PeapiType
;
78 public void Resolve (GenericParameters type_gen_params
, GenericParameters method_gen_params
)
80 foreach (BaseTypeRef type
in type_list
) {
81 BaseGenericTypeRef gtr
= type
as BaseGenericTypeRef
;
83 gtr
.Resolve (type_gen_params
, method_gen_params
);
85 /* Reset, might have changed (think GenericParamRef) */
89 private void MakeString ()
91 //Build full_name (foo < , >)
92 StringBuilder sb
= new StringBuilder ();
94 foreach (BaseTypeRef tr
in type_list
)
95 sb
.AppendFormat ("{0}, ", tr
.FullName
);
96 //Remove the extra ', ' at the end
99 type_str
= sb
.ToString ();
102 public override string ToString ()
104 if (type_str
== null)