2001-11-05 Miguel de Icaza <miguel@ximian.com>
[mono.git] / mcs / mcs / type.cs
1 //
2 // type.cs: Type container.
3 //
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 //
6 // Licensed under the terms of the GNU GPL
7 //
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
9 //
10
11 namespace CIR {
12         using System.Collections;
13         using System;
14
15         public class xUnresolvedType {
16                 TypeContainer parent;
17                 string name;
18                 
19                 public xUnresolvedType (TypeContainer parent, string name)
20                 {
21                         this.parent = parent;
22                         this.name = name;
23                 }
24
25                 public string Name {
26                         get {
27                                 return name;
28                         }
29                 }
30
31                 public TypeContainer Parent {
32                         get {
33                                 return parent;
34                         }
35                 }
36         }
37         
38         public class xTypeRef {
39                 object data;
40
41                 public xTypeRef (object data)
42                 {
43                         this.data = data;
44                 }
45
46                 public Object Data {
47                         get {
48                                 return data;
49                         }
50                 }
51
52                 public xUnresolvedType UnresolvedData {
53                         get {
54                                 if (data is UnresolvedType)
55                                         return (UnresolvedType) data;
56                                 else
57                                         return null;
58                         }
59                 }
60
61                 public Type Type {
62                         get {
63                                 if (data is UnresolvedType)
64                                         Resolve ();
65                                 
66                                 return (Type) data;
67                         }
68                 }
69                 
70                 public bool IsResolved {
71                         get {
72                                 return !(data is UnresolvedType);
73                         }
74                 }
75
76                 public bool Resolve () {
77                         return false;
78                 }
79         }
80
81         public class xTypeRefManager {
82                 ArrayList pending_types;
83                 
84                 public xTypeRefManager ()
85                 {
86                         pending_types = new ArrayList ();
87                 }
88
89                 public TypeRef GetTypeRef (TypeContainer container, string name)
90                 {
91                         object unresolved;
92                         TypeRef typeref;
93
94                         unresolved = new UnresolvedType (container, name);
95                         typeref = new TypeRef (unresolved);
96                         pending_types.Add (typeref);
97
98                         return typeref;
99                 }
100         }
101 }
102
103
104