X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Filasm%2FDriver.cs;h=1dfae0e01ca936455f3c5ec80e2c9bf1f86b7a9f;hb=300374f51e37ca8aab5905e37cfbed15f8119b97;hp=479f59a0d4ef010190c918f3d77d7ee46b9aec13;hpb=362718050dce32d6487f06ac12f5ebf2e7a1d9a6;p=mono.git diff --git a/mcs/ilasm/Driver.cs b/mcs/ilasm/Driver.cs index 479f59a0d4e..1dfae0e01ca 100644 --- a/mcs/ilasm/Driver.cs +++ b/mcs/ilasm/Driver.cs @@ -24,15 +24,22 @@ namespace Mono.ILASM { public static int Main (string[] args) { + // Do everything in Invariant + System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + DriverMain driver = new DriverMain (args); try { - driver.Run (); + if (!driver.Run ()) { + Console.WriteLine (); + Console.WriteLine ("***** FAILURE *****"); + return 1; + } } catch (Exception e) { Console.WriteLine (e); Console.WriteLine ("Error while compiling."); return 1; } - Console.WriteLine ("Compilation succeeded"); + Console.WriteLine ("Operation completed successfully"); return 0; } @@ -49,6 +56,7 @@ namespace Mono.ILASM { private bool show_method_ref = false; private bool show_parser = false; private bool scan_only = false; + private bool debugging_info = false; private CodeGen codegen; public DriverMain (string[] args) @@ -58,23 +66,27 @@ namespace Mono.ILASM { report = new Report (quiet); } - public void Run () + public bool Run () { try { if (il_file_list.Count == 0) Usage (); if (output_file == null) output_file = CreateOutputFile (); - codegen = new CodeGen (output_file, target == Target.Dll, true, report); + codegen = new CodeGen (output_file, target == Target.Dll, true, debugging_info, report); foreach (string file_path in il_file_list) ProcessFile (file_path); if (scan_only) - return; + return true; + if (report.ErrorCount > 0) + return false; codegen.Write (); } catch { - throw; + return false; } + + return true; } private void ProcessFile (string file_path) @@ -104,17 +116,23 @@ namespace Mono.ILASM { return; } - ILParser parser = new ILParser (codegen); + ILParser parser = new ILParser (codegen, scanner); + codegen.BeginSourceFile (file_path); try { if (show_parser) parser.yyparse (new ScannerAdapter (scanner), new yydebug.yyDebugSimple ()); else parser.yyparse (new ScannerAdapter (scanner), null); + } catch (ILTokenizingException ilte) { + report.Error (file_path + "(" + ilte.Location.line + ") : error : " + + "syntax error at token '" + ilte.Token + "'."); } catch { Console.WriteLine ("Error at: " + scanner.Reader.Location); throw; - } + } finally { + codegen.EndSourceFile (); + } } public void ShowToken (object sender, NewTokenEventArgs args) @@ -153,6 +171,7 @@ namespace Mono.ILASM { } switch (GetCommand (str, out command_arg)) { case "out": + case "output": output_file = command_arg; break; case "exe": @@ -166,10 +185,15 @@ namespace Mono.ILASM { case "quiet": quiet = true; break; + case "debug": + case "deb": + if (str[0] != '-') + break; + debugging_info = true; + break; // Stubs to stay commandline compatible with MS case "listing": case "nologo": - case "debug": case "clock": case "error": case "subsystem": @@ -204,6 +228,11 @@ namespace Mono.ILASM { break; Version (); break; + default: + if (str [0] == '-') + break; + il_file_list.Add (str); + break; } } } @@ -244,9 +273,10 @@ namespace Mono.ILASM { "ilasm [options] source-files\n" + " --about About the Mono ILasm compiler\n" + " --version Print the version number of the Mono ILasm compiler\n" + - " /out:file_name Specifies output file.\n" + + " /output:file_name Specifies output file.\n" + " /exe Compile to executable.\n" + " /dll Compile to library.\n" + + " /debug Include debug information.\n" + "Options can be of the form -option or /option\n"); Environment.Exit (1); }