2 // tree.cs: keeps a tree representation of the generated code
4 // Author: Miguel de Icaza (miguel@gnu.org)
6 // Licensed under the terms of the GNU GPL
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
13 using System.Collections;
14 using System.Reflection;
15 using System.Reflection.Emit;
21 public interface ITreeDump {
22 int Dump (Tree tree, StreamWriter output);
23 void ParseOptions (string options);
28 // We store here all the toplevel types that we have parsed,
29 // this is the root of all information we have parsed.
34 TypeContainer root_types;
37 // Keeps track of the interfaces defined in the source code
42 // Keeps track of the structs defined in the source code
47 // Keeps track of the classes defined in the source code
52 // Keeps track of namespaces defined in the source code
58 root_types = new TypeContainer (null, "", new Location (-1));
62 public void RecordInterface (string name, Interface iface)
65 ifaces = new Hashtable ();
67 ifaces.Add (name, iface);
70 public void RecordStruct (string name, Struct s)
73 structs = new Hashtable ();
75 structs.Add (name, s);
78 public void RecordClass (string name, Class c)
81 classes = new Hashtable ();
83 classes.Add (name, c);
86 public Namespace RecordNamespace (Namespace parent, string file, string name)
88 if (namespaces == null)
89 namespaces = new Hashtable ();
91 Namespace ns = new Namespace (parent, name);
93 if (namespaces.Contains (file)){
94 Hashtable ns_ns = (Hashtable) namespaces [file];
96 if (ns_ns.Contains (ns.Name))
97 return (Namespace) ns_ns [ns.Name];
98 ns_ns.Add (ns.Name, ns);
100 Hashtable new_table = new Hashtable ();
101 namespaces [file] = new_table;
103 new_table.Add (ns.Name, ns);
109 public TypeContainer Types {
115 public Hashtable Interfaces {
121 public Hashtable Classes {
127 public Hashtable Structs {
133 public Hashtable Namespaces {