2 // Mono.ILASM.GenericParamRef
5 // Jackson Harper (Jackson@LatitudeGeo.com)
6 // Ankit Jain (JAnkit@novell.com)
8 // (C) 2003 Jackson Harper, All rights reserved
9 // (C) 2006 Novell, Inc (http://www.novell.com)
14 using System
.Collections
;
16 namespace Mono
.ILASM
{
18 public class GenericParamRef
: BaseGenericTypeRef
{
20 /* PEAPI.Type type: Might get modified */
21 /* Unmodified GenParam */
22 private PEAPI
.GenParam param
;
23 private bool is_added
; /* Added to TypeSpec table ? */
24 private static Hashtable param_table
= new Hashtable ();
26 public GenericParamRef (PEAPI
.GenParam gen_param
, string full_name
)
27 : this (gen_param
, full_name
, null)
31 public GenericParamRef (PEAPI
.GenParam gen_param
, string full_name
, ArrayList conv_list
)
32 : base (full_name
, false, conv_list
, "")
34 this.type
= gen_param
;
35 this.param
= gen_param
;
39 public override string FullName
{
41 return (param
.Type
== PEAPI
.GenParamType
.Var
? "!" : "!!")
42 + param
.Index
+ sig_mod
;
46 public override void MakeValueClass ()
48 throw new InternalErrorException ("Not supported");
51 public override BaseTypeRef
Clone ()
53 return new GenericParamRef (param
, full_name
, (ArrayList
) ConversionList
.Clone ());
56 public override void ResolveNoTypeSpec (CodeGen code_gen
)
61 type
= Modify (code_gen
, type
);
65 public override void Resolve (CodeGen code_gen
)
67 ResolveNoTypeSpec (code_gen
);
71 string key
= param
.Type
.ToString () + param
.Index
.ToString ();
72 PEAPI
.GenParam val
= (PEAPI
.GenParam
) param_table
[key
];
74 code_gen
.PEFile
.AddGenericParam (param
);
75 param_table
[key
] = param
;
77 /* Set this instance's "type" to the cached
78 PEAPI.GenParam, after applying modifications */
79 type
= Modify (code_gen
, val
);
85 public override void Resolve (GenericParameters type_gen_params
, GenericParameters method_gen_params
)
87 if (param
.Name
== "") {
88 /* Name wasn't specified */
92 if (param
.Type
== PEAPI
.GenParamType
.MVar
&& method_gen_params
!= null)
93 param
.Index
= method_gen_params
.GetGenericParamNum (param
.Name
);
94 else if (type_gen_params
!= null)
95 param
.Index
= type_gen_params
.GetGenericParamNum (param
.Name
);
98 Report
.Error (String
.Format ("Invalid {0}type parameter '{1}'",
99 (param
.Type
== PEAPI
.GenParamType
.MVar
? "method " : ""),
103 protected override BaseMethodRef
CreateMethodRef (BaseTypeRef ret_type
, PEAPI
.CallConv call_conv
,
104 string name
, BaseTypeRef
[] param
, int gen_param_count
)
106 return new TypeSpecMethodRef (this, call_conv
, ret_type
, name
, param
, gen_param_count
);
109 protected override IFieldRef
CreateFieldRef (BaseTypeRef ret_type
, string name
)
111 return new TypeSpecFieldRef (this, ret_type
, name
);