X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmbas%2Fnamespace.cs;h=6cb6b3c5908d75a183494d30509063a82bd91dbc;hb=15bd9360bc877ca0c1fc0f95e985a180976c0ee4;hp=0a3aeea93d08caec01a9c222c3ae5082ca631afe;hpb=b2dc44d3a95291a81d12e4ecdaa1bbb79975a220;p=mono.git diff --git a/mcs/mbas/namespace.cs b/mcs/mbas/namespace.cs index 0a3aeea93d0..6cb6b3c5908 100644 --- a/mcs/mbas/namespace.cs +++ b/mcs/mbas/namespace.cs @@ -20,31 +20,7 @@ namespace Mono.MonoBASIC { Namespace parent; string name; - Hashtable using_clauses; - Hashtable aliases; - - public bool DeclarationFound = false; - - // - // This class holds the location where a using definition is - // done, and whether it has been used by the program or not. - // - // We use this to flag using clauses for namespaces that do not - // exist. - // - public class UsingEntry { - public string Name; - public bool Used; - public Location Location; - - public UsingEntry (string name, Location loc) - { - Name = name; - Location = loc; - Used = false; - } - } - + /// /// Constructor Takes the current namespace and the /// name. This is bootstrapped with parent == null @@ -81,96 +57,13 @@ namespace Mono.MonoBASIC { return parent; } } - - /// - /// Records a new namespace for resolving name references - /// - public void Using (string ns, Location loc) - { - if (DeclarationFound){ - Report.Error (1529, loc, "A using clause must precede all other namespace elements"); - return; - } - - if (using_clauses == null) - using_clauses = new CaseInsensitiveHashtable (); - - UsingEntry ue = new UsingEntry (ns, loc); - using_clauses [ns] = ue; - } - - public ICollection UsingTable { - get { - return using_clauses.Values; - } - } - - public void UsingAlias (string alias, string namespace_or_type, Location loc) - { - if (aliases == null) - aliases = new CaseInsensitiveHashtable (); - - if (aliases.Contains (alias)){ - Report.Error (1537, loc, "The using alias `" + alias + - "' appeared previously in this namespace"); - return; - } - - aliases [alias] = namespace_or_type; - } - - public string LookupAlias (string alias) - { - string value = null; - - // System.Console.WriteLine ("Lookup " + alias + " in " + name); - - if (aliases != null) - value = (string) (aliases [alias]); - if (value == null && Parent != null) - value = Parent.LookupAlias (alias); - - return value; - } - + /// - /// Used to validate that all the using clauses are correct - /// after we are finished parsing all the files. + /// Show the qualified name of the namespace contained here /// - public static bool VerifyUsing () - { - ArrayList unused = new ArrayList (); - int errors = 0; - - foreach (Namespace ns in all_namespaces){ - foreach (UsingEntry ue in ns.UsingTable){ - if (ue.Used) - continue; - unused.Add (ue); - } - } - - // - // If we have unused using aliases, load all namespaces and check - // whether it is unused, or it was missing - // - if (unused.Count > 0){ - CaseInsensitiveHashtable namespaces = TypeManager.GetNamespaces (); - - foreach (UsingEntry ue in unused){ - if (namespaces.Contains (ue.Name)){ - Report.Warning (6024, ue.Location, "Unused namespace in `using' declaration"); - continue; - } - - errors++; - Report.Error (246, ue.Location, "The namespace `" + ue.Name + - "' can not be found (missing assembly reference?)"); - } - } - - return errors == 0; + public override string ToString() { + return Name; } - + } }