Brush.jvm.cs: added brush transform field
[mono.git] / mcs / gmcs / tree.cs
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 //
10 //
11
12 using System;
13 using System.Collections;
14 using System.Reflection;
15 using System.Reflection.Emit;
16 using System.IO;
17
18 namespace Mono.CSharp
19 {
20
21         public interface ITreeDump {
22                 int  Dump (Tree tree, StreamWriter output);
23                 void ParseOptions (string options);
24         }
25
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>
32         
33         public class Tree {
34                 TypeContainer root_types;
35
36                 // <summary>
37                 //   Keeps track of all the types definied (classes, structs, ifaces, enums)
38                 // </summary>
39                 Hashtable decls;
40                 
41                 public Tree ()
42                 {
43                         root_types = new RootTypes ();
44
45                         decls = new Hashtable ();
46                 }
47
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)
51                 {
52                         DeclSpace other = (DeclSpace) decls [name];
53                         if (other != null){
54                                 Report.SymbolRelatedToPreviousError (other);
55
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",
61                                                 name);
62                                 }
63                                 else
64                                         Report.Error (101, ds.Location, 
65                                                 "The namespace `{0}' already contains a definition for `{1}'", ns.GetSignatureForError (), name.Name);
66                                 return;
67                         }
68
69                         decls.Add (name, ds);
70
71                         if (ds.Parent == Types)
72                                 ns.AddDeclSpace (name.Basename, ds);
73                 }
74                 
75                 //
76                 // FIXME: Why are we using Types?
77                 //
78                 public TypeContainer Types {
79                         get { return root_types; }
80                 }
81
82                 public DeclSpace GetDecl (MemberName name)
83                 {
84                         return (DeclSpace) decls [name];
85                 }
86
87                 public Hashtable AllDecls {
88                         get { return decls; }
89                 }
90         }
91
92         public class RootTypes : TypeContainer
93         {
94                 public RootTypes ()
95                         : base (null, null, MemberName.Null, null, Kind.Root, Location.Null)
96                 {
97                         ec = new EmitContext (null, this, Location.Null, null, null, 0, false);
98                 }
99
100                 public override PendingImplementation GetPendingImplementations ()
101                 {
102                         throw new InvalidOperationException ();
103                 }
104
105                 public override bool IsClsComplianceRequired (DeclSpace ds)
106                 {
107                         return true;
108                 }
109
110                 public override string GetSignatureForError ()
111                 {
112                         return "";
113                 }
114
115
116         }
117 }