2005-07-06 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / gmcs / tree.cs
index 60394d45ef8eded5af2ece67ea4cab6310f43d05..e0453caf977b4ae6bd6d6b6b28de5dcf676e4424 100644 (file)
@@ -45,51 +45,30 @@ namespace Mono.CSharp
                        decls = new Hashtable ();
                }
 
-               DoubleHash decl_ns_name = new DoubleHash ();
-               
-               public void RecordDecl (string name, DeclSpace ds)
+               public void RecordDecl (Namespace ns, MemberName name, DeclSpace ds)
                {
                        DeclSpace other = (DeclSpace) decls [name];
                        if (other != null){
+                               Report.SymbolRelatedToPreviousError (other);
+
                                PartialContainer other_pc = other as PartialContainer;
-                               if ((ds is TypeContainer) && (other_pc != null)) {
+                               if (ds is TypeContainer && other_pc != null)
                                        Report.Error (
                                                260, ds.Location, "Missing partial modifier " +
-                                               "on declaration of type `{0}'; another " +
+                                               "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 + "'");
+                               else
+                                       Report.Error (
+                                               101, ds.Location,
+                                               "There is already a definition for '{0}'", name);
                                return;
                        }
 
-                       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 DeclSpace LookupByNamespace (string ns, string name)
-               {
-                       object res;
-                       
-                       decl_ns_name.Lookup (ns, name, out res);
-                       return (DeclSpace) res;
+                       if (ds.Parent == Types)
+                               ns.DefineName (name.Basename, ds);
                }
                
                //
@@ -101,7 +80,12 @@ namespace Mono.CSharp
                         }
                 }
 
-               public Hashtable Decls {
+               public DeclSpace GetDecl (MemberName name)
+               {
+                       return (DeclSpace) decls [name];
+               }
+
+               public Hashtable AllDecls {
                        get {
                                return decls;
                        }
@@ -116,14 +100,15 @@ namespace Mono.CSharp
                        ec = new EmitContext (null, this, Location.Null, null, null, 0, false);
                }
 
-               public override void Register ()
+               public override PendingImplementation GetPendingImplementations ()
                {
                        throw new InvalidOperationException ();
-                       }
+               }
 
-               public override PendingImplementation GetPendingImplementations ()
+               public override bool IsClsComplianceRequired (DeclSpace ds)
                {
-                       throw new InvalidOperationException ();
+                       return true;
                }
+
        }
 }