2008-04-16 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Wed, 16 Apr 2008 14:03:32 +0000 (14:03 -0000)
committerMarek Safar <marek.safar@gmail.com>
Wed, 16 Apr 2008 14:03:32 +0000 (14:03 -0000)
* report.cs: ColorFormat is protected.

* rootcontext.cs: Unused fields clean-up.

* namespace.cs: Made UsingEntry name private.

svn path=/trunk/mcs/; revision=100871

mcs/mcs/ChangeLog
mcs/mcs/namespace.cs
mcs/mcs/report.cs
mcs/mcs/rootcontext.cs

index 1d752b85554c7f7a48d909d5d81bd04157d14403..53cb85ebe49ac37e54f4b69071d3e77c564a906a 100644 (file)
@@ -1,3 +1,11 @@
+2008-04-16  Marek Safar  <marek.safar@gmail.com>
+
+       * report.cs: ColorFormat is protected.
+       
+       * rootcontext.cs: Unused fields clean-up.
+       
+       * namespace.cs: Made UsingEntry name private.
+
 2008-04-16  Marek Safar  <marek.safar@gmail.com>
 
        * cs-tokenizer.cs, location.cs: Removed unused field.
index ea782cb11e2608dad8eb36e6f4d24fecdd3e916f..85f5036584805859576fb4bedd4caa684dfb8ac4 100644 (file)
@@ -574,29 +574,47 @@ namespace Mono.CSharp {
        public class NamespaceEntry : IResolveContext {
 
                class UsingEntry {
-                       public readonly MemberName Name;
+                       readonly MemberName name;
                        Namespace resolved;
                        
                        public UsingEntry (MemberName name)
                        {
-                               Name = name;
+                               this.name = name;
                        }
 
+                       public string GetSignatureForError ()
+                       {
+                               return name.GetSignatureForError ();
+                       }
+
+                       public string GetTypeName ()
+                       {
+                               return name.GetTypeName ();
+                       }
+
+                       public Location Location {
+                               get { return name.Location; }
+                       }
+                       
+                       public string Name {
+                               get { return name.FullName; }
+                       }                       
+
                        public Namespace Resolve (IResolveContext rc)
                        {
                                if (resolved != null)
                                        return resolved;
 
-                               FullNamedExpression fne = Name.GetTypeExpression ().ResolveAsTypeStep (rc, false);
+                               FullNamedExpression fne = name.GetTypeExpression ().ResolveAsTypeStep (rc, false);
                                if (fne == null)
                                        return null;
 
                                resolved = fne as Namespace;
                                if (resolved == null) {
                                        Report.SymbolRelatedToPreviousError (fne.Type);
-                                       Report.Error (138, Name.Location,
+                                       Report.Error (138, Location,
                                                "`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces",
-                                               Name.GetSignatureForError ());
+                                               GetSignatureForError ());
                                }
                                return resolved;
                        }
@@ -627,19 +645,20 @@ namespace Mono.CSharp {
 
                class LocalUsingAliasEntry : UsingAliasEntry {
                        Expression resolved;
+                       MemberName value;
 
                        public LocalUsingAliasEntry (string alias, MemberName name, Location loc)
                                : base (alias, loc)
                        {
-                               this.resolved = name.GetTypeExpression ();
+                               this.value = name;
                        }
 
                        public override FullNamedExpression Resolve (IResolveContext rc)
                        {
-                               if (resolved == null || resolved.Type != null)
+                               if (resolved != null)
                                        return (FullNamedExpression)resolved;
 
-                               resolved = resolved.ResolveAsTypeStep (rc, false);
+                               resolved = value.GetTypeExpression ().ResolveAsTypeStep (rc, false);
                                if (resolved == null)
                                        return null;
 
@@ -669,9 +688,10 @@ namespace Mono.CSharp {
                public bool DeclarationFound = false;
                // End
 
-               public readonly int ID;
                public readonly bool IsImplicit;
                public readonly DeclSpace SlaveDeclSpace;
+               static readonly Namespace [] empty_namespaces = new Namespace [0];
+               Namespace [] namespace_using_table;
 
                static ArrayList entries = new ArrayList ();
 
@@ -685,7 +705,6 @@ namespace Mono.CSharp {
                        this.parent = parent;
                        this.file = file;
                        entries.Add (this);
-                       this.ID = entries.Count;
 
                        if (parent != null)
                                ns = parent.NS.GetNamespace (name, true);
@@ -700,8 +719,6 @@ namespace Mono.CSharp {
                {
                        this.parent = parent;
                        this.file = file;
-                       // no need to add self to 'entries', since we don't have any aliases or using entries.
-                       this.ID = -1;
                        this.IsImplicit = true;
                        this.ns = ns;
                        this.SlaveDeclSpace = slave ? new RootDeclSpace (this) : null;
@@ -762,9 +779,9 @@ namespace Mono.CSharp {
                                using_clauses = new ArrayList ();
                        } else {
                                foreach (UsingEntry old_entry in using_clauses) {
-                                       if (name.Equals (old_entry.Name)) {
-                                               Report.SymbolRelatedToPreviousError (old_entry.Name.Location, old_entry.Name.GetSignatureForError ());
-                                               Report.Warning (105, 3, loc, "The using directive for `{0}' appeared previously in this namespace", name.GetName ());
+                                       if (name.FullName == old_entry.Name) {
+                                               Report.SymbolRelatedToPreviousError (old_entry.Location, old_entry.GetSignatureForError ());
+                                               Report.Warning (105, 3, loc, "The using directive for `{0}' appeared previously in this namespace", name.GetSignatureForError ());
                                                return;
                                        }
                                }
@@ -938,9 +955,6 @@ namespace Mono.CSharp {
                        return fne;
                }
 
-               // Our cached computation.
-               static readonly Namespace [] empty_namespaces = new Namespace [0];
-               Namespace [] namespace_using_table;
                Namespace [] GetUsingTable ()
                {
                        if (namespace_using_table != null)
@@ -976,7 +990,7 @@ namespace Mono.CSharp {
                                        if (using_clauses != null) {
                                                using_list = new string [using_clauses.Count];
                                                for (int i = 0; i < using_clauses.Count; i++)
-                                                       using_list [i] = ((UsingEntry) using_clauses [i]).Name.GetTypeName ();
+                                                       using_list [i] = ((UsingEntry) using_clauses [i]).GetTypeName ();
                                        }
 
                                        symfile_id = SymbolWriter.DefineNamespace (ns.Name, file.SourceFileEntry, using_list, parent_id);
index af0d5927f21367730a071d9040887315a1e2533a..2b28f7a061f696665b03b250f17b39ec9ebc529a 100644 (file)
@@ -358,7 +358,7 @@ namespace Mono.CSharp {
                                Check (code);
                        }
 
-                       public virtual string ColorFormat (string s)
+                       protected virtual string ColorFormat (string s)
                        {
                                return s;
                        }
@@ -537,7 +537,7 @@ namespace Mono.CSharp {
                        {
                        }
 
-                       public override string ColorFormat (string s)
+                       protected override string ColorFormat (string s)
                        {
                                if (prefix != null)
                                        return prefix + s + postfix;
index ce6a677fb17ba40c7a7b68e26b0bec87c2e0ef7c..0ac85e391bb567077e1d8a440fc4b8e72df76de8 100644 (file)
@@ -36,16 +36,39 @@ namespace Mono.CSharp {
        public class RootContext {
 
                //
-               // Contains the parsed tree
+               // COMPILER OPTIONS CLASS
                //
-               static RootTypes root;
+               public static Target Target;
+               public static string TargetExt;
+               public static bool VerifyClsCompliance = true;
+               public static bool Optimize = true;
+               public static LanguageVersion Version;
 
                //
-               // This hashtable contains all of the #definitions across the source code
-               // it is used by the ConditionalAttribute handler.
+               // We keep strongname related info here because
+               // it's also used as complier options from CSC 8.x
                //
-               public static Hashtable AllDefines = new Hashtable ();
-               
+               public static string StrongNameKeyFile;
+               public static string StrongNameKeyContainer;
+               public static bool StrongNameDelaySign;
+
+               //
+               // If set, enable XML documentation generation
+               //
+               public static Documentation Documentation;
+
+               static public string MainClass;
+
+               // 
+               // The default compiler checked state
+               //
+               static public bool Checked;
+
+               //
+               // Whether to allow Unsafe code
+               //
+               static public bool Unsafe;
+
                //
                // Whether we are being linked against the standard libraries.
                // This is only used to tell whether `System.Object' should
@@ -53,6 +76,25 @@ namespace Mono.CSharp {
                //
                public static bool StdLib;
 
+               public static bool NeedsEntryPoint {
+                       get { return Target == Target.Exe || Target == Target.WinExe; }
+               }
+
+               //
+               // COMPILER OPTIONS CLASS END
+               //
+
+               //
+               // Contains the parsed tree
+               //
+               static RootTypes root;
+
+               //
+               // This hashtable contains all of the #definitions across the source code
+               // it is used by the ConditionalAttribute handler.
+               //
+               public static Hashtable AllDefines = new Hashtable ();
+               
                //
                // This keeps track of the order in which classes were defined
                // so that we can poulate them in that order.
@@ -72,33 +114,6 @@ namespace Mono.CSharp {
                
                static TypeBuilder impl_details_class;
 
-               public static Target Target;
-               public static string TargetExt;
-
-               public static bool VerifyClsCompliance = true;
-
-               /// <summary>
-               /// Holds /optimize option
-               /// </summary>
-               public static bool Optimize = true;
-
-               public static LanguageVersion Version;
-
-               //
-               // We keep strongname related info here because
-               // it's also used as complier options from CSC 8.x
-               //
-               public static string StrongNameKeyFile;
-               public static string StrongNameKeyContainer;
-               public static bool StrongNameDelaySign;
-
-               //
-               // If set, enable XML documentation generation
-               //
-               public static Documentation Documentation;
-
-               static public string MainClass;
-
                //
                // Constructor
                //
@@ -128,10 +143,6 @@ namespace Mono.CSharp {
                        helper_classes = null;
                }
 
-               public static bool NeedsEntryPoint {
-                       get { return RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe; }
-               }
-
                static public RootTypes ToplevelTypes {
                        get { return root; }
                }
@@ -141,16 +152,6 @@ namespace Mono.CSharp {
                        type_container_resolve_order.Add (tc);
                }
                
-               // 
-               // The default compiler checked state
-               //
-               static public bool Checked;
-
-               //
-               // Whether to allow Unsafe code
-               //
-               static public bool Unsafe;
-               
                // <remarks>
                //   This function is used to resolve the hierarchy tree.
                //   It processes interfaces, structs and classes in that order.
@@ -292,16 +293,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               //
-               // A generic hook delegate
-               //
-               public delegate void Hook ();
-
-               //
-               // A hook invoked when the code has been generated.
-               //
-               public static event Hook EmitCodeHook;
-
                //
                // DefineTypes is used to fill in the members of each type.
                //
@@ -346,13 +337,6 @@ namespace Mono.CSharp {
                                foreach (Delegate d in root.Delegates)
                                        d.Emit ();
                        }                       
-                       //
-                       // Run any hooks after all the types have been defined.
-                       // This is used to create nested auxiliary classes for example
-                       //
-
-                       if (EmitCodeHook != null)
-                               EmitCodeHook ();
 
                        CodeGen.Assembly.Emit (root);
                        CodeGen.Module.Emit (root);