2004-08-07 Anirban Bhattacharjee <banirban@novell.com>
[mono.git] / mcs / mbas / tree.cs
index 452d6a941dc5056ec76f95cfde71de37419215eb..6ff1923dbe7bb234d1d77bc9212fdeaf2eaa2ac3 100644 (file)
-//\r
-// tree.cs: keeps a tree representation of the generated code\r
-//\r
-// Author: Miguel de Icaza (miguel@gnu.org)\r
-//\r
-// Licensed under the terms of the GNU GPL\r
-//\r
-// (C) 2001 Ximian, Inc (http://www.ximian.com)\r
-//\r
-//\r
-\r
-using System;\r
-using System.Collections;\r
-using System.Reflection;\r
-using System.Reflection.Emit;\r
-using System.IO;\r
-\r
-namespace Mono.CSharp\r
-{\r
-\r
-       public interface ITreeDump {\r
-               int  Dump (Tree tree, StreamWriter output);\r
-               void ParseOptions (string options);\r
-       }\r
-\r
-       // <summary>\r
-       //   \r
-       //   We store here all the toplevel types that we have parsed,\r
-       //   this is the root of all information we have parsed.\r
-       // \r
-       // </summary>\r
-       \r
-       public class Tree {\r
-               TypeContainer root_types;\r
-\r
-               // <summary>\r
-               //   Keeps track of the interfaces defined in the source code\r
-               // </summary>\r
-               Hashtable ifaces;\r
-\r
-               // <summary>\r
-               //   Keeps track of the structs defined in the source code\r
-               // </summary>\r
-               Hashtable structs;\r
-\r
-               // <summary>\r
-               //   Keeps track of the classes defined in the source code\r
-               // </summary>\r
-               Hashtable classes;\r
-\r
-               // <summary>\r
-               //  Keeps track of namespaces defined in the source code\r
-               // </summary>\r
-               Hashtable namespaces;\r
-\r
-               // <summary>\r
-               //  Keeps track of enums defined\r
-               // </summary>\r
-               Hashtable enums;\r
-               \r
-               public Tree ()\r
-               {\r
-                       root_types = new TypeContainer (null, "", new Location (-1));\r
-               }\r
-\r
-               void RecordDecl (Hashtable decl, string name, DeclSpace ds)\r
-               {\r
-                       if (decl.Contains (name)){\r
-                               Report.Error (\r
-                                       101, ds.Location,\r
-                                       "There is already a definition for `" + name + "'");\r
-                               DeclSpace other = (DeclSpace) decl [name];\r
-                               Report.Error (0,\r
-                                       other.Location, "(Location of symbol related to previous error)");\r
-                               return;\r
-                       }\r
-                       decl.Add (name, ds);\r
-               }\r
-               \r
-               public void RecordInterface (string name, Interface iface)\r
-               {\r
-                       if (ifaces == null)\r
-                               ifaces = new Hashtable ();\r
-\r
-                       RecordDecl (ifaces, name, iface);\r
-               }\r
-               \r
-               public void RecordStruct (string name, Struct s)\r
-               {\r
-                       if (structs == null)\r
-                               structs = new Hashtable ();\r
-\r
-                       RecordDecl (structs, name, s);\r
-               }\r
-               \r
-               public void RecordClass (string name, Class c)\r
-               {\r
-                       if (classes == null)\r
-                               classes = new Hashtable ();\r
-\r
-                       RecordDecl (classes, name, c);\r
-               }\r
-\r
-               public void RecordEnum (string name, Enum e)\r
-               {\r
-                       if (enums == null)\r
-                               enums = new Hashtable ();\r
-\r
-                       RecordDecl (enums, name, e);\r
-               }\r
-\r
-               public Namespace RecordNamespace (Namespace parent, string file, string name)\r
-               {\r
-                       if (namespaces == null)\r
-                               namespaces = new Hashtable ();\r
-                                                                                                    \r
-                       Namespace ns = new Namespace (parent, name);\r
-\r
-                       if (namespaces.Contains (file)){\r
-                               Hashtable ns_ns = (Hashtable) namespaces [file];\r
-\r
-                               if (ns_ns.Contains (ns.Name))\r
-                                       return (Namespace) ns_ns [ns.Name];\r
-                               ns_ns.Add (ns.Name, ns);\r
-                       } else {\r
-                               Hashtable new_table = new Hashtable ();\r
-                               namespaces [file] = new_table;\r
-\r
-                               new_table.Add (ns.Name, ns);\r
-                       }\r
-\r
-                       return ns;\r
-               }\r
-               \r
-               public TypeContainer Types {\r
-                       get {\r
-                               return root_types;\r
-                       }\r
-               }\r
-\r
-               public Hashtable Interfaces {\r
-                       get {\r
-                               return ifaces;\r
-                       }\r
-               }\r
-\r
-               public Hashtable Classes {\r
-                       get {\r
-                               return classes;\r
-                       }\r
-               }\r
-\r
-               public Hashtable Structs {\r
-                       get {\r
-                               return structs;\r
-                       }\r
-               }\r
-\r
-               public Hashtable Namespaces {\r
-                       get {\r
-                               return namespaces;\r
-                       }\r
-               }\r
-\r
-               public Hashtable Enums {\r
-                       get {\r
-                               return enums;\r
-                       }\r
-               }\r
-       }\r
-}\r
+//
+// tree.cs: keeps a tree representation of the generated code
+//
+// Author: Miguel de Icaza (miguel@gnu.org)
+//
+// Licensed under the terms of the GNU GPL
+//
+// (C) 2001 Ximian, Inc (http://www.ximian.com)
+//
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.IO;
+
+namespace Mono.MonoBASIC
+{
+
+       public interface ITreeDump {
+               int  Dump (Tree tree, StreamWriter output);
+               void ParseOptions (string options);
+       }
+
+       // <summary>
+       //   
+       //   We store here all the toplevel types that we have parsed,
+       //   this is the root of all information we have parsed.
+       // 
+       // </summary>
+       
+       public class Tree {
+               TypeContainer root_types;
+
+               // <summary>
+               //  Keeps track of namespaces defined in the source code
+               // </summary>
+               Hashtable namespaces;
+
+               // <summary>
+               //   Keeps track of all the types definied (classes, structs, ifaces, enums)
+               // </summary>
+               Hashtable decls;
+               
+               public Tree ()
+               {
+                       root_types = new TypeContainer (null, "", new Location (-1, 0));
+
+                       decls = new Hashtable ();
+                       namespaces = new Hashtable ();
+               }
+
+               public void RecordDecl (string name, DeclSpace ds)
+               {
+                       if (decls.Contains (name)){
+                               Report.Error (
+                                       101, ds.Location,
+                                       "There is already a definition for `" + name + "'");
+                               DeclSpace other = (DeclSpace) decls [name];
+                               Report.Error (0,
+                                       other.Location, "(Location of symbol related to previous error)");
+                               return;
+                       }
+                       decls.Add (name, ds);
+               }
+               
+               public Namespace RecordNamespace (Namespace parent, string file, string name)
+               {
+                       Namespace ns = new Namespace (parent, name);
+
+                       if (namespaces.Contains (file)){
+                               Hashtable ns_ns = (Hashtable) namespaces [file];
+
+                               if (ns_ns.Contains (ns.Name))
+                                       return (Namespace) ns_ns [ns.Name];
+                               ns_ns.Add (ns.Name, ns);
+                       } else {
+                               Hashtable new_table = new Hashtable ();
+                               namespaces [file] = new_table;
+
+                               new_table.Add (ns.Name, ns);
+                       }
+
+                       return ns;
+               }
+
+               //
+               // FIXME: Why are we using Types?
+               //
+                public TypeContainer Types {
+                        get {
+                                return root_types;
+                        }
+                }
+
+               public Hashtable Decls {
+                       get {
+                               return decls;
+                       }
+               }
+
+               public Hashtable Namespaces {
+                       get {
+                               return namespaces;
+                       }
+               }
+       }
+}