Merge pull request #3279 from xmcclure/tarjan-crash-2
[mono-project.git] / mcs / ilasm / Report.cs
bloba7ebafe8afd6eca44c3de0af540220f57491c2a3
1 //
2 // Mono.ILASM.Report
3 //
4 // Author(s):
5 // Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
11 using System;
12 using System.IO;
14 namespace Mono.ILASM {
16 public abstract class Report {
18 private static int error_count;
19 private static int mark_count;
20 private static bool quiet;
21 /* Current file being processed */
22 private static string file_path;
24 static Report ()
26 error_count = 0;
27 quiet = false;
30 public static int ErrorCount {
31 get { return error_count; }
34 public static bool Quiet {
35 get { return quiet; }
36 set { quiet = value; }
39 public static string FilePath {
40 get { return file_path; }
41 set { file_path = value; }
44 public static void AssembleFile (string file, string listing,
45 string target, string output)
47 if (quiet)
48 return;
49 Console.WriteLine ("Assembling '{0}' , {1}, to {2} --> '{3}'", file,
50 GetListing (listing), target, output);
51 Console.WriteLine ();
54 public static void Error (string message)
56 Error (null, message);
59 public static void Error (Location location, string message)
61 error_count++;
62 throw new ILAsmException (file_path, location, message);
65 public static void Warning (string message)
67 Warning (null, message);
70 public static void Warning (Location location, string message)
72 string location_str = " : ";
73 if (location != null)
74 location_str = " (" + location.line + ", " + location.column + ") : ";
76 Console.Error.WriteLine (String.Format ("{0}{1}Warning -- {2}",
77 (file_path != null ? file_path : ""), location_str, message));
80 public static void Message (string message)
82 if (quiet)
83 return;
84 Console.WriteLine (message);
87 private static string GetListing (string listing)
89 if (listing == null)
90 return "no listing file";
91 return listing;
96 public class ILAsmException : Exception {
98 string message;
99 string file_path;
100 Location location;
102 public ILAsmException (string file_path, Location location, string message)
104 this.file_path = file_path;
105 this.location = location;
106 this.message = message;
109 public ILAsmException (Location location, string message)
110 : this (null, location, message)
114 public ILAsmException (string message)
115 : this (null, null, message)
119 public override string Message {
120 get { return message; }
123 public Location Location {
124 get { return location; }
125 set { location = value; }
128 public string FilePath {
129 get { return file_path; }
130 set { file_path = value; }
133 public override string ToString ()
135 string location_str = " : ";
136 if (location != null)
137 location_str = " (" + location.line + ", " + location.column + ") : ";
139 return String.Format ("{0}{1}Error : {2}",
140 (file_path != null ? file_path : ""), location_str, message);
145 public class InternalErrorException : Exception {
146 public InternalErrorException ()
147 : base ("Internal error")
151 public InternalErrorException (string message)
152 : base (message)