Initial revision
[mono.git] / mcs / mcs / tree.cs
1 //
2 // tree.cs: keeps a tree representation of the generated code
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
12 using System;
13 using System.Collections;
14 using System.Reflection;
15
16 namespace CIR
17 {
18
19         // <summary>
20         //   A storage for temporary IL trees
21         // </summary>
22         
23         public class Tree {
24                 TypeContainer root_types;
25                 ArrayList assemblies;
26                 Type [] types;
27                 
28                 public Tree ()
29                 {
30                         root_types = new TypeContainer (null, "");
31                         assemblies = new ArrayList ();
32                 }
33
34                 public TypeContainer Types {
35                         get {
36                                 return root_types;
37                         }
38                 }
39
40                 public int ResolveTypeContainerTypes (TypeContainer type)
41                 {
42                         return 0;
43                 }
44                 
45                 public int ResolveNames (TypeContainer types)
46                 {
47                         int errors = 0;
48                         
49                         if (types == null)
50                                 return 0;
51
52                         foreach (DictionaryEntry de in types.Types){
53                                 TypeContainer type = (TypeContainer) de.Value;
54
55                                 errors += ResolveTypeContainerTypes (type);
56                         }
57
58                         return errors;
59                 }
60
61
62                 public int ResolveTypeContainerParents (TypeContainer type)
63                 {
64                         return type.ResolveParents (this);
65                 }
66
67                 public int Resolve ()
68                 {
69                         int errors = 0;
70
71                         errors += ResolveTypeContainerParents (root_types);
72                         return 0;
73                 }
74
75                 bool fix_me_hit = false;
76                 
77                 public void AddAssembly (Assembly a)
78                 {
79                         if (fix_me_hit)
80                                 Console.WriteLine ("AddAssembly currently can only hold types from one assembly");
81                         fix_me_hit = true;
82                         assemblies.Add (a);
83                         types = a.GetExportedTypes ();
84                 }
85         }
86 }