5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
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
;
29 public static int ErrorCount
{
30 get { return error_count; }
33 public static bool 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
)
48 Console
.WriteLine ("Assembling '{0}' , {1}, to {2} --> '{3}'", file
,
49 GetListing (listing
), target
, output
);
53 public static void Error (string message
)
55 Error (null, message
);
58 public static void Error (Location location
, string message
)
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
= " : ";
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
)
83 Console
.WriteLine (message
);
86 private static string GetListing (string listing
)
89 return "no listing file";
95 public class ILAsmException
: Exception
{
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
)