Fix name of MIT license in LICENSE file (#19601)
[mono-project.git] / mcs / ilasm / Report.cs
blobc53763a6c8b6707684ae33849cb519a8dc07ed56
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 bool quiet;
20 /* Current file being processed */
21 private static string file_path;
23 static Report ()
25 error_count = 0;
26 quiet = false;
29 public static int ErrorCount {
30 get { return error_count; }
33 public static bool Quiet {
34 get { return quiet; }
35 set { quiet = value; }
38 public static string FilePath {
39 get { return file_path; }
40 set { file_path = value; }
43 public static void AssembleFile (string file, string listing,
44 string target, string output)
46 if (quiet)
47 return;
48 Console.WriteLine ("Assembling '{0}' , {1}, to {2} --> '{3}'", file,
49 GetListing (listing), target, output);
50 Console.WriteLine ();
53 public static void Error (string message)
55 Error (null, message);
58 public static void Error (Location location, string message)
60 error_count++;
61 throw new ILAsmException (file_path, location, message);
64 public static void Warning (string message)
66 Warning (null, message);
69 public static void Warning (Location location, string message)
71 string location_str = " : ";
72 if (location != null)
73 location_str = " (" + location.line + ", " + location.column + ") : ";
75 Console.Error.WriteLine (String.Format ("{0}{1}Warning -- {2}",
76 (file_path != null ? file_path : ""), location_str, message));
79 public static void Message (string message)
81 if (quiet)
82 return;
83 Console.WriteLine (message);
86 private static string GetListing (string listing)
88 if (listing == null)
89 return "no listing file";
90 return listing;
95 public class ILAsmException : Exception {
97 string message;
98 string file_path;
99 Location location;
101 public ILAsmException (string file_path, Location location, string message)
103 this.file_path = file_path;
104 this.location = location;
105 this.message = message;
108 public ILAsmException (Location location, string message)
109 : this (null, location, message)
113 public ILAsmException (string message)
114 : this (null, null, message)
118 public override string Message {
119 get { return message; }
122 public Location Location {
123 get { return location; }
124 set { location = value; }
127 public string FilePath {
128 get { return file_path; }
129 set { file_path = value; }
132 public override string ToString ()
134 string location_str = " : ";
135 if (location != null)
136 location_str = " (" + location.line + ", " + location.column + ") : ";
138 return String.Format ("{0}{1}Error : {2}",
139 (file_path != null ? file_path : ""), location_str, message);
144 public class InternalErrorException : Exception {
145 public InternalErrorException ()
146 : base ("Internal error")
150 public InternalErrorException (string message)
151 : base (message)