+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
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;
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;
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 ()
{
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)
{
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)
public override string ToString ()
{
- string location_str = "";
+ string location_str = " : ";
if (location != null)
location_str = " (" + location.line + ", " + location.column + ") : ";
+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.
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)
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);
}
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,
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 ();
get { return (meth_attr & PEAPI.MethAttr.Abstract) != 0; }
}
+ public Location StartLocation {
+ get { return start; }
+ }
+
public DeclSecurity DeclSecurity {
get {
if (decl_sec == null)
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)
{
this.impl_list = impl_list;
this.gen_params = gen_params;
this.outer = outer;
+ this.location = location;
field_table = new Hashtable ();
field_list = new ArrayList ();
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;
}
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);
}
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);
}
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;
}
+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
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
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