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 DoubleHash decl_ns_name
= new DoubleHash ();
50 public void RecordDecl (string name
, DeclSpace ds
)
52 DeclSpace other
= (DeclSpace
) decls
[name
];
54 PartialContainer other_pc
= other
as PartialContainer
;
55 if ((ds
is TypeContainer
) && (other_pc
!= null)) {
57 260, ds
.Location
, "Missing partial modifier " +
58 "on declaration of type `{0}'; another " +
59 "partial implementation of this type exists",
62 Report
.LocationOfPreviousError (other
.Location
);
66 Report
.SymbolRelatedToPreviousError (
67 other
.Location
, other
.GetSignatureForError ());
71 "There is already a definition for `" + name
+ "'");
77 int p
= name
.LastIndexOf ('.');
79 decl_ns_name
.Insert ("", name
, ds
);
81 decl_ns_name
.Insert (name
.Substring (0, p
), name
.Substring (p
+1), ds
);
87 public DeclSpace
LookupByNamespace (string ns
, string name
)
91 decl_ns_name
.Lookup (ns
, name
, out res
);
92 return (DeclSpace
) res
;
96 // FIXME: Why are we using Types?
98 public TypeContainer Types
{
104 public Hashtable Decls
{
111 public class RootTypes
: TypeContainer
114 : base (null, null, MemberName
.Null
, null, Kind
.Root
,
118 public override void Register ()
120 throw new InvalidOperationException ();
123 public override PendingImplementation
GetPendingImplementations ()
125 throw new InvalidOperationException ();