📄 report.cs
字号:
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}", loc, msg)); } public static WarningRegions RegisterWarningRegion (Location location) { if (warning_regions_table == null) warning_regions_table = new Hashtable (); WarningRegions regions = (WarningRegions)warning_regions_table [location.Name]; if (regions == null) { regions = new WarningRegions (); warning_regions_table.Add (location.Name, regions); } return regions; } static public void Warning (int code, int level, Location loc, string format, params object[] args) { WarningMessage w = new WarningMessage (level); w.Print (code, loc, String.Format (format, args)); } static public void Warning (int code, Location loc, string format, params object[] args) { WarningMessage w = new WarningMessage (); w.Print (code, loc, String.Format (format, args)); } static public void Warning (int code, string format, params object[] args) { Warning (code, Location.Null, String.Format (format, args)); } /// <summary> /// Did you test your WarningLevel, that you use this method /// </summary> static public void Warning (int code, string text) { Warning (code, Location.Null, text); } static public void Error (int code, string format, params object[] args) { Error (code, Location.Null, String.Format (format, args)); } static public void Error (int code, Location loc, string format, params object[] 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) { if (warning_ignore_table == null) warning_ignore_table = new Hashtable (); warning_ignore_table [code] = true; } static public int ExpectedError { set { expected_error = value; } get { return expected_error; } } public static int DebugFlags = 0; [Conditional ("MCS_DEBUG")] static public void Debug (string message, params object[] args) { Debug (4, message, args); } [Conditional ("MCS_DEBUG")] static public void Debug (int category, string message, params object[] args) { if ((category & DebugFlags) == 0) return; StringBuilder sb = new StringBuilder (message); if ((args != null) && (args.Length > 0)) { sb.Append (": "); bool first = true; foreach (object arg in args) { if (first) first = false; else sb.Append (", "); if (arg == null) sb.Append ("null"); else if (arg is ICollection) sb.Append (PrintCollection ((ICollection) arg)); else sb.Append (arg); } } Console.WriteLine (sb.ToString ()); } static public string PrintCollection (ICollection collection) { StringBuilder sb = new StringBuilder (); sb.Append (collection.GetType ()); sb.Append ("("); bool first = true; foreach (object o in collection) { if (first) first = false; else sb.Append (", "); sb.Append (o); } sb.Append (")"); return sb.ToString (); } } public enum TimerType { FindMembers = 0, TcFindMembers = 1, MemberLookup = 2, CachedLookup = 3, CacheInit = 4, MiscTimer = 5, CountTimers = 6 } public enum CounterType { FindMembers = 0, MemberCache = 1, MiscCounter = 2, CountCounters = 3 } public class Timer { static DateTime[] timer_start; static TimeSpan[] timers; static long[] timer_counters; static long[] counters; static Timer () { timer_start = new DateTime [(int) TimerType.CountTimers]; timers = new TimeSpan [(int) TimerType.CountTimers]; timer_counters = new long [(int) TimerType.CountTimers]; counters = new long [(int) CounterType.CountCounters]; for (int i = 0; i < (int) TimerType.CountTimers; i++) { timer_start [i] = DateTime.Now; timers [i] = TimeSpan.Zero; } } [Conditional("TIMER")] static public void IncrementCounter (CounterType which) { ++counters [(int) which]; } [Conditional("TIMER")] static public void StartTimer (TimerType which) { timer_start [(int) which] = DateTime.Now; } [Conditional("TIMER")] static public void StopTimer (TimerType which) { timers [(int) which] += DateTime.Now - timer_start [(int) which]; ++timer_counters [(int) which]; } [Conditional("TIMER")] static public void ShowTimers () { ShowTimer (TimerType.FindMembers, "- FindMembers timer"); ShowTimer (TimerType.TcFindMembers, "- TypeContainer.FindMembers timer"); ShowTimer (TimerType.MemberLookup, "- MemberLookup timer"); ShowTimer (TimerType.CachedLookup, "- CachedLookup timer"); ShowTimer (TimerType.CacheInit, "- Cache init"); ShowTimer (TimerType.MiscTimer, "- Misc timer"); ShowCounter (CounterType.FindMembers, "- Find members"); ShowCounter (CounterType.MemberCache, "- Member cache"); ShowCounter (CounterType.MiscCounter, "- Misc counter"); } static public void ShowCounter (CounterType which, string msg) { Console.WriteLine ("{0} {1}", counters [(int) which], msg); } static public void ShowTimer (TimerType which, string msg) { Console.WriteLine ( "[{0:00}:{1:000}] {2} (used {3} times)", (int) timers [(int) which].TotalSeconds, timers [(int) which].Milliseconds, msg, timer_counters [(int) which]); } } public class InternalErrorException : Exception { public InternalErrorException () : base ("Internal error") { } public InternalErrorException (string message) : base (message) { } } /// <summary> /// Handles #pragma warning /// </summary> public class WarningRegions { abstract class PragmaCmd { public int Line; protected PragmaCmd (int line) { Line = line; } public abstract bool IsEnabled (int code, bool previous); } class Disable : PragmaCmd { int code; public Disable (int line, int code) : base (line) { this.code = code; } public override bool IsEnabled (int code, bool previous) { return this.code == code ? false : previous; } } class DisableAll : PragmaCmd { public DisableAll (int line) : base (line) {} public override bool IsEnabled(int code, bool previous) { return false; } } class Enable : PragmaCmd { int code; public Enable (int line, int code) : base (line) { this.code = code; } public override bool IsEnabled(int code, bool previous) { return this.code == code ? true : previous; } } class EnableAll : PragmaCmd { public EnableAll (int line) : base (line) {} public override bool IsEnabled(int code, bool previous) { return true; } } ArrayList regions = new ArrayList (); public void WarningDisable (int line) { regions.Add (new DisableAll (line)); } public void WarningDisable (Location location, int code) { if (CheckWarningCode (code, location)) regions.Add (new Disable (location.Row, code)); } public void WarningEnable (int line) { regions.Add (new EnableAll (line)); } public void WarningEnable (Location location, int code) { if (CheckWarningCode (code, location)) regions.Add (new Enable (location.Row, code)); } public bool IsWarningEnabled (int code, int src_line) { bool result = true; foreach (PragmaCmd pragma in regions) { if (src_line < pragma.Line) break; result = pragma.IsEnabled (code, result); } return result; } bool CheckWarningCode (int code, Location loc) { if (Report.IsValidWarning (code)) return true; Report.Warning (1691, 1, loc, "`{0}' is not a valid warning number", code); return false; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -