In ilasm/codegen:
authorAnkit Jain <radical@corewars.org>
Wed, 7 Jun 2006 10:10:39 +0000 (10:10 -0000)
committerAnkit Jain <radical@corewars.org>
Wed, 7 Jun 2006 10:10:39 +0000 (10:10 -0000)
* TypeDef.cs (TypeDef.AddFieldDef):
(TypeDef.Define): Use Report.Warning instead of Console.Error.WriteLine
(TypeDef.AddMethodDef): Likewise. Also, use methoddef.Location .
* ExternTable.cs (ExternTable.GetTypeRef): Likewise.
* MethodDef.cs (MethodDef.StartLocation): New.

In ilasm:

* Report.cs (Report.FilePath): New, static property.
(Report.Error): Remove overload with file_path param.
(Report.Warning): New.
* Driver.cs (DriverMain.Run): Set Report.FilePath .
(DriverMain.ProcessFile): Update use of Report.Error .

In ilasm/parser:

* ILParser.jay : Update to use Report.Warning instead of
Console.Error.WriteLine

svn path=/trunk/mcs/; revision=61521

mcs/ilasm/ChangeLog
mcs/ilasm/Driver.cs
mcs/ilasm/Report.cs
mcs/ilasm/codegen/ChangeLog
mcs/ilasm/codegen/ExternTable.cs
mcs/ilasm/codegen/MethodDef.cs
mcs/ilasm/codegen/TypeDef.cs
mcs/ilasm/parser/ChangeLog
mcs/ilasm/parser/ILParser.jay

index 5e7c15a5221f720d5baec92fe7645a2eb7f67cef..cc71dc8c2465782424763c0fb087eb75caccd056 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-07  Ankit Jain  <jankit@novell.com>
+
+       * Report.cs (Report.FilePath): New, static property.
+       (Report.Error): Remove overload with file_path param.
+       (Report.Warning): New.
+       * Driver.cs (DriverMain.Run): Set Report.FilePath .
+       (DriverMain.ProcessFile): Update use of Report.Error .
+       
+
 2006-05-26  Ankit Jain  <jankit@novell.com>
 
        * ilasm.exe.sources: Add Assembly.cs
index d57ba98fe11296e3355f103672593852ce5c8d82..eb5ee04410a28defe6249da57ae4c7317dc83b28 100644 (file)
@@ -68,8 +68,10 @@ namespace Mono.ILASM {
                                         output_file = CreateOutputFilename ();
                                 try {
                                         codegen = new CodeGen (output_file, target == Target.Dll, debugging_info);
-                                        foreach (string file_path in il_file_list)
+                                        foreach (string file_path in il_file_list) {
+                                                Report.FilePath = file_path;
                                                 ProcessFile (file_path);
+                                        }
                                         if (scan_only)
                                                 return true;
 
@@ -180,9 +182,9 @@ namespace Mono.ILASM {
                                         else
                                                 parser.yyparse (new ScannerAdapter (scanner),  null);
                                 } catch (ILTokenizingException ilte) {
-                                        Report.Error (file_path, ilte.Location, "syntax error at token '" + ilte.Token + "'");
+                                        Report.Error (ilte.Location, "syntax error at token '" + ilte.Token + "'");
                                 } catch (Mono.ILASM.yyParser.yyException ye) {
-                                        Report.Error (file_path, scanner.Reader.Location, ye.Message);
+                                        Report.Error (scanner.Reader.Location, ye.Message);
                                 } catch (ILAsmException ie) {
                                         ie.FilePath = file_path;
                                         ie.Location = scanner.Reader.Location;
index 1a9bce5976b13ef8e5e1c223c725de9a8a48ab31..dd2afd2ee27ff30c1a48c16f37c50334227f785e 100644 (file)
@@ -18,6 +18,8 @@ namespace Mono.ILASM {
                 private static int error_count;
                 private static int mark_count;
                 private static bool quiet;
+                /* Current file being processed */
+                private static string file_path;
 
                 static Report ()
                 {
@@ -34,6 +36,11 @@ namespace Mono.ILASM {
                        set { quiet = value; }
                }
 
+                public static string FilePath {
+                        get { return file_path; }
+                        set { file_path = value; }
+                }
+
                 public static void AssembleFile (string file, string listing,
                                           string target, string output)
                 {
@@ -44,18 +51,28 @@ namespace Mono.ILASM {
 
                 public static void Error (string message)
                 {
-                       Error (null, null, message);
+                        Error (null, message);
                 }
 
                 public static void Error (Location location, string message)
                 {
-                       Error (null, location, message);
+                        error_count++;
+                        throw new ILAsmException (file_path, location, message);
                 }
                 
-                public static void Error (string file_path, Location location, string message)
+                public static void Warning (string message)
                 {
-                        error_count++;
-                        throw new ILAsmException (file_path, location, message);
+                        Warning (null, message);
+                }
+
+                public static void Warning (Location location, string message)
+                {
+                        string location_str = " : ";
+                        if (location != null)
+                                location_str = " (" + location.line + ", " + location.column + ") : ";
+
+                        Console.Error.WriteLine (String.Format ("{0}{1}Warning -- {2}",
+                                (file_path != null ? file_path : ""), location_str, message));
                 }
 
                 public static void Message (string message)
@@ -113,7 +130,7 @@ namespace Mono.ILASM {
 
                 public override string ToString ()
                 {
-                        string location_str = "";
+                        string location_str = " : ";
                         if (location != null)
                                 location_str = " (" + location.line + ", " + location.column + ") : ";
 
index 52fe0ab71baa737af37a67b961e756f9dc988448..4fa5fc7bca9626462b6fbcd9f383fd70872e87a9 100644 (file)
@@ -1,3 +1,11 @@
+2006-06-07  Ankit Jain  <jankit@novell.com>
+
+       * TypeDef.cs (TypeDef.AddFieldDef):
+       (TypeDef.Define): Use Report.Warning instead of Console.Error.WriteLine
+       (TypeDef.AddMethodDef): Likewise. Also, use methoddef.Location .
+       * ExternTable.cs (ExternTable.GetTypeRef): Likewise.
+       * MethodDef.cs (MethodDef.StartLocation): New.
+
 2006-06-01  Ankit Jain  <jankit@novell.com>
 
        * MethodDef.cs (GetNamedParamPos): Return -1 if param_list is null.
index 69cb3c0eaa952aa85eed85405cf0efe77f71e6e0..037ecfada85d04521baabf5c74d462dce137c0a0 100644 (file)
@@ -323,7 +323,7 @@ namespace Mono.ILASM {
                         if (assembly_table == null && (asmb_name == "mscorlib" || asmb_name == "corlib")) {
                                 /* AddCorlib if mscorlib is being referenced but
                                    we haven't encountered a ".assembly 'name'" as yet. */
-                                Console.Error.WriteLine ("Warning -- Reference to undeclared extern assembly '{0}', adding.", asmb_name);
+                                Report.Warning (String.Format ("Reference to undeclared extern assembly '{0}', adding.", asmb_name));
                                 AddCorlib ();
                         }
                         if (assembly_table != null)
@@ -333,7 +333,7 @@ namespace Mono.ILASM {
                                 System.Reflection.AssemblyName asmname = new System.Reflection.AssemblyName ();
                                 asmname.Name = asmb_name;
 
-                                Console.Error.WriteLine ("Warning -- Reference to undeclared extern assembly '{0}', adding.", asmb_name);
+                                Report.Warning (String.Format ("Reference to undeclared extern assembly '{0}', adding.", asmb_name));
                                 ext_asmb = AddAssembly (asmb_name, asmname);
                         }
 
index 8f758df8a77193b50e176a59d264860af2740d1a..fc4714beb1c94fe10c402643059fdbb4406c5170 100644 (file)
@@ -47,6 +47,7 @@ namespace Mono.ILASM {
                private SourceMethod source;
                 private TypeDef type_def;
                 private GenericParameters gen_params;
+                private Location start;
 
                 public MethodDef (CodeGen codegen, PEAPI.MethAttr meth_attr,
                                  PEAPI.CallConv call_conv, PEAPI.ImplAttr impl_attr,
@@ -61,6 +62,7 @@ namespace Mono.ILASM {
                         this.type_def = type_def;
                         this.gen_params = gen_params;
                         this.ret_param = new ParamDef (PEAPI.ParamAttr.Default, "", ret_type);
+                        this.start = (Location) start.Clone ();
 
                         inst_list = new ArrayList ();
                         label_table = new Hashtable ();
@@ -127,6 +129,10 @@ namespace Mono.ILASM {
                         get { return (meth_attr & PEAPI.MethAttr.Abstract) != 0; }
                 }
 
+                public Location StartLocation {
+                        get { return start; }
+                }
+
                 public DeclSecurity DeclSecurity {
                         get {
                                 if (decl_sec == null)
index 34c52103c4500355da7f3f84392a14c8cefd5cb0..ea8a414262de318b275796a49b0edd7078bcda70 100644 (file)
@@ -45,6 +45,8 @@ namespace Mono.ILASM {
                 private bool is_value_class;
                 private bool is_enum_class;
 
+                private Location location;
+
                 public TypeDef (PEAPI.TypeAttr attr, string name_space, string name,
                                 BaseClassRef parent, ArrayList impl_list, Location location, GenericParameters gen_params, TypeDef outer)
                 {
@@ -53,6 +55,7 @@ namespace Mono.ILASM {
                         this.impl_list = impl_list;
                         this.gen_params = gen_params;
                         this.outer = outer;
+                        this.location = location;
 
                         field_table = new Hashtable ();
                         field_list = new ArrayList ();
@@ -179,7 +182,7 @@ namespace Mono.ILASM {
                 public void AddFieldDef (FieldDef fielddef)
                 {
                         if (IsInterface && !fielddef.IsStatic) {
-                                Console.WriteLine ("warning -- Non-static field in interface, set to such");
+                                Report.Warning ("Non-static field in interface, set to such");
                                 fielddef.Attributes |= PEAPI.FieldAttr.Static;
                         }
 
@@ -193,12 +196,12 @@ namespace Mono.ILASM {
                 public void AddMethodDef (MethodDef methoddef)
                 {
                         if (IsInterface && !(methoddef.IsVirtual || methoddef.IsAbstract)) {
-                                Console.WriteLine ("warning -- Non-virtual, non-abstract instance method in interface, set to such");
+                                Report.Warning (methoddef.StartLocation, "Non-virtual, non-abstract instance method in interface, set to such");
                                 methoddef.Attributes |= PEAPI.MethAttr.Abstract | PEAPI.MethAttr.Virtual;
                         }
 
                         if (method_table [methoddef.Signature] != null)
-                                Report.Error ("Duplicate method declaration: " + methoddef.Signature);
+                                Report.Error (methoddef.StartLocation, "Duplicate method declaration: " + methoddef.Signature);
 
                         method_table.Add (methoddef.Signature, methoddef);
                 }
@@ -316,7 +319,7 @@ namespace Mono.ILASM {
 
                                if (vis == PEAPI.TypeAttr.Private || vis == PEAPI.TypeAttr.Public) {
                                        /* Nested class, but attr not set accordingly. */
-                                       Console.WriteLine ("Warning -- Nested class '{0}' has non-nested visibility, set to such.", NestedFullName);
+                                       Report.Warning (location, String.Format ("Nested class '{0}' has non-nested visibility, set to such.", NestedFullName));
                                        attr = attr ^ vis;
                                        attr |= (vis == PEAPI.TypeAttr.Public ? PEAPI.TypeAttr.NestedPublic : PEAPI.TypeAttr.NestedPrivate);
                                }               
@@ -340,7 +343,7 @@ namespace Mono.ILASM {
                                 if (!IsValueType (name_space, name) && !IsEnumType (name_space, name) &&
                                         is_value_class && (attr & PEAPI.TypeAttr.Sealed) == 0) {
 
-                                        Console.WriteLine ("Warning -- Non-sealed value class, made sealed.");
+                                        Report.Warning (location, "Non-sealed value class, made sealed.");
                                         attr |= PEAPI.TypeAttr.Sealed;
                                 }
 
index 3987b9d7d09a29e1d44b7786303571496f86f1d7..470b98ef8b2c30380971e22ab3f6bf1d6fdc98a8 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-07  Ankit Jain  <jankit@novell.com>
+
+       * ILParser.jay : Update to use Report.Warning instead of
+       Console.Error.WriteLine
+
 2006-06-01  Ankit Jain  <jankit@novell.com>
 
        * ILParser.jay (instr | INSTR_PARAM ..): Report error if the param is not
index 27768ff51b39f4676b3d8376f226a7ab68e3e6f2..c7dc43180180b3a16381e1e401f5e52b5e0532bd 100644 (file)
@@ -60,7 +60,7 @@ namespace Mono.ILASM {
                         if ((action == System.Security.Permissions.SecurityAction.RequestMinimum || \r
                                 action == System.Security.Permissions.SecurityAction.RequestOptional || \r
                                 action == System.Security.Permissions.SecurityAction.RequestRefuse) && !for_assembly) {\r
-                                Console.Error.WriteLine (String.Format ("System.Security.Permissions.SecurityAction '{0}' is not valid for this declaration", action));\r
+                                Report.Warning (String.Format ("System.Security.Permissions.SecurityAction '{0}' is not valid for this declaration", action));\r
                                 return false;\r
                         }\r
 \r
@@ -2142,7 +2142,7 @@ method_decl               : D_EMITBYTE int32
                                 codegen.CurrentCustomAttrTarget = param;\r
 \r
                                 if (param == null) {\r
-                                        Console.Error.WriteLine ("{0} Warning -- invalid param index ({1}) with .param", tokenizer.Location, index);\r
+                                        Report.Warning (tokenizer.Location, String.Format ("invalid param index ({0}) with .param", index));\r
                                         break;\r
                                 }\r
                                 if ($5 != null)\r