Author: ankit
Date: 2006-02-20 08:07:13 -0500 (Mon, 20 Feb 2006)
New Revision: 57066
Modified:
branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog
branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs
branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs
branches/mono-1-1-13/mcs/ilasm/ChangeLog
branches/mono-1-1-13/mcs/ilasm/Driver.cs
branches/mono-1-1-13/mcs/ilasm/Report.cs
branches/mono-1-1-13/mcs/ilasm/codegen/BaseGenericTypeRef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog
branches/mono-1-1-13/mcs/ilasm/codegen/ClassTable.cs
branches/mono-1-1-13/mcs/ilasm/codegen/CodeGen.cs
branches/mono-1-1-13/mcs/ilasm/codegen/EventDef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/ExternMethodRef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/ExternTable.cs
branches/mono-1-1-13/mcs/ilasm/codegen/FieldTable.cs
branches/mono-1-1-13/mcs/ilasm/codegen/GenericArguments.cs
branches/mono-1-1-13/mcs/ilasm/codegen/GenericParamRef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/GenericParameters.cs
branches/mono-1-1-13/mcs/ilasm/codegen/GenericTypeInst.cs
branches/mono-1-1-13/mcs/ilasm/codegen/LabelInfo.cs
branches/mono-1-1-13/mcs/ilasm/codegen/Local.cs
branches/mono-1-1-13/mcs/ilasm/codegen/Method.cs
branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/MethodRef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/MethodTable.cs
branches/mono-1-1-13/mcs/ilasm/codegen/Module.cs
branches/mono-1-1-13/mcs/ilasm/codegen/PrimitiveTypeRef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/PropertyDef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/SwitchInstr.cs
branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/TypeRef.cs
branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog
branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay
branches/mono-1-1-13/mcs/ilasm/scanner/ChangeLog
branches/mono-1-1-13/mcs/ilasm/scanner/ILTables.cs
branches/mono-1-1-13/mcs/ilasm/scanner/ILTokenizingException.cs
branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog
Log:
Backport r57063 & r57065.
In ilasm/tests:
* generics-al.i, test-29.il: Remove. These use invalid style of
specifying generic constraints.
In ilasm/codegen:
* *.cs: Update all .cs files to use Report.Error instead of directly
throwing an exception.
* CodeGen.cs (CodeGen.ctor): Remove 'report' param, and the related
field & property.
In ilasm:
* Report.cs (Report): Make all methods,fields static.
(Report.Error): Update to throw ILAsmException.
(ILAsmException): New.
(InternalErrorException): New. Derive from ILAsmException.
* Driver.cs (Driver.Run): Catch ILAsmException and PEFileException and
print error messages instead of dumping the stack trace, and delete the
output file if CodeGen.Write() fails.
Move the check for entrypoint from CodeGen.Write to here.
In ilasm/scanner:
* ILTable.cs (directives): Remove .constraint
* ILTokenizingException.cs (ILTokenizingException): Derive from
ILAsmException.
In ilasm/parser:
* ILParser.jay: Remove D_CONSTRAINT
* ILParser.jay: Update to use Report.Error instead of directly throwing
an exception.
In class/PEAPI:
* PEAPI.cs (PEFileException): Update error message.
* Metadata.cs: Update to throw PEFileException instead of Exception.
Modified: branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1,3 +1,8 @@
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * PEAPI.cs (PEFileException): Update error message.
+ * Metadata.cs: Update to throw PEFileException instead of Exception.
+
2006-02-19 Ankit Jain <[EMAIL PROTECTED]>
* Metadata.cs (Module): Implment IExternRef to allow reference to types
Modified: branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1016,11 +1016,11 @@
nameIx = md.AddToStringsHeap(mrName);
if (resourceBytes != null) {
if (rRef != null)
- throw new Exception("ERROR: Manifest
Resource has byte value and file reference");
+ throw new PEFileException ("Manifest
Resource has byte value and file reference");
fileOffset = md.AddResource(resourceBytes);
} else {
if (rRef == null)
- throw new Exception("ERROR: Manifest
Resource has no implementation or value");
+ throw new PEFileException ("Manifest
Resource has no implementation or value");
rRef.BuildTables (md);
}
@@ -2029,7 +2029,7 @@
internal sealed override void TypeSig(MemoryStream str)
{
if (index < 0)
- throw new Exception (String.Format ("Unresolved
{0} - {1}", (GenParamType) GetTypeIndex (), param_name));
+ throw new PEFileException (String.Format
("Unresolved {0} - {1}", (GenParamType) GetTypeIndex (), param_name));
str.WriteByte(typeIndex);
MetaData.CompressNum ((uint) index, str);
}
Modified: branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1197,7 +1197,7 @@
/// Error for invalid PE file
/// </summary>
public class PEFileException : System.Exception {
- public PEFileException(string msg) : base("Error in PE File: "
+ msg) { }
+ public PEFileException(string msg) : base(msg) { }
}
public class NotYetImplementedException : System.Exception {
Modified: branches/mono-1-1-13/mcs/ilasm/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/ChangeLog 2006-02-20 13:03:47 UTC (rev
57065)
+++ branches/mono-1-1-13/mcs/ilasm/ChangeLog 2006-02-20 13:07:13 UTC (rev
57066)
@@ -1,3 +1,14 @@
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * Report.cs (Report): Make all methods,fields static.
+ (Report.Error): Update to throw ILAsmException.
+ (ILAsmException): New.
+ (InternalErrorException): New. Derive from ILAsmException.
+ * Driver.cs (Driver.Run): Catch ILAsmException and PEFileException and
+ print error messages instead of dumping the stack trace, and delete the
+ output file if CodeGen.Write() fails.
+ Move the check for entrypoint from CodeGen.Write to here.
+
2006-01-19 Ankit Jain <[EMAIL PROTECTED]>
* ilasm.exe.sources: Add Module.cs to the build.
Modified: branches/mono-1-1-13/mcs/ilasm/Driver.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/Driver.cs 2006-02-20 13:03:47 UTC (rev
57065)
+++ branches/mono-1-1-13/mcs/ilasm/Driver.cs 2006-02-20 13:07:13 UTC (rev
57066)
@@ -31,11 +31,8 @@
System.Threading.Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.InvariantCulture;
DriverMain driver = new DriverMain (args);
- if (!driver.Run ()) {
- Console.WriteLine ();
- Console.WriteLine ("***** FAILURE
*****");
- return 1;
- }
+ if (!driver.Run ())
+ return 1;
Console.WriteLine ("Operation completed successfully");
return 0;
}
@@ -43,11 +40,9 @@
private class DriverMain {
private ArrayList il_file_list;
- private Report report;
private string output_file;
private Target target = Target.Exe;
private string target_string = "exe";
- private bool quiet = false;
private bool show_tokens = false;
private bool show_method_def = false;
private bool show_method_ref = false;
@@ -62,25 +57,41 @@
{
il_file_list = new ArrayList ();
ParseArgs (args);
- report = new Report (quiet);
}
public bool Run ()
{
- if (il_file_list.Count == 0)
- Usage ();
- if (output_file == null)
- output_file = CreateOutputFile
();
- codegen = new CodeGen (output_file,
target == Target.Dll, true, debugging_info, report);
+ if (il_file_list.Count == 0)
+ Usage ();
+ if (output_file == null)
+ output_file = CreateOutputFilename ();
+ try {
+ codegen = new CodeGen (output_file,
target == Target.Dll, true, debugging_info);
foreach (string file_path in
il_file_list)
ProcessFile (file_path);
if (scan_only)
return true;
- if (report.ErrorCount > 0)
+ if (Report.ErrorCount > 0)
return false;
- codegen.Write ();
+ if (target != Target.Dll &&
!codegen.HasEntryPoint)
+ Report.Error ("No entry point
found.");
+
+ try {
+ codegen.Write ();
+ } catch {
+ File.Delete (output_file);
+ throw;
+ }
+ } catch (ILAsmException e) {
+ Error (e.Message);
+ return false;
+ } catch (PEAPI.PEFileException pe) {
+ Error (pe.Message);
+ return false;
+ }
+
try {
if (keyname != null) {
Console.WriteLine ("Signing
assembly with the specified strongname keypair");
@@ -93,6 +104,12 @@
return true;
}
+ private void Error (string message)
+ {
+ Console.WriteLine ("Error : " + message +
"\n");
+ Console.WriteLine ("***** FAILURE *****\n");
+ }
+
private bool Sign (string filename)
{
// note: if the file cannot be signed (no
public key in it) then
@@ -123,7 +140,7 @@
file_path);
Environment.Exit (2);
}
- report.AssembleFile (file_path, null,
+ Report.AssembleFile (file_path, null,
target_string, output_file);
StreamReader reader = File.OpenText
(file_path);
ILTokenizer scanner = new ILTokenizer (reader);
@@ -152,8 +169,10 @@
else
parser.yyparse (new
ScannerAdapter (scanner), null);
} catch (ILTokenizingException ilte) {
- report.Error (file_path + "(" +
ilte.Location.line + ") : error : " +
+ Report.Error (file_path + "(" +
ilte.Location.line + ") : error : " +
"syntax error at token
'" + ilte.Token + "'.");
+ } catch (Mono.ILASM.yyParser.yyException) {
+ Report.Error ("Error at: " +
scanner.Reader.Location);
} catch {
Console.WriteLine ("Error at: " +
scanner.Reader.Location);
throw;
@@ -210,7 +229,7 @@
target_string = "dll";
break;
case "quiet":
- quiet = true;
+ Report.Quiet = true;
break;
case "debug":
case "deb":
@@ -289,7 +308,7 @@
/// <summary>
/// Get the first file name and makes it into an
output file name
/// </summary>
- private string CreateOutputFile ()
+ private string CreateOutputFilename ()
{
string file_name = (string)il_file_list[0];
int ext_index = file_name.LastIndexOf ('.');
Modified: branches/mono-1-1-13/mcs/ilasm/Report.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/Report.cs 2006-02-20 13:03:47 UTC (rev
57065)
+++ branches/mono-1-1-13/mcs/ilasm/Report.cs 2006-02-20 13:07:13 UTC (rev
57066)
@@ -13,28 +13,28 @@
namespace Mono.ILASM {
- public class Report {
+ public abstract class Report {
- private int error_count;
- private int mark_count;
- private bool quiet;
+ private static int error_count;
+ private static int mark_count;
+ private static bool quiet;
- public Report () : this (false)
+ static Report ()
{
-
+ error_count = 0;
+ quiet = false;
}
- public Report (bool quiet)
- {
- this.error_count = 0;
- this.quiet = quiet;
- }
-
- public int ErrorCount {
+ public static int ErrorCount {
get { return error_count; }
}
- public void AssembleFile (string file, string listing,
+ public static bool Quiet {
+ get { return quiet; }
+ set { quiet = value; }
+ }
+
+ public static void AssembleFile (string file, string listing,
string target, string output)
{
Console.WriteLine ("Assembling '{0}' , {1}, to {2} -->
'{3}'", file,
@@ -42,20 +42,20 @@
Console.WriteLine ();
}
- public void Error (string message)
+ public static void Error (string message)
{
error_count++;
- Console.WriteLine (message);
+ throw new ILAsmException (message);
}
- public void Message (string message)
+ public static void Message (string message)
{
if (quiet)
return;
Console.WriteLine (message);
}
- private string GetListing (string listing)
+ private static string GetListing (string listing)
{
if (listing == null)
return "no listing file";
@@ -64,5 +64,39 @@
}
+ public class ILAsmException : Exception {
+
+ string message;
+ Location location;
+
+ public ILAsmException (Location location, string message)
+ {
+ this.location = location;
+ this.message = message;
+ }
+
+ public ILAsmException (string message)
+ {
+ this.message = message;
+ }
+
+ public override string Message {
+ get { return message; }
+ }
+
+ }
+
+ public class InternalErrorException : Exception {
+ public InternalErrorException ()
+ : base ("Internal error")
+ {
+ }
+
+ public InternalErrorException (string message)
+ : base (message)
+ {
+ }
+ }
+
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/BaseGenericTypeRef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/BaseGenericTypeRef.cs
2006-02-20 13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/BaseGenericTypeRef.cs
2006-02-20 13:07:13 UTC (rev 57066)
@@ -27,12 +27,14 @@
public override GenericTypeInst GetGenericTypeInst
(GenericArguments gen_args)
{
- throw new Exception (String.Format ("Invalid attempt
to create '{0}''{1}'", FullName, gen_args.ToString ()));
+ Report.Error ("Invalid attempt to create '" + FullName
+ "''" + gen_args.ToString () + "'");
+ return null;
}
public override PEAPI.Type ResolveInstance (CodeGen code_gen,
GenericArguments gen_args)
{
- throw new Exception (String.Format ("Invalid attempt
to create '{0}''{1}'", FullName, gen_args.ToString ()));
+ Report.Error ("Invalid attempt to create '" + FullName
+ "''" + gen_args.ToString () + "'");
+ return null;
}
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1,3 +1,10 @@
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * *.cs: Update all .cs files to use Report.Error instead of directly
+ throwing an exception.
+ * CodeGen.cs (CodeGen.ctor): Remove 'report' param, and the related
+ field & property.
+
2006-02-19 Ankit Jain <[EMAIL PROTECTED]>
* ExternTable.cs (ExternTable.GetModuleTypeRef): 'module_table' can be
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/ClassTable.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/ClassTable.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/ClassTable.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -191,7 +191,7 @@
ClassTableItem table_item = (ClassTableItem)
dic_entry.Value;
if (table_item.CheckDefined ())
continue;
- throw new Exception (String.Format ("Type: {0}
is not defined.", dic_entry.Key));
+ Report.Error (String.Format ("Type: {0} is not
defined.", dic_entry.Key));
}
}
@@ -203,7 +203,7 @@
ClassTableItem item = table[full_name] as
ClassTableItem;
if ((item != null) && (item.Defined)) {
- throw new Exception (String.Format ("Class:
{0} defined in multiple locations.",
+ Report.Error (String.Format ("Class: {0}
defined in multiple locations.",
full_name));
}
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/CodeGen.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/CodeGen.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/CodeGen.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -25,7 +25,6 @@
private PEFile pefile;
private string assembly_name;
- private Report report;
private ExternAssembly current_assemblyref;
private ExternModule current_moduleref;
private string current_namespace;
@@ -75,12 +74,11 @@
private Module this_module;
public CodeGen (string output_file, bool is_dll, bool
is_assembly,
- bool debugging_info, Report report)
+ bool debugging_info)
{
this.output_file = output_file;
this.is_dll = is_dll;
this.is_assembly = is_assembly;
- this.report = report;
if (debugging_info)
symwriter = new SymbolWriter (CreateDebugFile
(output_file));
@@ -119,10 +117,6 @@
get { return pefile; }
}
- public Report Report {
- get { return report; }
- }
-
public SymbolWriter SymbolWriter {
get { return symwriter; }
}
@@ -171,7 +165,7 @@
set {
/* if (!value) error: unsetting entrypoint ? */
if (entry_point)
- throw new Exception ("Multiple
.entrypoint declarations.");
+ Report.Error ("Multiple .entrypoint
declarations.");
entry_point = value;
}
}
@@ -255,8 +249,7 @@
public void SetAssemblyName (string name)
{
if (assembly_name != null && assembly_name != name)
- //FIXME: Report error
- throw new Exception ("Multiple assembly
declarations");
+ Report.Error ("Multiple assembly
declarations");
assembly_name = name;
if (assembly_name != "mscorlib")
ExternTable.AddCorlib ();
@@ -495,9 +488,6 @@
FileStream out_stream = null;
try {
- if (!is_dll && !HasEntryPoint)
- throw new Exception ("No EntryPoint
found.");
-
if (ThisModule == null)
this_module = new Module
(Path.GetFileName (output_file));
@@ -558,8 +548,6 @@
Guid guid = pefile.GetThisModule
().Guid;
symwriter.Write (guid);
}
- } catch {
- throw;
} finally {
if (out_stream != null)
out_stream.Close ();
@@ -570,7 +558,7 @@
{
MethodDef methoddef = (MethodDef)
global_method_table[signature];
if (methoddef == null)
- throw new Exception (String.Format ("Unable to
resolve global method : {0}", signature));
+ Report.Error ("Unable to resolve global method
: " + signature);
return methoddef.Resolve (this);
}
@@ -588,7 +576,7 @@
{
FieldDef fielddef = (FieldDef) global_field_table[new
DictionaryEntry (name, type_name)];
if (fielddef == null)
- throw new Exception (String.Format ("Unable to
resolve global field : {0} {1}", type_name, name));
+ Report.Error (String.Format ("Unable to
resolve global field : {0} {1}", type_name, name));
return fielddef.Resolve (this);
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/EventDef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/EventDef.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/EventDef.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -70,7 +70,7 @@
{
PEAPI.MethodDef methoddef = method as PEAPI.MethodDef;
if (methoddef == null)
- throw new Exception (type + " method of event
" + name + " not found");
+ Report.Error (type + " method of event " +
name + " not found");
return methoddef;
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/ExternMethodRef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/ExternMethodRef.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/ExternMethodRef.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -95,7 +95,7 @@
write_name = name;
if (owner.IsArray)
- throw new NotImplementedException ("Vararg
methods on arrays are not supported yet.");
+ Report.Error ("Vararg methods on arrays are
not supported yet.");
owner.Resolve (code_gen);
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/ExternTable.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/ExternTable.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/ExternTable.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -341,7 +341,7 @@
mod = module_table [mod_name] as ExternModule;
if (mod == null)
- throw new Exception (String.Format ("Module
{0} not defined.", mod_name));
+ Report.Error ("Module " + mod_name + " not
defined.");
return mod.GetTypeRef (full_name, is_valuetype);
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/FieldTable.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/FieldTable.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/FieldTable.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -91,7 +91,7 @@
FieldTableItem table_item = (FieldTableItem)
dic_entry.Value;
if (table_item.Defined)
continue;
- throw new Exception (String.Format ("Field: {0}
is not defined.", dic_entry.Key));
+ Report.Error (String.Format ("Field: {0} is not
defined.", dic_entry.Key));
}
return true;
}
@@ -121,10 +121,8 @@
{
FieldTableItem item = table[signature] as
FieldTableItem;
- if ((item != null) && (item.Defined)) {
- throw new Exception (String.Format ("Field: {0}
defined in multiple locations.",
- signature));
- }
+ if ((item != null) && (item.Defined))
+ Report.Error ("Field: " + signature + " defined
in multiple locations.");
}
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/GenericArguments.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/GenericArguments.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/GenericArguments.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -36,7 +36,7 @@
public void Add (BaseTypeRef type)
{
if (type == null)
- throw new ArgumentException ("type");
+ throw new InternalErrorException ();
if (type_list == null)
type_list = new ArrayList ();
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/GenericParamRef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/GenericParamRef.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/GenericParamRef.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -45,7 +45,7 @@
public override void MakeValueClass ()
{
- throw new Exception ("Not supported");
+ throw new InternalErrorException ("Not supported");
}
public override BaseClassRef Clone ()
@@ -95,8 +95,7 @@
param.Index =
type_gen_params.GetGenericParamNum (param.Name);
if (param.Index < 0)
- /* TODO: Report error */
- throw new Exception (String.Format ("Invalid
{0}type parameter '{1}'",
+ Report.Error (String.Format ("Invalid {0}type
parameter '{1}'",
(param.Type ==
PEAPI.GenParamType.MVar ? "method " : ""),
param.Name));
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/GenericParameters.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/GenericParameters.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/GenericParameters.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -50,7 +50,7 @@
public void AddConstraint (BaseTypeRef constraint)
{
if (constraint == null)
- throw new ArgumentException ("constraint");
+ throw new InternalErrorException ();
if (constraintsList == null)
constraintsList = new ArrayList ();
@@ -140,7 +140,7 @@
public void Add (GenericParameter gen_param)
{
if (gen_param == null)
- throw new ArgumentException ("gen_param");
+ throw new InternalErrorException ();
if (param_list == null)
param_list = new ArrayList ();
@@ -152,8 +152,7 @@
public GenericParameter GetGenericParam (string id)
{
if (param_list == null)
- //FIXME: Report error
- throw new Exception (String.Format ("Invalid
type parameter '{0}'", id));
+ Report.Error ("Invalid type parameter '" + id +
"'");
foreach (GenericParameter param in param_list)
if (param.Id == id)
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/GenericTypeInst.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/GenericTypeInst.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/GenericTypeInst.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -36,7 +36,8 @@
: base ("", is_valuetypeinst, conv_list, sig_mod)
{
if (class_ref is GenericTypeInst)
- throw new ArgumentException (String.Format
("Cannot create nested GenericInst, '{0}' '{1}'", class_ref.FullName,
gen_args.ToString ()));
+ throw new InternalErrorException ("Cannot
create nested GenericInst, '" +
+ class_ref.FullName +
"' '" + gen_args.ToString () + "'");
this.class_ref = class_ref;
this.gen_args = gen_args;
@@ -91,7 +92,7 @@
protected override BaseMethodRef CreateMethodRef (BaseTypeRef
ret_type,
PEAPI.CallConv call_conv, string name, BaseTypeRef[]
param, int gen_param_count)
{
- throw new Exception ("Should not be called");
+ throw new InternalErrorException ("Should not be
called");
}
public override BaseMethodRef GetMethodRef (BaseTypeRef
ret_type, PEAPI.CallConv call_conv,
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/LabelInfo.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/LabelInfo.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/LabelInfo.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -48,7 +48,7 @@
if(other != null)
return Pos.CompareTo(other.Pos);
- throw new ArgumentException ("object is not a
LabelInfo");
+ throw new InternalErrorException ("object is not a
LabelInfo");
}
public override string ToString ()
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/Local.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/Local.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/Local.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -44,14 +44,14 @@
public PEAPI.Local GetPeapiLocal (CodeGen code_gen)
{
- int ec = code_gen.Report.ErrorCount;
+ int ec = Report.ErrorCount;
BaseGenericTypeRef gtr = type as BaseGenericTypeRef;
if (gtr == null)
type.Resolve (code_gen);
else
gtr.ResolveNoTypeSpec (code_gen);
- if (code_gen.Report.ErrorCount > ec)
+ if (Report.ErrorCount > ec)
return null;
return new PEAPI.Local (name, type.PeapiType);
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/Method.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/Method.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/Method.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -176,7 +176,7 @@
public void AddInstruction (InstrBase instr)
{
if (instr == null) {
- throw new System.ArgumentNullException
("instr", "<null> instruction");
+ throw new InternalErrorException ("<null>
instruction");
}
if (instructions == null) {
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -273,7 +273,7 @@
public void EntryPoint ()
{
if (!IsStatic)
- throw new Exception ("Non-static method as
entrypoint.");
+ Report.Error ("Non-static method as
entrypoint.");
entry_point = true;
}
@@ -298,8 +298,7 @@
gpar.Index = type_def.GetGenericParamNum
(gpar.Name);
if (gpar.Index < 0)
- /* TODO: Report error */
- throw new Exception (String.Format ("Invalid
{0}type parameter '{1}'",
+ Report.Error (String.Format ("Invalid {0}type
parameter '{1}'",
(gpar.Type ==
PEAPI.GenParamType.MVar ? "method " : ""),
gpar.Name));
}
@@ -389,7 +388,7 @@
public PEAPI.MethodRef GetVarargSig (PEAPI.Type[] opt)
{
if (!is_resolved)
- throw new Exception ("Methods must be resolved
before a vararg sig can be created.");
+ throw new InternalErrorException ("Methods
must be resolved before a vararg sig can be created.");
PEAPI.MethodRef methref = null;
StringBuilder sigbuilder = new StringBuilder ();
@@ -464,13 +463,13 @@
methoddef.DeclareEntryPoint ();
if (local_list.Count > 0) {
- int ec = code_gen.Report.ErrorCount;
+ int ec = Report.ErrorCount;
PEAPI.Local[] local_array = new
PEAPI.Local[local_list.Count];
foreach (Local local in local_list)
local_array[local.Slot] =
local.GetPeapiLocal (code_gen);
- if (code_gen.Report.ErrorCount > ec)
+ if (Report.ErrorCount > ec)
return;
if (zero_init)
@@ -523,7 +522,7 @@
foreach (LabelInfo label in labelref_table.Values) {
LabelInfo def = (LabelInfo)
label_table[label.Name];
if (def == null) {
- code_gen.Report.Error ("Undefined
Label: " + label);
+ Report.Error ("Undefined Label: " +
label);
return;
}
label.Label = def.Label;
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/MethodRef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/MethodRef.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/MethodRef.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -30,7 +30,7 @@
TypeDef owner_def =
code_gen.TypeManager[owner.FullName];
if (owner_def == null)
- throw new Exception (String.Format ("Reference
to undefined class '{0}'", owner.FullName));
+ Report.Error ("Reference to undefined class '"
+ owner.FullName + "'");
string write_name;
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/MethodTable.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/MethodTable.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/MethodTable.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -166,7 +166,7 @@
MethodTableItem table_item = (MethodTableItem)
dic_entry.Value;
if (table_item.Defined)
continue;
- throw new Exception (String.Format ("Method:
{0} is not defined.", dic_entry.Key));
+ Report.Error (String.Format ("Method: {0} is
not defined.", dic_entry.Key));
}
return true;
}
@@ -218,7 +218,7 @@
MethodTableItem item = table[signature] as
MethodTableItem;
if ((item != null) && (item.Defined)) {
- throw new Exception (String.Format ("Method:
{0} defined in multiple locations.",
+ Report.Error (String.Format ("Method: {0}
defined in multiple locations.",
signature));
}
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/Module.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/Module.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/Module.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -41,7 +41,7 @@
public override void Resolve (CodeGen code_gen)
{
- throw new Exception ("This should not get called");
+ throw new InternalErrorException ("This should not get
called");
}
public void Resolve (CodeGen code_gen, PEAPI.Module module)
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/PrimitiveTypeRef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/PrimitiveTypeRef.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/PrimitiveTypeRef.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -63,7 +63,7 @@
protected override BaseMethodRef CreateMethodRef (BaseTypeRef
ret_type,
PEAPI.CallConv call_conv, string name, BaseTypeRef[]
param, int gen_param_count)
{
- throw new Exception ("Should not be called");
+ throw new InternalErrorException ("Should not be
called");
}
public override BaseMethodRef GetMethodRef (BaseTypeRef
ret_type, PEAPI.CallConv call_conv,
@@ -83,7 +83,8 @@
protected override IFieldRef CreateFieldRef (BaseTypeRef
ret_type, string name)
{
- throw new Exception ("PrimitiveType's can't have
fields!");
+ Report.Error ("PrimitiveType's can't have fields!");
+ return null;
}
public BaseClassRef AsClassRef (CodeGen code_gen)
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/PropertyDef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/PropertyDef.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/PropertyDef.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -83,7 +83,7 @@
{
PEAPI.MethodDef methoddef = method as PEAPI.MethodDef;
if (methoddef == null)
- throw new Exception (type + " method of
property " + name + " not found");
+ Report.Error (type + " method of property " +
name + " not found");
return methoddef;
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/SwitchInstr.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/SwitchInstr.cs 2006-02-20
13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/SwitchInstr.cs 2006-02-20
13:07:13 UTC (rev 57066)
@@ -35,7 +35,7 @@
if (lab is string) {
label_array[count++] =
meth.GetLabelDef ((string) lab);
} else {
- throw new
NotImplementedException ("offsets in switch statements.");
+ throw new
InternalErrorException ("offsets in switch statements.");
}
}
} else {
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -177,7 +177,7 @@
DictionaryEntry entry = new DictionaryEntry
(fielddef.Name, fielddef.Type.FullName);
if (field_table [entry] != null)
- throw new Exception (String.Format ("Duplicate
field declaration: {0} {1}", fielddef.Type.FullName, fielddef.Name));
+ Report.Error ("Duplicate field declaration: "
+ fielddef.Type.FullName + " " + fielddef.Name);
field_table.Add (entry, fielddef);
field_list.Add (fielddef);
}
@@ -190,7 +190,7 @@
}
if (method_table [methoddef.Signature] != null)
- throw new Exception (String.Format ("Duplicate
method declaration: {0}", methoddef.Signature));
+ Report.Error ("Duplicate method declaration: "
+ methoddef.Signature);
method_table.Add (methoddef.Signature, methoddef);
}
@@ -198,7 +198,7 @@
public void BeginEventDef (EventDef event_def)
{
if (current_event != null)
- throw new Exception ("An event definition was
not closed.");
+ Report.Error ("An event definition was not
closed.");
current_event = event_def;
}
@@ -215,7 +215,7 @@
public void BeginPropertyDef (PropertyDef property_def)
{
if (current_property != null)
- throw new Exception ("A property definition
was not closed.");
+ Report.Error ("A property definition was not
closed.");
current_property = property_def;
}
@@ -306,7 +306,7 @@
if (is_intransit) {
// Circular definition
- throw new Exception ("Circular definition of
class: " + FullName);
+ Report.Error ("Circular definition of class: "
+ FullName);
}
if (outer != null) {
@@ -327,7 +327,7 @@
is_intransit = false;
if (parent.PeapiClass == null) {
- throw new Exception ("this type can
not be a base type: "
+ Report.Error ("this type can not be a
base type: "
+ parent);
}
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/TypeRef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/TypeRef.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/TypeRef.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -61,7 +61,7 @@
base_type = code_gen.TypeManager.GetPeapiType
(full_name);
if (base_type == null) {
- code_gen.Report.Error ("Reference to undefined
class '" +
+ Report.Error ("Reference to undefined class '"
+
FullName + "'");
return;
}
Modified: branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1,3 +1,12 @@
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILParser.jay: Remove D_CONSTRAINT
+
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILParser.jay: Update to use Report.Error instead of directly throwing
+ an exception.
+
2006-02-09 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay (bound | int32): Handle invalid -ve size.
Modified: branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -210,7 +210,6 @@
%token D_CLASS
%token D_COMTYPE
%token D_CONFIG
-%token D_CONSTRAINT
%token D_IMAGEBASE
%token D_CORFLAGS
%token D_CTOR
@@ -637,8 +636,7 @@
#if NET_2_0 || BOOTSTRAP_NET_2_0
$$ = $2;
#else
- Console.Error.WriteLine ("ERROR: Use ilasm2 for
generics support.");
- Environment.Exit (1);
+ Report.Error ("Use ilasm2 for generics
support.");
#endif
}
;
@@ -649,8 +647,7 @@
#if NET_2_0 || BOOTSTRAP_NET_2_0
$$ = $2;
#else
- Console.Error.WriteLine ("ERROR: Use ilasm2 for
generics support.");
- Environment.Exit (1);
+ Report.Error ("Use ilasm2 for generics
support.");
#endif
}
;
@@ -778,7 +775,7 @@
else
codegen.CurrentCustomAttrTarget =
codegen.CurrentTypeDef.GetGenericParam ((string) $3);
if (codegen.CurrentCustomAttrTarget == null)
- throw new Exception (String.Format
("Type parameter '{0}' undefined.", (string) $3));
+ Report.Error (String.Format ("Type
parameter '{0}' undefined.", (string) $3));
}
| D_PARAM K_TYPE OPEN_BRACKET int32 CLOSE_BRACKET
{
@@ -788,7 +785,7 @@
else
codegen.CurrentCustomAttrTarget =
codegen.CurrentTypeDef.GetGenericParam (index - 1);
if (codegen.CurrentCustomAttrTarget == null)
- throw new Exception (String.Format
("Type parameter '{0}' index out of range.", index));
+ Report.Error (String.Format ("Type
parameter '{0}' index out of range.", index));
}
;
@@ -854,7 +851,7 @@
{
PermPair pp = (PermPair) $1;
if (!CheckSecurityActionValidity
((System.Security.Permissions.SecurityAction) (short) pp.sec_action, false))
- throw new Exception (String.Format
("Invalid security action : {0}", pp.sec_action));
+ Report.Error (String.Format ("Invalid
security action : {0}", pp.sec_action));
codegen.AddPermission (pp.sec_action, pp.perm);
}
@@ -1121,7 +1118,7 @@
int lower = (int) $1;
int upper = (int) $3;
if (lower > upper)
- throw new Exception (String.Format
("Lower bound {0} must be <= upper bound {1}", lower, upper));
+ Report.Error ("Lower bound " + lower +
" must be <= upper bound " + upper);
$$ = new DictionaryEntry ($1, $3);
}
@@ -2125,7 +2122,7 @@
{
PermPair pp = (PermPair) $1;
if (!CheckSecurityActionValidity
((System.Security.Permissions.SecurityAction) (short) pp.sec_action, false))
- throw new Exception (String.Format
("Invalid security action : {0}", pp.sec_action));
+ Report.Error (String.Format ("Invalid
security action : {0}", pp.sec_action));
codegen.AddPermission (pp.sec_action, pp.perm);
}
@@ -2257,8 +2254,7 @@
seh_clause : K_CATCH class_ref handler_block
{
if ($2.GetType () == typeof (PrimitiveTypeRef))
- /* FIXME: Report Error here */
- Console.Error.WriteLine ("Exception not
be of a primitive type.");
+ Report.Error ("Exception not be of a
primitive type.");
BaseClassRef type = (BaseClassRef) $2;
CatchBlock cb = new CatchBlock (type);
@@ -2984,7 +2980,7 @@
{
PermPair pp = (PermPair) $1;
if (!CheckSecurityActionValidity
((System.Security.Permissions.SecurityAction) (short) pp.sec_action, true))
- throw new Exception (String.Format
("Invalid security action : {0}", pp.sec_action));
+ Report.Error (String.Format ("Invalid
security action : {0}", pp.sec_action));
codegen.AddAssemblyPermission (pp.sec_action,
pp.perm);
}
Modified: branches/mono-1-1-13/mcs/ilasm/scanner/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/scanner/ChangeLog 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/scanner/ChangeLog 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1,3 +1,12 @@
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILTable.cs (directives): Remove .constraint
+
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILTokenizingException.cs (ILTokenizingException): Derive from
+ ILAsmException.
+
2006-01-31 Ankit Jain <[EMAIL PROTECTED]>
* ILTables.cs (keywords): Enable keyword 'type' only for NET_2_0
profile.
Modified: branches/mono-1-1-13/mcs/ilasm/scanner/ILTables.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/scanner/ILTables.cs 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/scanner/ILTables.cs 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -54,7 +54,6 @@
directives [".class"] = new ILToken
(Token.D_CLASS, ".class");
directives [".comtype"] = new ILToken
(Token.D_COMTYPE, ".comtype");
directives [".config"] = new ILToken
(Token.D_CONFIG, ".config");
- directives [".constraint"] = new ILToken
(Token.D_CONSTRAINT, ".constraint");
directives [".imagebase"] = new ILToken
(Token.D_IMAGEBASE, ".imagebase");
directives [".corflags"] = new ILToken
(Token.D_CORFLAGS, ".corflags");
directives [".ctor"] = new ILToken
(Token.D_CTOR, ".ctor");
Modified: branches/mono-1-1-13/mcs/ilasm/scanner/ILTokenizingException.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/scanner/ILTokenizingException.cs
2006-02-20 13:03:47 UTC (rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/scanner/ILTokenizingException.cs
2006-02-20 13:07:13 UTC (rev 57066)
@@ -12,12 +12,13 @@
namespace Mono.ILASM {
- public class ILTokenizingException : Exception {
+ public class ILTokenizingException : ILAsmException {
public readonly Location Location;
public readonly string Token;
public ILTokenizingException (Location location, string token)
+ : base (location, token)
{
Location = location;
Token = token;
Modified: branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog 2006-02-20 13:03:47 UTC
(rev 57065)
+++ branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog 2006-02-20 13:07:13 UTC
(rev 57066)
@@ -1,3 +1,8 @@
+2006-02-20 Ankit Jain <[EMAIL PROTECTED]>
+
+ * generics-al.i, test-29.il: Remove. These use invalid style of
+ specifying generic constraints.
+
2006-02-19 Ankit Jain <[EMAIL PROTECTED]>
* invalid-method.il: New. Reference to undefined method.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches