X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fgmcs%2Ftree.cs;h=e0453caf977b4ae6bd6d6b6b28de5dcf676e4424;hb=e7e6591153da6bdfefdd7f5e0a3ab2f4b06cfeac;hp=b03b7761093d7dfbe8f3dc62b956bb002bf24975;hpb=33d2fc699a7c72ed3816e40cedea573e95a14b31;p=mono.git diff --git a/mcs/gmcs/tree.cs b/mcs/gmcs/tree.cs old mode 100755 new mode 100644 index b03b7761093..e0453caf977 --- a/mcs/gmcs/tree.cs +++ b/mcs/gmcs/tree.cs @@ -33,11 +33,6 @@ namespace Mono.CSharp public class Tree { TypeContainer root_types; - // - // Keeps track of namespaces defined in the source code - // - Hashtable namespaces; - // // Keeps track of all the types definied (classes, structs, ifaces, enums) // @@ -45,68 +40,37 @@ namespace Mono.CSharp public Tree () { - root_types = new TypeContainer (); + root_types = new RootTypes (); decls = new Hashtable (); - namespaces = new Hashtable (); } - DoubleHash decl_ns_name = new DoubleHash (); - - public void RecordDecl (MemberName member_name, DeclSpace ds) + public void RecordDecl (Namespace ns, MemberName name, DeclSpace ds) { - string name = (string) member_name; - - 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)"); + DeclSpace other = (DeclSpace) decls [name]; + if (other != null){ + Report.SymbolRelatedToPreviousError (other); + + 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); + 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); } - public NamespaceEntry RecordNamespace (NamespaceEntry parent, SourceFile file, string name, Location loc) - { - NamespaceEntry ns = new NamespaceEntry (parent, file, name, loc); - - if (namespaces.Contains (file)){ - Hashtable ns_ns = (Hashtable) namespaces [file]; - - if (ns_ns.Contains (ns.FullName)) - return (NamespaceEntry) ns_ns [ns.FullName]; - ns_ns.Add (ns.FullName, ns); - } else { - Hashtable new_table = new Hashtable (); - namespaces [file] = new_table; - - new_table.Add (ns.FullName, ns); - } - - return ns; - } - // // FIXME: Why are we using Types? // @@ -116,16 +80,35 @@ namespace Mono.CSharp } } - public Hashtable Decls { + public DeclSpace GetDecl (MemberName name) + { + return (DeclSpace) decls [name]; + } + + public Hashtable AllDecls { get { return decls; } } + } - public Hashtable Namespaces { - get { - return namespaces; - } + public class RootTypes : TypeContainer + { + public RootTypes () + : base (null, null, MemberName.Null, null, Kind.Root, Location.Null) + { + ec = new EmitContext (null, this, Location.Null, null, null, 0, false); } + + public override PendingImplementation GetPendingImplementations () + { + throw new InvalidOperationException (); + } + + public override bool IsClsComplianceRequired (DeclSpace ds) + { + return true; + } + } }