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 all the types definied (classes, structs, ifaces, enums)
43 root_types = new RootTypes ();
45 decls = new Hashtable ();
48 // TODO: Move this check to current_container.Add..... method
49 // I guess we can save cpu&mem
50 public void RecordDecl (Namespace ns, MemberName name, DeclSpace ds)
52 DeclSpace other = (DeclSpace) decls [name];
54 Report.SymbolRelatedToPreviousError (other);
56 PartialContainer other_pc = other as PartialContainer;
57 if (ds is TypeContainer && other_pc != null) {
58 Report.SymbolRelatedToPreviousError (other);
59 Report.Error (260, ds.Location,
60 "Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists",
64 Report.Error (101, ds.Location,
65 "The namespace `{0}' already contains a definition for `{1}'", ns.GetSignatureForError (), name.Name);
71 if (ds.Parent == Types)
72 ns.AddDeclSpace (name.Basename, ds);
76 // FIXME: Why are we using Types?
78 public TypeContainer Types {
79 get { return root_types; }
82 public DeclSpace GetDecl (MemberName name)
84 return (DeclSpace) decls [name];
87 public Hashtable AllDecls {
92 public class RootTypes : TypeContainer
95 : base (null, null, MemberName.Null, null, Kind.Root, Location.Null)
97 ec = new EmitContext (null, this, Location.Null, null, null, 0, false);
100 public override PendingImplementation GetPendingImplementations ()
102 throw new InvalidOperationException ();
105 public override bool IsClsComplianceRequired (DeclSpace ds)
110 public override string GetSignatureForError ()