2006-04-28 Marek Safar <marek.safar@seznam.cz>
[mono.git] / mcs / mcs / 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                 public Tree ()
37                 {
38                         root_types = new RootTypes ();
39                 }
40
41                 public void RecordDecl (Namespace ns, MemberName name, DeclSpace ds)
42                 {
43                         if (ds.Parent == root_types)
44                                 ns.AddDeclSpace (name.Basename, ds);
45                 }
46                 
47                 //
48                 // FIXME: Why are we using Types?
49                 //
50                 public TypeContainer Types {
51                         get { return root_types; }
52                 }
53         }
54
55         public sealed class RootTypes : TypeContainer
56         {
57                 public RootTypes ()
58                         : base (null, null, MemberName.Null, null, Kind.Root)
59                 {
60                         types = new ArrayList ();
61                 }
62
63                 public override bool IsClsComplianceRequired ()
64                 {
65                         return true;
66                 }
67
68                 public override bool GetClsCompliantAttributeValue ()
69                 {
70                         return CodeGen.Assembly.IsClsCompliant;
71                 }
72
73                 public override string GetSignatureForError ()
74                 {
75                         return "";
76                 }
77
78                 protected override bool AddToTypeContainer (DeclSpace ds)
79                 {
80                         return AddToContainer (ds, ds.Name);
81                 }
82
83                 public override TypeContainer AddPartial (TypeContainer nextPart)
84                 {
85                         return AddPartial (nextPart, nextPart.Name);
86                 }
87
88         }
89 }