(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / mcs / tree.cs
blobc873e706fe3b72bfb6c213e0d1a53472b167ad38
1 //
2 // tree.cs: keeps a tree representation of the generated code
3 //
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 //
6 // Licensed under the terms of the GNU GPL
7 //
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
9 //
12 using System;
13 using System.Collections;
14 using System.Reflection;
15 using System.Reflection.Emit;
16 using System.IO;
18 namespace Mono.CSharp
21 public interface ITreeDump {
22 int Dump (Tree tree, StreamWriter output);
23 void ParseOptions (string options);
26 // <summary>
27 //
28 // We store here all the toplevel types that we have parsed,
29 // this is the root of all information we have parsed.
30 //
31 // </summary>
33 public class Tree {
34 TypeContainer root_types;
36 // <summary>
37 // Keeps track of all the types definied (classes, structs, ifaces, enums)
38 // </summary>
39 Hashtable decls;
41 public Tree ()
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];
53 if (other != null){
54 PartialContainer other_pc = other as PartialContainer;
55 if ((ds is TypeContainer) && (other_pc != null)) {
56 Report.Error (
57 260, ds.Location, "Missing partial modifier " +
58 "on declaration of type `{0}'; another " +
59 "partial implementation of this type exists",
60 name);
62 Report.LocationOfPreviousError (other.Location);
63 return;
66 Report.SymbolRelatedToPreviousError (
67 other.Location, other.GetSignatureForError ());
69 Report.Error (
70 101, ds.Location,
71 "There is already a definition for `" + name + "'");
72 return;
75 ds.RecordDecl ();
77 int p = name.LastIndexOf ('.');
78 if (p == -1)
79 decl_ns_name.Insert ("", name, ds);
80 else {
81 decl_ns_name.Insert (name.Substring (0, p), name.Substring (p+1), ds);
84 decls.Add (name, ds);
87 public DeclSpace LookupByNamespace (string ns, string name)
89 object res;
91 decl_ns_name.Lookup (ns, name, out res);
92 return (DeclSpace) res;
96 // FIXME: Why are we using Types?
98 public TypeContainer Types {
99 get {
100 return root_types;
104 public Hashtable Decls {
105 get {
106 return decls;
111 public class RootTypes : TypeContainer
113 public RootTypes ()
114 : base (null, null, MemberName.Null, null, Kind.Root,
115 new Location (-1))
118 public override void Register ()
120 throw new InvalidOperationException ();
123 public override PendingImplementation GetPendingImplementations ()
125 throw new InvalidOperationException ();