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 namespaces defined in the source code
42 // Keeps track of all the types definied (classes, structs, ifaces, enums)
48 root_types = new TypeContainer (null, null, "", new Location (-1));
50 decls = new Hashtable ();
51 namespaces = new Hashtable ();
54 DoubleHash decl_ns_name = new DoubleHash ();
56 public void RecordDecl (string name, DeclSpace ds)
58 if (decls.Contains (name)){
61 "There is already a definition for `" + name + "'");
62 DeclSpace other = (DeclSpace) decls [name];
64 other.Location, "(Location of symbol related to previous error)");
70 int p = name.LastIndexOf ('.');
72 decl_ns_name.Insert ("", name, ds);
74 decl_ns_name.Insert (name.Substring (0, p), name.Substring (p+1), ds);
80 public DeclSpace LookupByNamespace (string ns, string name)
84 decl_ns_name.Lookup (ns, name, out res);
85 return (DeclSpace) res;
88 public NamespaceEntry RecordNamespace (NamespaceEntry parent, SourceFile file, string name, Location loc)
90 NamespaceEntry ns = new NamespaceEntry (parent, file, name, loc);
92 if (namespaces.Contains (file)){
93 Hashtable ns_ns = (Hashtable) namespaces [file];
95 if (ns_ns.Contains (ns.FullName))
96 return (NamespaceEntry) ns_ns [ns.FullName];
97 ns_ns.Add (ns.FullName, ns);
99 Hashtable new_table = new Hashtable ();
100 namespaces [file] = new_table;
102 new_table.Add (ns.FullName, ns);
109 // FIXME: Why are we using Types?
111 public TypeContainer Types {
117 public Hashtable Decls {
123 public Hashtable Namespaces {