X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fgmcs%2Freport.cs;h=2cef8ad9491902a6675c93288a2f8f71ee5fb9b6;hb=2a23b6fa7ec1091a65cca42d38b8e1bc260d3a01;hp=9a802c4c34bd2c0bbf85caa2f39424a73d57a438;hpb=17e8983b93d7fb48b2c2cbe4359cb92d7b84cd30;p=mono.git diff --git a/mcs/gmcs/report.cs b/mcs/gmcs/report.cs index 9a802c4c34b..2cef8ad9491 100644 --- a/mcs/gmcs/report.cs +++ b/mcs/gmcs/report.cs @@ -10,6 +10,7 @@ // FIXME: currently our class library does not support custom number format strings // using System; +using System.IO; using System.Text; using System.Collections; using System.Collections.Specialized; @@ -47,6 +48,8 @@ namespace Mono.CSharp { /// Whether to dump a stack trace on errors. /// static public bool Stacktrace; + + static public TextWriter Stderr = Console.Error; // // If the 'expected' error code is reported then the @@ -59,7 +62,7 @@ namespace Mono.CSharp { // // Keeps track of the warnings that we are ignoring // - static Hashtable warning_ignore_table; + public static Hashtable warning_ignore_table; static Hashtable warning_regions_table; @@ -68,6 +71,14 @@ namespace Mono.CSharp { /// static StringCollection extra_information = new StringCollection (); + public static void Reset () + { + Errors = Warnings = 0; + WarningsAreErrors = false; + warning_ignore_table = null; + warning_regions_table = null; + } + abstract class AbstractMessage { static void Check (int code) @@ -92,10 +103,10 @@ namespace Mono.CSharp { msg.Append (' '); } msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text); - Console.Error.WriteLine (msg.ToString ()); + Stderr.WriteLine (msg.ToString ()); foreach (string s in extra_information) - Console.Error.WriteLine (s + MessageType); + Stderr.WriteLine (s + MessageType); extra_information.Clear (); @@ -112,15 +123,15 @@ namespace Mono.CSharp { public virtual void Print (int code, Location location, string text) { - if (location.Equals (Location.Null)) { + if (location.IsNull) { Print (code, "", text); return; } - Print (code, String.Format ("{0}({1})", location.Name, location.Row), text); + Print (code, location.ToString (), text); } } - sealed class WarningMessage: AbstractMessage { + sealed class WarningMessage : AbstractMessage { Location loc = Location.Null; readonly int Level; @@ -186,7 +197,7 @@ namespace Mono.CSharp { } } - sealed class ErrorMessage: AbstractMessage { + sealed class ErrorMessage : AbstractMessage { public override void Print(int code, string location, string text) { @@ -208,7 +219,7 @@ namespace Mono.CSharp { public static void FeatureIsNotStandardized (Location loc, string feature) { - Report.Error (1644, loc, "Feature '{0}' cannot be used because it is not part of the standardized ISO C# language specification", feature); + Report.Error (1644, loc, "Feature `{0}' cannot be used because it is not part of the standardized ISO C# language specification", feature); } public static string FriendlyStackTrace (Exception e) @@ -252,6 +263,11 @@ namespace Mono.CSharp { return sb.ToString (); } + public static void StackTrace () + { + Console.WriteLine (FriendlyStackTrace (new StackTrace (true))); + } + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // IF YOU ADD A NEW WARNING YOU HAVE TO DUPLICATE ITS ID HERE // @@ -259,7 +275,7 @@ namespace Mono.CSharp { { int[] all_warnings = new int[] { 28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649, - 659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028 + 659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028, 3005 }; foreach (int i in all_warnings) { @@ -271,12 +287,12 @@ namespace Mono.CSharp { static public void LocationOfPreviousError (Location loc) { - Console.Error.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row)); + Stderr.WriteLine (String.Format ("{0} (Location of symbol related to previous error)", loc)); } static public void RuntimeMissingSupport (Location loc, string feature) { - Report.Error (-88, loc, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature); + Report.Error (-88, loc, "Your .NET Runtime does not support `{0}'. Please use the latest Mono runtime instead.", feature); } /// @@ -285,7 +301,7 @@ namespace Mono.CSharp { /// static public void SymbolRelatedToPreviousError (Location loc, string symbol) { - SymbolRelatedToPreviousError (String.Format ("{0}({1})", loc.Name, loc.Row), symbol); + SymbolRelatedToPreviousError (loc.ToString (), symbol); } static public void SymbolRelatedToPreviousError (MemberInfo mi) @@ -299,12 +315,11 @@ namespace Mono.CSharp { while (mb.Mono_IsInflatedMethod) mb = mb.GetGenericMethodDefinition (); IMethodData md = TypeManager.GetMethod (mb); - SymbolRelatedToPreviousError (md.Location, md.GetSignatureForError (temp_ds)); + SymbolRelatedToPreviousError (md.Location, md.GetSignatureForError ()); return; } - string name = String.Concat (temp_ds.Name, ".", mi.Name); - MemberCore mc = temp_ds.GetDefinition (name); + MemberCore mc = temp_ds.GetDefinition (mi.Name); SymbolRelatedToPreviousError (mc); } } @@ -316,6 +331,8 @@ namespace Mono.CSharp { static public void SymbolRelatedToPreviousError (Type type) { + if (type.IsGenericInstance) + type = type.GetGenericTypeDefinition (); if (type is TypeBuilder) { DeclSpace temp_ds = TypeManager.LookupDeclSpace (type); SymbolRelatedToPreviousError (temp_ds.Location, TypeManager.CSharpName (type)); @@ -328,12 +345,12 @@ namespace Mono.CSharp { static void SymbolRelatedToPreviousError (string loc, string symbol) { - extra_information.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol)); + extra_information.Add (String.Format ("{0}: `{1}', name of symbol related to previous ", loc, symbol)); } public static void ExtraInformation (Location loc, string msg) { - extra_information.Add (String.Format ("{0}({1}) {2}", loc.Name, loc.Row, msg)); + extra_information.Add (String.Format ("{0} {1}", loc, msg)); } public static WarningRegions RegisterWarningRegion (Location location) @@ -381,8 +398,12 @@ namespace Mono.CSharp { static public void Error (int code, Location loc, string format, params object[] args) { - ErrorMessage e = new ErrorMessage (); - e.Print (code, loc, String.Format (format, args)); + Error (code, loc, String.Format (format, args)); + } + + static public void Error (int code, Location loc, string error) + { + new ErrorMessage ().Print (code, loc, error); } static public void SetIgnoreWarning (int code) @@ -575,7 +596,7 @@ namespace Mono.CSharp { public abstract bool IsEnabled (int code, bool previous); } - class Disable: PragmaCmd + class Disable : PragmaCmd { int code; public Disable (int line, int code) @@ -590,7 +611,7 @@ namespace Mono.CSharp { } } - class DisableAll: PragmaCmd + class DisableAll : PragmaCmd { public DisableAll (int line) : base (line) {} @@ -601,7 +622,7 @@ namespace Mono.CSharp { } } - class Enable: PragmaCmd + class Enable : PragmaCmd { int code; public Enable (int line, int code) @@ -616,7 +637,7 @@ namespace Mono.CSharp { } } - class EnableAll: PragmaCmd + class EnableAll : PragmaCmd { public EnableAll (int line) : base (line) {} @@ -669,7 +690,7 @@ namespace Mono.CSharp { if (Report.IsValidWarning (code)) return true; - Report.Warning (1691, 1, loc, "'{0}' is not a valid warning number", code); + Report.Warning (1691, 1, loc, "`{0}' is not a valid warning number", code); return false; } }