More work
[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 using System.Reflection.Emit;
16 using System.IO;
17
18 namespace CIR
19 {
20
21         public interface ITreeDump {
22                 int  Dump (Tree tree, StreamWriter output);
23                 void ParseOptions (string options);
24         }
25
26         // <summary>
27         //   
28         //   We store here all the toplevel types that we have parsed,
29         //   this is the root of all information we have parsed.
30         // 
31         // </summary>
32         
33         public class Tree {
34                 TypeContainer root_types;
35
36                 // <summary>
37                 //   Keeps track of the interfaces defined in the source code
38                 // </summary>
39                 Hashtable ifaces;
40
41                 // <summary>
42                 //   Keeps track of the structs defined in the source code
43                 // </summary>
44                 Hashtable structs;
45
46                 // <summary>
47                 //   Keeps track of the classes defined in the source code
48                 // </summary>
49                 Hashtable classes;
50
51                 RootContext rc;
52                 
53                 public Tree (RootContext rc)
54                 {
55                         root_types = new TypeContainer (rc, null, "");
56                         this.rc = rc;
57                 }
58
59
60                 public void RecordInterface (string name, Interface iface)
61                 {
62                         if (ifaces == null)
63                                 ifaces = new Hashtable ();
64
65                         ifaces.Add (name, iface);
66                 }
67                 
68                 public void RecordStruct (string name, Struct s)
69                 {
70                         if (structs == null)
71                                 structs = new Hashtable ();
72
73                         structs.Add (name, s);
74                 }
75                 
76                 public void RecordClass (string name, Class c)
77                 {
78                         if (classes == null)
79                                 classes = new Hashtable ();
80
81                         classes.Add (name, c);
82                 }
83                 
84                 public TypeContainer Types {
85                         get {
86                                 return root_types;
87                         }
88                 }
89
90                 public Hashtable Interfaces {
91                         get {
92                                 return ifaces;
93                         }
94                 }
95
96                 public Hashtable Classes {
97                         get {
98                                 return classes;
99                         }
100                 }
101
102                 public Hashtable Structs {
103                         get {
104                                 return structs;
105                         }
106                 }
107         }
108 }