using System.Reflection.Emit;
using System.IO;
-namespace CIR
+namespace Mono.CSharp
{
public interface ITreeDump {
TypeContainer root_types;
// <summary>
- // Keeps track of the interfaces defined in the source code
+ // Keeps track of all the types definied (classes, structs, ifaces, enums)
// </summary>
- Hashtable ifaces;
-
- // <summary>
- // Keeps track of the structs defined in the source code
- // </summary>
- Hashtable structs;
-
- // <summary>
- // Keeps track of the classes defined in the source code
- // </summary>
- Hashtable classes;
-
- // <summary>
- // Keeps track of namespaces defined in the source code
- // </summary>
- Hashtable namespaces;
-
- RootContext rc;
+ Hashtable decls;
- public Tree (RootContext rc)
- {
- root_types = new TypeContainer (rc, null, "", new Location (-1));
- this.rc = rc;
- }
-
-
- public void RecordInterface (string name, Interface iface)
+ public Tree ()
{
- if (ifaces == null)
- ifaces = new Hashtable ();
+ root_types = new RootTypes ();
- ifaces.Add (name, iface);
+ decls = new Hashtable ();
}
-
- public void RecordStruct (string name, Struct s)
- {
- if (structs == null)
- structs = new Hashtable ();
- structs.Add (name, s);
- }
+ DoubleHash decl_ns_name = new DoubleHash ();
- public void RecordClass (string name, Class c)
+ public void RecordDecl (string name, DeclSpace ds)
{
- if (classes == null)
- classes = new Hashtable ();
+ DeclSpace other = (DeclSpace) decls [name];
+ if (other != null){
+ PartialContainer other_pc = other as PartialContainer;
+ if ((ds is TypeContainer) && (other_pc != null)) {
+ Report.Error (
+ 260, ds.Location, "Missing partial modifier " +
+ "on declaration of type `{0}'; another " +
+ "partial implementation of this type exists",
+ name);
+
+ Report.LocationOfPreviousError (other.Location);
+ return;
+ }
+
+ Report.SymbolRelatedToPreviousError (
+ other.Location, other.GetSignatureForError ());
+
+ Report.Error (
+ 101, ds.Location,
+ "There is already a definition for `" + name + "'");
+ return;
+ }
- classes.Add (name, c);
+ ds.RecordDecl ();
+
+ int p = name.LastIndexOf ('.');
+ if (p == -1)
+ decl_ns_name.Insert ("", name, ds);
+ else {
+ decl_ns_name.Insert (name.Substring (0, p), name.Substring (p+1), ds);
+ }
+
+ decls.Add (name, ds);
}
- public Namespace RecordNamespace (Namespace parent, string name)
+ public DeclSpace LookupByNamespace (string ns, string name)
{
- if (namespaces == null)
- namespaces = new Hashtable ();
-
- if (namespaces.ContainsKey (name))
- return (Namespace) namespaces [name];
-
- Namespace ns = new Namespace (parent, name);
- namespaces.Add (ns.Name, ns);
- return ns;
+ object res;
+
+ decl_ns_name.Lookup (ns, name, out res);
+ return (DeclSpace) res;
}
- public TypeContainer Types {
+ //
+ // FIXME: Why are we using Types?
+ //
+ public TypeContainer Types {
+ get {
+ return root_types;
+ }
+ }
+
+ public Hashtable Decls {
get {
- return root_types;
+ return decls;
}
}
+ }
- public Hashtable Interfaces {
- get {
- return ifaces;
- }
+ public class RootTypes : TypeContainer
+ {
+ public RootTypes ()
+ : base (null, null, MemberName.Null, null, Kind.Root,
+ new Location (-1))
+ {
+ ec = new EmitContext (null, this, Location.Null, null, null, 0, false);
}
- public Hashtable Classes {
- get {
- return classes;
- }
+ public override void Register ()
+ {
+ throw new InvalidOperationException ();
}
- public Hashtable Structs {
- get {
- return structs;
- }
+ public override PendingImplementation GetPendingImplementations ()
+ {
+ throw new InvalidOperationException ();
}
- public Hashtable Namespaces {
- get {
- return namespaces;
- }
+ public override bool IsClsCompliaceRequired (DeclSpace ds)
+ {
+ return true;
}
+
}
}