merge -r 53370:58178
[mono.git] / mcs / ilasm / codegen / GenericTypeInst.cs
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 //
9
10
11 using System;
12 using System.Collections;
13
14 namespace Mono.ILASM {
15
16         public class GenericTypeInst : ModifiableType, ITypeRef {
17
18                 private string full_name;
19                 private string sig_mod;
20                 private ITypeRef[] type_list;
21                 private PEAPI.Type gen_inst;
22
23                 private bool is_resolved;
24
25                 public GenericTypeInst (string full_name,
26                                 ITypeRef[] type_list)
27                 {
28                         this.full_name = full_name;
29                         this.type_list = type_list;
30                         sig_mod = String.Empty;
31                         is_resolved = false;
32                 }
33
34                 public string FullName {
35                         get { return full_name + sig_mod; }
36                 }
37
38                 public override string SigMod {
39                         get { return sig_mod; }
40                         set { sig_mod = value; }
41                 }
42
43                 public PEAPI.Type PeapiType {
44                         get { return gen_inst; }
45                 }
46
47                 public void Resolve (CodeGen code_gen)
48                 {
49                         if (is_resolved)
50                                 return;
51
52                         PEAPI.Type p_gen_type;
53                         PEAPI.Type[] p_type_list = new PEAPI.Type[type_list.Length];
54
55                         p_gen_type = code_gen.TypeManager.GetPeapiType (full_name);
56
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;
60                         }
61
62                         gen_inst = new PEAPI.GenericTypeInst (p_gen_type, p_type_list);
63                         gen_inst = Modify (code_gen, gen_inst);
64
65                         is_resolved = true;
66                 }
67
68                 public IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
69                                 string name, ITypeRef[] param)
70                 {
71                         return new TypeSpecMethodRef (this, ret_type, call_conv, name, param);
72                 }
73
74                 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
75                 {
76                         return new TypeSpecFieldRef (this, ret_type, name);
77                 }
78
79         }
80
81 }
82
83