**** Merged from MCS ****
[mono-project.git] / mcs / ilasm / codegen / GenericTypeInst.cs
blobbcd704870aba208f914c4740803dbacfcc9d6fdc
1 //
2 // Mono.ILASM.GenericTypeInst
3 //
4 // Author(s):
5 // Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Latitude Geographics Group, All rights reserved
8 //
11 using System;
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class GenericTypeInst : ModifiableType, ITypeRef {
18 private string full_name;
19 private string sig_mod;
20 private ITypeRef[] type_list;
21 private PEAPI.Type gen_inst;
23 private bool is_resolved;
25 public GenericTypeInst (string full_name,
26 ITypeRef[] type_list)
28 this.full_name = full_name;
29 this.type_list = type_list;
30 sig_mod = String.Empty;
31 is_resolved = false;
34 public string FullName {
35 get { return full_name + sig_mod; }
38 public override string SigMod {
39 get { return sig_mod; }
40 set { sig_mod = value; }
43 public PEAPI.Type PeapiType {
44 get { return gen_inst; }
47 public void Resolve (CodeGen code_gen)
49 if (is_resolved)
50 return;
52 PEAPI.Type p_gen_type;
53 PEAPI.Type[] p_type_list = new PEAPI.Type[type_list.Length];
55 p_gen_type = code_gen.TypeManager.GetPeapiType (full_name);
57 for (int i=0; i<p_type_list.Length; i++) {
58 type_list[i].Resolve (code_gen);
59 p_type_list[i] = type_list[i].PeapiType;
62 gen_inst = new PEAPI.GenericTypeInst (p_gen_type, p_type_list);
63 gen_inst = Modify (code_gen, gen_inst);
65 is_resolved = true;
68 public IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
69 string name, ITypeRef[] param)
71 return new TypeSpecMethodRef (this, ret_type, call_conv, name, param);
74 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
76 return new TypeSpecFieldRef (this, ret_type, name);