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 ();
50 decls = new Hashtable ();
51 namespaces = new Hashtable ();
54 DoubleHash decl_ns_name = new DoubleHash ();
56 public void RecordDecl (MemberName member_name, DeclSpace ds)
58 string name = (string) member_name;
60 if (decls.Contains (name)){
63 "There is already a definition for `" + name + "'");
64 DeclSpace other = (DeclSpace) decls [name];
66 other.Location, "(Location of symbol related to previous error)");
72 int p = name.LastIndexOf ('.');
74 decl_ns_name.Insert ("", name, ds);
76 decl_ns_name.Insert (name.Substring (0, p), name.Substring (p+1), ds);
82 public DeclSpace LookupByNamespace (string ns, string name)
86 decl_ns_name.Lookup (ns, name, out res);
87 return (DeclSpace) res;
90 public NamespaceEntry RecordNamespace (NamespaceEntry parent, SourceFile file, string name, Location loc)
92 NamespaceEntry ns = new NamespaceEntry (parent, file, name, loc);
94 if (namespaces.Contains (file)){
95 Hashtable ns_ns = (Hashtable) namespaces [file];
97 if (ns_ns.Contains (ns.FullName))
98 return (NamespaceEntry) ns_ns [ns.FullName];
99 ns_ns.Add (ns.FullName, ns);
101 Hashtable new_table = new Hashtable ();
102 namespaces [file] = new_table;
104 new_table.Add (ns.FullName, ns);
111 // FIXME: Why are we using Types?
113 public TypeContainer Types {
119 public Hashtable Decls {
125 public Hashtable Namespaces {