2004-01-15 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
[mono.git] / mcs / mcs / driver.cs
1 //
2 // driver.cs: The compiler command line driver.
3 //
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 //
6 // Licensed under the terms of the GNU GPL
7 //
8 // (C) 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
9 //
10
11 namespace Mono.CSharp
12 {
13         using System;
14         using System.Reflection;
15         using System.Reflection.Emit;
16         using System.Collections;
17         using System.IO;
18         using System.Text;
19         using System.Globalization;
20         using Mono.Languages;
21
22         public enum Target {
23                 Library, Exe, Module, WinExe
24         };
25         
26         /// <summary>
27         ///    The compiler driver.
28         /// </summary>
29         public class Driver
30         {
31                 
32                 //
33                 // Assemblies references to be linked.   Initialized with
34                 // mscorlib.dll here.
35                 static ArrayList references;
36
37                 //
38                 // If any of these fail, we ignore the problem.  This is so
39                 // that we can list all the assemblies in Windows and not fail
40                 // if they are missing on Linux.
41                 //
42                 static ArrayList soft_references;
43
44                 //
45                 // Modules to be linked
46                 //
47                 static ArrayList modules;
48
49                 // Lookup paths
50                 static ArrayList link_paths;
51
52                 // Whether we want Yacc to output its progress
53                 static bool yacc_verbose = false;
54
55                 // Whether we want to only run the tokenizer
56                 static bool tokenize = false;
57                 
58                 static string first_source;
59
60                 static bool want_debugging_support = false;
61
62                 static bool parse_only = false;
63                 static bool timestamps = false;
64                 static bool pause = false;
65                 static bool show_counters = false;
66                 public static bool parser_verbose = false;
67                 
68                 //
69                 // Whether to load the initial config file (what CSC.RSP has by default)
70                 // 
71                 static bool load_default_config = true;
72
73                 static Hashtable response_file_list;
74
75                 //
76                 // A list of resource files
77                 //
78                 static ArrayList resources;
79                 static ArrayList embedded_resources;
80                 static string win32ResourceFile;
81                 static string win32IconFile;
82
83                 //
84                 // An array of the defines from the command line
85                 //
86                 static ArrayList defines;
87
88                 //
89                 // Output file
90                 //
91                 static string output_file = null;
92
93                 //
94                 // Last time we took the time
95                 //
96                 static DateTime last_time, first_time;
97
98                 //
99                 // Encoding: ISO-Latin1 is 28591
100                 //
101                 static Encoding encoding;
102
103                 //
104                 // Whether the user has specified a different encoder manually
105                 //
106                 static bool using_default_encoder = true;
107                 
108                 public static void ShowTime (string msg)
109                 {
110                         if (!timestamps)
111                                 return;
112
113                         DateTime now = DateTime.Now;
114                         TimeSpan span = now - last_time;
115                         last_time = now;
116
117                         Console.WriteLine (
118                                 "[{0:00}:{1:000}] {2}",
119                                 (int) span.TotalSeconds, span.Milliseconds, msg);
120                 }
121
122                 public static void ShowTotalTime (string msg)
123                 {
124                         if (!timestamps)
125                                 return;
126
127                         DateTime now = DateTime.Now;
128                         TimeSpan span = now - first_time;
129                         last_time = now;
130
131                         Console.WriteLine (
132                                 "[{0:00}:{1:000}] {2}",
133                                 (int) span.TotalSeconds, span.Milliseconds, msg);
134                 }              
135                
136                 static void tokenize_file (SourceFile file)
137                 {
138                         Stream input;
139
140                         try {
141                                 input = File.OpenRead (file.Name);
142                         } catch {
143                                 Report.Error (2001, "Source file '" + file.Name + "' could not be opened");
144                                 return;
145                         }
146
147                         using (input){
148                                 SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
149                                 Tokenizer lexer = new Tokenizer (reader, file, defines);
150                                 int token, tokens = 0, errors = 0;
151
152                                 while ((token = lexer.token ()) != Token.EOF){
153                                         tokens++;
154                                         if (token == Token.ERROR)
155                                                 errors++;
156                                 }
157                                 Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
158                         }
159                         
160                         return;
161                 }
162
163                 // MonoTODO("Change error code for aborted compilation to something reasonable")]               
164                 static void parse (SourceFile file)
165                 {
166                         CSharpParser parser;
167                         Stream input;
168
169                         try {
170                                 input = File.OpenRead (file.Name);
171                         } catch {
172                                 Report.Error (2001, "Source file '" + file.Name + "' could not be opened");
173                                 return;
174                         }
175
176                         SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
177                                 
178                         parser = new CSharpParser (reader, file, defines);
179                         parser.yacc_verbose = yacc_verbose;
180                         try {
181                                 parser.parse ();
182                         } catch (Exception ex) {
183                                 Report.Error(666, "Compilation aborted: " + ex);
184                         } finally {
185                                 input.Close ();
186                         }
187                 }
188                 
189                 static void Usage ()
190                 {
191                         Console.WriteLine (
192                                 "Mono C# compiler, (C) 2001 - 2003 Ximian, Inc.\n" +
193                                 "mcs [options] source-files\n" +
194                                 "   --about            About the Mono C# compiler\n" +
195                                 "   -checked[+|-]      Set default context to checked\n" +
196                                 "   -codepage:ID       Sets code page to the one in ID\n" +
197                                 "                      (number, `utf8' or `reset')\n" +
198                                 "   -define:S1[;S2]    Defines one or more symbols (short: /d:)\n" +
199                                 "   -debug[+-]         Generate debugging information\n" + 
200                                 "   -doc:FILE          XML Documentation file to generate\n" + 
201                                 "   -g                 Generate debugging information\n" +
202                                 "   --fatal            Makes errors fatal\n" +
203                                 "   -lib:PATH1,PATH2   Adds the paths to the assembly link path\n" +
204                                 "   -main:class        Specified the class that contains the entry point\n" +
205                                 "   -noconfig[+|-]     Disables implicit references to assemblies\n" +
206                                 "   -nostdlib[+|-]     Does not load core libraries\n" +
207                                 "   -nowarn:W1[,W2]    Disables one or more warnings\n" + 
208                                 "   -out:FNAME         Specifies output file\n" +
209                                 "   --parse            Only parses the source file\n" +
210                                 "   --expect-error X   Expect that error X will be encountered\n" +
211                                 "   -recurse:SPEC      Recursively compiles the files in SPEC ([dir]/file)\n" + 
212                                 "   -reference:ASS     References the specified assembly (-r:ASS)\n" +
213                                 "   --stacktrace       Shows stack trace at error location\n" +
214                                 "   -target:KIND       Specifies the target (KIND is one of: exe, winexe,\n" +
215                                 "                      library, module), (short: /t:)\n" +
216                                 "   --timestamp        Displays time stamps of various compiler events\n" +
217                                 "   -unsafe[+|-]       Allows unsafe code\n" +
218                                 "   -warnaserror[+|-]  Treat warnings as errors\n" +
219                                 "   -warn:LEVEL        Sets warning level (the highest is 4, the default is 2)\n" +
220                                 "   -v                 Verbose parsing (for debugging the parser)\n" +
221                                 "   -2                 Enables experimental C# features\n" +
222                                 "\n" +
223                                 "Resources:\n" +
224                                 "   -linkresource:FILE[,ID] Links FILE as a resource\n" +
225                                 "   -resource:FILE[,ID]     Embed FILE as a resource\n" +
226                                 "   -win32res:FILE          Specifies Win32 resource file (.res)\n" +
227                                 "   -win32icon:FILE         Use this icon for the output\n" +
228                                 "   --mcs-debug X      Sets MCS debugging level to X\n" +
229                                 "   @file              Read response file for more options\n\n" +
230                                 "Options can be of the form -option or /option");
231                 }
232
233                 static void TargetUsage ()
234                 {
235                         Report.Error (2019, "Valid options for -target: are exe, winexe, library or module");
236                 }
237                 
238                 static void About ()
239                 {
240                         Console.WriteLine (
241                                 "The Mono C# compiler is (C) 2001, 2002, 2003 Ximian, Inc.\n\n" +
242                                 "The compiler source code is released under the terms of the GNU GPL\n\n" +
243
244                                 "For more information on Mono, visit the project Web site\n" +
245                                 "   http://www.go-mono.com\n\n" +
246
247                                 "The compiler was written by Miguel de Icaza, Ravi Pratap and Martin Baulig");
248                         Environment.Exit (0);
249                 }
250
251                 public static int counter1, counter2;
252                 
253                 public static int Main (string[] args)
254                 {
255                         bool ok = MainDriver (args);
256                         
257                         if (ok && Report.Errors == 0) {
258                                 Console.Write("Compilation succeeded");
259                                 if (Report.Warnings > 0) {
260                                         Console.Write(" - {0} warning(s)", Report.Warnings);
261                                 }
262                                 Console.WriteLine();
263                                 if (show_counters){
264                                         Console.WriteLine ("Counter1: " + counter1);
265                                         Console.WriteLine ("Counter2: " + counter2);
266                                 }
267                                 if (pause)
268                                         Console.ReadLine ();
269                                 return 0;
270                         } else {
271                                 Console.WriteLine("Compilation failed: {0} error(s), {1} warnings",
272                                         Report.Errors, Report.Warnings);
273                                 return 1;
274                         }
275                 }
276
277                 static public void LoadAssembly (string assembly, bool soft)
278                 {
279                         Assembly a;
280                         string total_log = "";
281
282                         try {
283                                 char[] path_chars = { '/', '\\', '.' };
284
285                                 if (assembly.IndexOfAny (path_chars) != -1) {
286                                         a = Assembly.LoadFrom (assembly);
287                                 } else {
288                                         a = Assembly.Load (assembly);
289                                 }
290                                 TypeManager.AddAssembly (a);
291
292                         } catch (FileNotFoundException){
293                                 foreach (string dir in link_paths){
294                                         string full_path = Path.Combine (dir, assembly);
295                                         if (!assembly.EndsWith (".dll"))
296                                                 full_path += ".dll";
297
298                                         try {
299                                                 a = Assembly.LoadFrom (full_path);
300                                                 TypeManager.AddAssembly (a);
301                                                 return;
302                                         } catch (FileNotFoundException ff) {
303                                                 total_log += ff.FusionLog;
304                                                 continue;
305                                         }
306                                 }
307                                 if (!soft) {
308                                         Report.Error (6, "Cannot find assembly `" + assembly + "'" );
309                                         Console.WriteLine ("Log: \n" + total_log);
310                                 }
311                         } catch (BadImageFormatException f) {
312                                 Report.Error(6, "Cannot load assembly (bad file format)" + f.FusionLog);
313                         } catch (FileLoadException f){
314                                 Report.Error(6, "Cannot load assembly " + f.FusionLog);
315                         } catch (ArgumentNullException){
316                                 Report.Error(6, "Cannot load assembly (null argument)");
317                         }
318                 }
319
320                 static public void LoadModule (MethodInfo adder_method, string module)
321                 {
322                         Module m;
323                         string total_log = "";
324
325                         try {
326                                 try {
327                                         m = (Module)adder_method.Invoke (CodeGen.AssemblyBuilder, new object [] { module });
328                                 }
329                                 catch (TargetInvocationException ex) {
330                                         throw ex.InnerException;
331                                 }
332                                 TypeManager.AddModule (m);
333
334                         } 
335                         catch (FileNotFoundException){
336                                 foreach (string dir in link_paths){
337                                         string full_path = Path.Combine (dir, module);
338                                         if (!module.EndsWith (".netmodule"))
339                                                 full_path += ".netmodule";
340
341                                         try {
342                                                 try {
343                                                         m = (Module)adder_method.Invoke (CodeGen.AssemblyBuilder, new object [] { full_path });
344                                                 }
345                                                 catch (TargetInvocationException ex) {
346                                                         throw ex.InnerException;
347                                                 }
348                                                 TypeManager.AddModule (m);
349                                                 return;
350                                         } catch (FileNotFoundException ff) {
351                                                 total_log += ff.FusionLog;
352                                                 continue;
353                                         }
354                                 }
355                                 Report.Error (6, "Cannot find module `" + module + "'" );
356                                 Console.WriteLine ("Log: \n" + total_log);
357                         } catch (BadImageFormatException f) {
358                                 Report.Error(6, "Cannot load module (bad file format)" + f.FusionLog);
359                         } catch (FileLoadException f){
360                                 Report.Error(6, "Cannot load module " + f.FusionLog);
361                         } catch (ArgumentNullException){
362                                 Report.Error(6, "Cannot load module (null argument)");
363                         }
364                 }
365
366                 /// <summary>
367                 ///   Loads all assemblies referenced on the command line
368                 /// </summary>
369                 static public void LoadReferences ()
370                 {
371                         foreach (string r in references)
372                                 LoadAssembly (r, false);
373
374                         foreach (string r in soft_references)
375                                 LoadAssembly (r, true);
376                         
377                         return;
378                 }
379
380                 static void SetupDefaultDefines ()
381                 {
382                         defines = new ArrayList ();
383                         defines.Add ("__MonoCS__");
384                 }
385
386                 static string [] LoadArgs (string file)
387                 {
388                         StreamReader f;
389                         ArrayList args = new ArrayList ();
390                         string line;
391                         try {
392                                 f = new StreamReader (file);
393                         } catch {
394                                 return null;
395                         }
396
397                         StringBuilder sb = new StringBuilder ();
398                         
399                         while ((line = f.ReadLine ()) != null){
400                                 int t = line.Length;
401
402                                 for (int i = 0; i < t; i++){
403                                         char c = line [i];
404                                         
405                                         if (c == '"' || c == '\''){
406                                                 char end = c;
407                                                 
408                                                 for (i++; i < t; i++){
409                                                         c = line [i];
410
411                                                         if (c == end)
412                                                                 break;
413                                                         sb.Append (c);
414                                                 }
415                                         } else if (c == ' '){
416                                                 if (sb.Length > 0){
417                                                         args.Add (sb.ToString ());
418                                                         sb.Length = 0;
419                                                 }
420                                         } else
421                                                 sb.Append (c);
422                                 }
423                                 if (sb.Length > 0){
424                                         args.Add (sb.ToString ());
425                                         sb.Length = 0;
426                                 }
427                         }
428
429                         string [] ret_value = new string [args.Count];
430                         args.CopyTo (ret_value, 0);
431
432                         return ret_value;
433                 }
434
435                 //
436                 // Returns the directory where the system assemblies are installed
437                 //
438                 static string GetSystemDir ()
439                 {
440                         Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
441
442                         foreach (Assembly a in assemblies){
443                                 string codebase = a.Location;
444                                 string fn = System.IO.Path.GetFileName (codebase);
445                                 if (fn == "corlib.dll" || fn == "mscorlib.dll"){
446                                         return codebase.Substring (0, codebase.LastIndexOf (System.IO.Path.DirectorySeparatorChar));
447                                 }
448                         }
449
450                         Report.Error (-15, "Can not compute my system path");
451                         return "";
452                 }
453
454                 //
455                 // Given a path specification, splits the path from the file/pattern
456                 //
457                 static void SplitPathAndPattern (string spec, out string path, out string pattern)
458                 {
459                         int p = spec.LastIndexOf ('/');
460                         if (p != -1){
461                                 //
462                                 // Windows does not like /file.cs, switch that to:
463                                 // "\", "file.cs"
464                                 //
465                                 if (p == 0){
466                                         path = "\\";
467                                         pattern = spec.Substring (1);
468                                 } else {
469                                         path = spec.Substring (0, p);
470                                         pattern = spec.Substring (p + 1);
471                                 }
472                                 return;
473                         }
474
475                         p = spec.LastIndexOf ('\\');
476                         if (p != -1){
477                                 path = spec.Substring (0, p);
478                                 pattern = spec.Substring (p + 1);
479                                 return;
480                         }
481
482                         path = ".";
483                         pattern = spec;
484                 }
485
486                 static void ProcessFile (string f)
487                 {
488                         if (first_source == null)
489                                 first_source = f;
490
491                         Location.AddFile (f);
492                 }
493
494                 static void ProcessFiles ()
495                 {
496                         Location.Initialize ();
497
498                         foreach (SourceFile file in Location.SourceFiles) {
499                                 if (tokenize) {
500                                         tokenize_file (file);
501                                 } else {
502                                         parse (file);
503                                 }
504                         }
505                 }
506
507                 static void CompileFiles (string spec, bool recurse)
508                 {
509                         string path, pattern;
510
511                         SplitPathAndPattern (spec, out path, out pattern);
512                         if (pattern.IndexOf ('*') == -1){
513                                 ProcessFile (spec);
514                                 return;
515                         }
516
517                         string [] files = null;
518                         try {
519                                 files = Directory.GetFiles (path, pattern);
520                         } catch (System.IO.DirectoryNotFoundException) {
521                                 Report.Error (2001, "Source file `" + spec + "' could not be found");
522                                 return;
523                         } catch (System.IO.IOException){
524                                 Report.Error (2001, "Source file `" + spec + "' could not be found");
525                                 return;
526                         }
527                         foreach (string f in files) {
528                                 ProcessFile (f);
529                         }
530
531                         if (!recurse)
532                                 return;
533                         
534                         string [] dirs = null;
535
536                         try {
537                                 dirs = Directory.GetDirectories (path);
538                         } catch {
539                         }
540                         
541                         foreach (string d in dirs) {
542                                         
543                                 // Don't include path in this string, as each
544                                 // directory entry already does
545                                 CompileFiles (d + "/" + pattern, true);
546                         }
547                 }
548
549                 static void DefineDefaultConfig ()
550                 {
551                         //
552                         // For now the "default config" is harcoded into the compiler
553                         // we can move this outside later
554                         //
555                         string [] default_config = {
556                                 "System",
557                                 "System.Xml",
558 #if false
559                                 //
560                                 // Is it worth pre-loading all this stuff?
561                                 //
562                                 "Accessibility",
563                                 "System.Configuration.Install",
564                                 "System.Data",
565                                 "System.Design",
566                                 "System.DirectoryServices",
567                                 "System.Drawing.Design",
568                                 "System.Drawing",
569                                 "System.EnterpriseServices",
570                                 "System.Management",
571                                 "System.Messaging",
572                                 "System.Runtime.Remoting",
573                                 "System.Runtime.Serialization.Formatters.Soap",
574                                 "System.Security",
575                                 "System.ServiceProcess",
576                                 "System.Web",
577                                 "System.Web.RegularExpressions",
578                                 "System.Web.Services",
579                                 "System.Windows.Forms"
580 #endif
581                         };
582                         
583                         int p = 0;
584                         foreach (string def in default_config)
585                                 soft_references.Insert (p++, def);
586                 }
587
588                 static void SetOutputFile (string name)
589                 {
590                         output_file = name;
591                 }
592
593                 static void SetWarningLevel (string s)
594                 {
595                         int level = 0;
596
597                         try {
598                                 level = Int32.Parse (s);
599                         } catch {
600                                 Report.Error (
601                                         1900,
602                                         "--wlevel requires a value from 0 to 4");
603                                 Environment.Exit (1);
604                         }
605                         if (level < 0 || level > 4){
606                                 Report.Error (1900, "Warning level must be 0 to 4");
607                                 Environment.Exit (1);
608                         }
609                         RootContext.WarningLevel = level;
610                         TestWarningConflict ();
611                 }
612
613                 static void TestWarningConflict ()
614                 {
615                         if (RootContext.WarningLevel == 0 && Report.WarningsAreErrors) {
616                                 Report.Error (1901, "Conflicting options specified: Warning level 0; Treat warnings as errors");
617                                 Environment.Exit (1);
618                         }
619                 }
620
621                 static void SetupV2 ()
622                 {
623                         RootContext.V2 = true;
624                         defines.Add ("__V2__");
625                 }
626                 
627                 static void Version ()
628                 {
629                         string version = Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
630                         Console.WriteLine ("Mono C# compiler version {0}", version);
631                         Environment.Exit (0);
632                 }
633                 
634                 //
635                 // Currently handles the Unix-like command line options, but will be
636                 // deprecated in favor of the CSCParseOption, which will also handle the
637                 // options that start with a dash in the future.
638                 //
639                 static bool UnixParseOption (string arg, ref string [] args, ref int i)
640                 {
641                         switch (arg){
642                         case "-vv":
643                                 parser_verbose = true;
644                                 return true;
645                                 
646                         case "-v":
647                                 yacc_verbose = true;
648                                 return true;
649
650                         case "--version":
651                                 Version ();
652                                 return true;
653                                 
654                         case "--parse":
655                                 parse_only = true;
656                                 return true;
657                                 
658                         case "--main": case "-m":
659                                 if ((i + 1) >= args.Length){
660                                         Usage ();
661                                         Environment.Exit (1);
662                                 }
663                                 RootContext.MainClass = args [++i];
664                                 return true;
665                                 
666                         case "--unsafe":
667                                 RootContext.Unsafe = true;
668                                 return true;
669                                 
670                         case "/?": case "/h": case "/help":
671                         case "--help":
672                                 Usage ();
673                                 Environment.Exit (0);
674                                 return true;
675                                 
676                         case "--define":
677                                 if ((i + 1) >= args.Length){
678                                         Usage ();
679                                         Environment.Exit (1);
680                                 }
681                                 defines.Add (args [++i]);
682                                 return true;
683
684                         case "--show-counters":
685                                 show_counters = true;
686                                 return true;
687                                 
688                         case "--expect-error": {
689                                 int code = 0;
690                                 
691                                 try {
692                                         code = Int32.Parse (
693                                                 args [++i], NumberStyles.AllowLeadingSign);
694                                         Report.ExpectedError = code;
695                                 } catch {
696                                         Report.Error (-14, "Invalid number specified");
697                                 } 
698                                 return true;
699                         }
700                                 
701                         case "--tokenize": 
702                                 tokenize = true;
703                                 return true;
704                                 
705                         case "-o": 
706                         case "--output":
707                                 if ((i + 1) >= args.Length){
708                                         Usage ();
709                                         Environment.Exit (1);
710                                 }
711                                 SetOutputFile (args [++i]);
712                                 return true;
713                                 
714                         case "--checked":
715                                 RootContext.Checked = true;
716                                 return true;
717                                 
718                         case "--stacktrace":
719                                 Report.Stacktrace = true;
720                                 return true;
721                                 
722                         case "--linkresource":
723                         case "--linkres":
724                                 if ((i + 1) >= args.Length){
725                                         Usage ();
726                                         Report.Error (5, "Missing argument to --linkres"); 
727                                         Environment.Exit (1);
728                                 }
729                                 if (resources == null)
730                                         resources = new ArrayList ();
731                                 
732                                 resources.Add (args [++i]);
733                                 return true;
734                                 
735                         case "--resource":
736                         case "--res":
737                                 if ((i + 1) >= args.Length){
738                                         Usage ();
739                                         Report.Error (5, "Missing argument to --resource"); 
740                                         Environment.Exit (1);
741                                 }
742                                 if (embedded_resources == null)
743                                         embedded_resources = new ArrayList ();
744                                 
745                                 embedded_resources.Add (args [++i]);
746                                 return true;
747                                 
748                         case "--target":
749                                 if ((i + 1) >= args.Length){
750                                         Environment.Exit (1);
751                                         return true;
752                                 }
753                                 
754                                 string type = args [++i];
755                                 switch (type){
756                                 case "library":
757                                         RootContext.Target = Target.Library;
758                                         RootContext.TargetExt = ".dll";
759                                         break;
760                                         
761                                 case "exe":
762                                         RootContext.Target = Target.Exe;
763                                         break;
764                                         
765                                 case "winexe":
766                                         RootContext.Target = Target.WinExe;
767                                         break;
768                                         
769                                 case "module":
770                                         RootContext.Target = Target.Module;
771                                         RootContext.TargetExt = ".dll";
772                                         break;
773                                 default:
774                                         TargetUsage ();
775                                         Environment.Exit (1);
776                                         break;
777                                 }
778                                 return true;
779                                 
780                         case "-r":
781                                 if ((i + 1) >= args.Length){
782                                         Usage ();
783                                         Environment.Exit (1);
784                                 }
785                                 
786                                 references.Add (args [++i]);
787                                 return true;
788                                 
789                         case "-L":
790                                 if ((i + 1) >= args.Length){
791                                         Usage ();       
792                                         Environment.Exit (1);
793                                 }
794                                 link_paths.Add (args [++i]);
795                                 return true;
796                                 
797                         case "--nostdlib":
798                                 RootContext.StdLib = false;
799                                 return true;
800                                 
801                         case "--fatal":
802                                 Report.Fatal = true;
803                                 return true;
804                                 
805                         case "--werror":
806                                 Report.WarningsAreErrors = true;
807                                 TestWarningConflict();
808                                 return true;
809                                 
810                         case "--nowarn":
811                                 if ((i + 1) >= args.Length){
812                                         Usage ();
813                                         Environment.Exit (1);
814                                 }
815                                 int warn = 0;
816                                 
817                                 try {
818                                         warn = Int32.Parse (args [++i]);
819                                 } catch {
820                                         Usage ();
821                                         Environment.Exit (1);
822                                 }
823                                 Report.SetIgnoreWarning (warn);
824                                 return true;
825                                 
826                         case "--wlevel":
827                                 if ((i + 1) >= args.Length){
828                                         Report.Error (
829                                                 1900,
830                                                 "--wlevel requires a value from 0 to 4");
831                                         Environment.Exit (1);
832                                 }
833
834                                 SetWarningLevel (args [++i]);
835                                 return true;
836
837                         case "--mcs-debug":
838                                 if ((i + 1) >= args.Length){
839                                         Report.Error (5, "--mcs-debug requires an argument");
840                                         Environment.Exit (1);
841                                 }
842
843                                 try {
844                                         Report.DebugFlags = Int32.Parse (args [++i]);
845                                 } catch {
846                                         Report.Error (5, "Invalid argument to --mcs-debug");
847                                         Environment.Exit (1);
848                                 }
849                                 return true;
850                                 
851                         case "--about":
852                                 About ();
853                                 return true;
854                                 
855                         case "--recurse":
856                                 if ((i + 1) >= args.Length){
857                                         Report.Error (5, "--recurse requires an argument");
858                                         Environment.Exit (1);
859                                 }
860                                 CompileFiles (args [++i], true); 
861                                 return true;
862                                 
863                         case "--timestamp":
864                                 timestamps = true;
865                                 last_time = first_time = DateTime.Now;
866                                 return true;
867
868                         case "--pause":
869                                 pause = true;
870                                 return true;
871                                 
872                         case "--debug": case "-g":
873                                 want_debugging_support = true;
874                                 return true;
875                                 
876                         case "--noconfig":
877                                 load_default_config = false;
878                                 return true;
879                         }
880
881                         return false;
882                 }
883
884                 //
885                 // Currently it is very basic option parsing, but eventually, this will
886                 // be the complete option parser
887                 //
888                 static bool CSCParseOption (string option, ref string [] args, ref int i)
889                 {
890                         int idx = option.IndexOf (':');
891                         string arg, value;
892
893                         if (idx == -1){
894                                 arg = option;
895                                 value = "";
896                         } else {
897                                 arg = option.Substring (0, idx);
898
899                                 value = option.Substring (idx + 1);
900                         }
901
902                         switch (arg){
903                         case "/nologo":
904                                 return true;
905
906                         case "/t":
907                         case "/target":
908                                 switch (value){
909                                 case "exe":
910                                         RootContext.Target = Target.Exe;
911                                         break;
912
913                                 case "winexe":
914                                         RootContext.Target = Target.WinExe;
915                                         break;
916
917                                 case "library":
918                                         RootContext.Target = Target.Library;
919                                         RootContext.TargetExt = ".dll";
920                                         break;
921
922                                 case "module":
923                                         RootContext.Target = Target.Module;
924                                         RootContext.TargetExt = ".netmodule";
925                                         break;
926
927                                 default:
928                                         TargetUsage ();
929                                         Environment.Exit (1);
930                                         break;
931                                 }
932                                 return true;
933
934                         case "/out":
935                                 if (value == ""){
936                                         Usage ();
937                                         Environment.Exit (1);
938                                 }
939                                 SetOutputFile (value);
940                                 return true;
941
942                         case "/optimize":
943                         case "/optimize+":
944                         case "/optimize-":
945                         case "/incremental":
946                         case "/incremental+":
947                         case "/incremental-":
948                                 // nothing.
949                                 return true;
950
951                         case "/d":
952                         case "/define": {
953                                 string [] defs;
954
955                                 if (value == ""){
956                                         Usage ();
957                                         Environment.Exit (1);
958                                 }
959
960                                 defs = value.Split (new Char [] {';', ','});
961                                 foreach (string d in defs){
962                                         defines.Add (d);
963                                 }
964                                 return true;
965                         }
966
967                         case "/linkres":
968                         case "/linkresource":
969                                 if (value == ""){
970                                         Report.Error (5, arg + " requires an argument");
971                                         Environment.Exit (1);
972                                 }
973                                 if (resources == null)
974                                         resources = new ArrayList ();
975                                 
976                                 resources.Add (value);
977                                 return true;
978                                 
979                         case "/res":
980                         case "/resource":
981                                 if (value == ""){
982                                         Report.Error (5, arg + " requires an argument");
983                                         Environment.Exit (1);
984                                 }
985                                 if (embedded_resources == null)
986                                         embedded_resources = new ArrayList ();
987                                 
988                                 embedded_resources.Add (value);
989                                 return true;
990                                 
991                         case "/recurse":
992                                 if (value == ""){
993                                         Report.Error (5, "/recurse requires an argument");
994                                         Environment.Exit (1);
995                                 }
996                                 CompileFiles (value, true); 
997                                 return true;
998
999                         case "/r":
1000                         case "/reference": {
1001                                 if (value == ""){
1002                                         Report.Error (5, arg + " requires an argument");
1003                                         Environment.Exit (1);
1004                                 }
1005
1006                                 string [] refs = value.Split (new char [] { ';', ',' });
1007                                 foreach (string r in refs){
1008                                         references.Add (r);
1009                                 }
1010                                 return true;
1011                         }
1012                         case "/addmodule": {
1013                                 if (value == ""){
1014                                         Report.Error (5, arg + " requires an argument");
1015                                         Environment.Exit (1);
1016                                 }
1017
1018                                 string [] refs = value.Split (new char [] { ';', ',' });
1019                                 foreach (string r in refs){
1020                                         modules.Add (r);
1021                                 }
1022                                 return true;
1023                         }
1024                         case "/win32res": {
1025                                 if (value == "") {
1026                                         Report.Error (5, arg + " requires an argument");
1027                                         Environment.Exit (1);
1028                                 }
1029
1030                                 win32ResourceFile = value;
1031                                 return true;
1032                         }
1033                         case "/win32icon": {
1034                                 if (value == "") {
1035                                         Report.Error (5, arg + " requires an argument");
1036                                         Environment.Exit (1);
1037                                 }
1038
1039                                 win32IconFile = value;
1040                                 return true;
1041                         }
1042                         case "/doc": {
1043                                 if (value == ""){
1044                                         Report.Error (5, arg + " requires an argument");
1045                                         Environment.Exit (1);
1046                                 }
1047                                 // TODO handle the /doc argument to generate xml doc
1048                                 return true;
1049                         }
1050                         case "/lib": {
1051                                 string [] libdirs;
1052                                 
1053                                 if (value == ""){
1054                                         Report.Error (5, "/lib requires an argument");
1055                                         Environment.Exit (1);
1056                                 }
1057
1058                                 libdirs = value.Split (new Char [] { ',' });
1059                                 foreach (string dir in libdirs)
1060                                         link_paths.Add (dir);
1061                                 return true;
1062                         }
1063                                 
1064                         case "/debug":
1065                         case "/debug+":
1066                                 want_debugging_support = true;
1067                                 return true;
1068
1069                         case "/checked":
1070                         case "/checked+":
1071                                 RootContext.Checked = true;
1072                                 return true;
1073
1074                         case "/checked-":
1075                                 RootContext.Checked = false;
1076                                 return true;
1077
1078                         case "/unsafe":
1079                         case "/unsafe+":
1080                                 RootContext.Unsafe = true;
1081                                 return true;
1082
1083                         case "/unsafe-":
1084                                 RootContext.Unsafe = false;
1085                                 return true;
1086
1087                         case "/warnaserror":
1088                         case "/warnaserror+":
1089                                 Report.WarningsAreErrors = true;
1090                                 TestWarningConflict();
1091                                 return true;
1092
1093                         case "/warnaserror-":
1094                                 Report.WarningsAreErrors = false;
1095                                 return true;
1096
1097                         case "/warn":
1098                                 SetWarningLevel (value);
1099                                 return true;
1100
1101                         case "/nowarn": {
1102                                 string [] warns;
1103
1104                                 if (value == ""){
1105                                         Report.Error (5, "/nowarn requires an argument");
1106                                         Environment.Exit (1);
1107                                 }
1108                                 
1109                                 warns = value.Split (new Char [] {','});
1110                                 foreach (string wc in warns){
1111                                         try {
1112                                                 int warn = Int32.Parse (wc);
1113                                                 if (warn < 1) {
1114                                                         throw new ArgumentOutOfRangeException("warn");
1115                                                 }
1116                                                 Report.SetIgnoreWarning (warn);
1117                                         } catch {
1118                                                 Report.Error (1904, String.Format("'{0}' is not a valid warning number", wc));
1119                                                 Environment.Exit (1);
1120                                         }
1121                                 }
1122                                 return true;
1123                         }
1124
1125                         case "/noconfig-":
1126                                 load_default_config = true;
1127                                 return true;
1128                                 
1129                         case "/noconfig":
1130                         case "/noconfig+":
1131                                 load_default_config = false;
1132                                 return true;
1133
1134                         case "/help":
1135                         case "/?":
1136                                 Usage ();
1137                                 Environment.Exit (0);
1138                                 return true;
1139
1140                         case "/main":
1141                         case "/m":
1142                                 if (value == ""){
1143                                         Report.Error (5, arg + " requires an argument");                                        
1144                                         Environment.Exit (1);
1145                                 }
1146                                 RootContext.MainClass = value;
1147                                 return true;
1148
1149                         case "/nostdlib":
1150                         case "/nostdlib+":
1151                                 RootContext.StdLib = false;
1152                                 return true;
1153
1154                         case "/nostdlib-":
1155                                 RootContext.StdLib = true;
1156                                 return true;
1157
1158                         case "/fullpaths":
1159                                 return true;
1160
1161                         case "/v2":
1162                         case "/2":
1163                                 SetupV2 ();
1164                                 return true;
1165                                 
1166                         case "/codepage":
1167                                 int cp = -1;
1168
1169                                 if (value == "utf8"){
1170                                         encoding = new UTF8Encoding();
1171                                         using_default_encoder = false;
1172                                         return true;
1173                                 }
1174                                 if (value == "reset"){
1175                                         //
1176                                         // 28591 is the code page for ISO-8859-1 encoding.
1177                                         //
1178                                         cp = 28591;
1179                                         using_default_encoder = true;
1180                                 }
1181                                 
1182                                 try {
1183                                         cp = Int32.Parse (value);
1184                                         encoding = Encoding.GetEncoding (cp);
1185                                         using_default_encoder = false;
1186                                 } catch {
1187                                         Report.Error (2016, String.Format("Code page '{0}' is invalid or not installed", cp));
1188                                         Environment.Exit (1);
1189                                 }
1190                                 return true;
1191                         }
1192                         //Report.Error (2007, String.Format ("Unrecognized command-line option: '{0}'", option));
1193                         //Environment.Exit (1);
1194                         return false;
1195                 }
1196                 
1197                 /// <summary>
1198                 ///    Parses the arguments, and drives the compilation
1199                 ///    process.
1200                 /// </summary>
1201                 ///
1202                 /// <remarks>
1203                 ///    TODO: Mostly structured to debug the compiler
1204                 ///    now, needs to be turned into a real driver soon.
1205                 /// </remarks>
1206                 // [MonoTODO("Change error code for unknown argument to something reasonable")]
1207                 internal static bool MainDriver (string [] args)
1208                 {
1209                         int i;
1210                         bool parsing_options = true;
1211
1212                         try {
1213                                 encoding = Encoding.GetEncoding (28591);
1214                         } catch {
1215                                 Console.WriteLine ("Error: could not load encoding 28591, trying 1252");
1216                                 encoding = Encoding.GetEncoding (1252);
1217                         }
1218                         
1219                         references = new ArrayList ();
1220                         soft_references = new ArrayList ();
1221                         modules = new ArrayList ();
1222                         link_paths = new ArrayList ();
1223
1224                         SetupDefaultDefines ();
1225                         
1226                         //
1227                         // Setup defaults
1228                         //
1229                         // This is not required because Assembly.Load knows about this
1230                         // path.
1231                         //
1232
1233                         int argc = args.Length;
1234                         for (i = 0; i < argc; i++){
1235                                 string arg = args [i];
1236
1237                                 if (arg.StartsWith ("@")){
1238                                         string [] new_args, extra_args;
1239                                         string response_file = arg.Substring (1);
1240
1241                                         if (response_file_list == null)
1242                                                 response_file_list = new Hashtable ();
1243                                         
1244                                         if (response_file_list.Contains (response_file)){
1245                                                 Report.Error (
1246                                                         1515, "Response file `" + response_file +
1247                                                         "' specified multiple times");
1248                                                 Environment.Exit (1);
1249                                         }
1250                                         
1251                                         response_file_list.Add (response_file, response_file);
1252                                                     
1253                                         extra_args = LoadArgs (response_file);
1254                                         if (extra_args == null){
1255                                                 Report.Error (2011, "Unable to open response file: " +
1256                                                               response_file);
1257                                                 return false;
1258                                         }
1259
1260                                         new_args = new string [extra_args.Length + argc];
1261                                         args.CopyTo (new_args, 0);
1262                                         extra_args.CopyTo (new_args, argc);
1263                                         args = new_args;
1264                                         argc = new_args.Length;
1265                                         continue;
1266                                 }
1267
1268                                 if (parsing_options){
1269                                         if (arg == "--"){
1270                                                 parsing_options = false;
1271                                                 continue;
1272                                         }
1273                                         
1274                                         if (arg.StartsWith ("-")){
1275                                                 if (UnixParseOption (arg, ref args, ref i))
1276                                                         continue;
1277
1278                                                 // Try a -CSCOPTION
1279                                                 string csc_opt = "/" + arg.Substring (1);
1280                                                 if (CSCParseOption (csc_opt, ref args, ref i))
1281                                                         continue;
1282                                         } else {
1283                                                 if (arg.StartsWith ("/")){
1284                                                         if (CSCParseOption (arg, ref args, ref i))
1285                                                                 continue;
1286                                                 }
1287                                         }
1288                                 }
1289
1290                                 CompileFiles (arg, false); 
1291                         }
1292
1293                         ProcessFiles ();
1294
1295                         if (tokenize)
1296                                 return true;
1297
1298                         //
1299                         // If we are an exe, require a source file for the entry point
1300                         //
1301                         if (RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe){
1302                                 if (first_source == null){
1303                                         Report.Error (2008, "No files to compile were specified");
1304                                         return false;
1305                                 }
1306
1307                         }
1308
1309                         //
1310                         // If there is nothing to put in the assembly, and we are not a library
1311                         //
1312                         if (first_source == null && embedded_resources == null && resources == null){
1313                                         Report.Error (2008, "No files to compile were specified");
1314                                         return false;
1315                         }
1316
1317                         if (Report.Errors > 0)
1318                                 return false;
1319                         
1320                         if (parse_only)
1321                                 return true;
1322
1323                         Tokenizer.Cleanup ();
1324                         
1325                         //
1326                         // Load Core Library for default compilation
1327                         //
1328                         if (RootContext.StdLib)
1329                                 references.Insert (0, "mscorlib");
1330
1331                         if (load_default_config)
1332                                 DefineDefaultConfig ();
1333
1334                         if (Report.Errors > 0){
1335                                 return false;
1336                         }
1337
1338                         //
1339                         // Load assemblies required
1340                         //
1341                         if (timestamps)
1342                                 ShowTime ("Loading references");
1343                         link_paths.Add (GetSystemDir ());
1344                         LoadReferences ();
1345                         
1346                         if (timestamps)
1347                                 ShowTime ("   References loaded");
1348                         
1349                         if (Report.Errors > 0){
1350                                 return false;
1351                         }
1352
1353                         //
1354                         // Quick hack
1355                         //
1356                         if (output_file == null){
1357                                 int pos = first_source.LastIndexOf ('.');
1358
1359                                 if (pos > 0)
1360                                         output_file = first_source.Substring (0, pos) + RootContext.TargetExt;
1361                                 else
1362                                         output_file = first_source + RootContext.TargetExt;
1363                         }
1364
1365                         CodeGen.Init (output_file, output_file, want_debugging_support);
1366
1367                         if (RootContext.Target == Target.Module) {
1368                                 PropertyInfo module_only = typeof (AssemblyBuilder).GetProperty ("IsModuleOnly", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
1369                                 if (module_only == null) {
1370                                         Report.Error (0, new Location (-1), "Cannot use /target:module on this runtime: try the Mono runtime instead.");
1371                                         Environment.Exit (1);
1372                                 }
1373
1374                                 module_only.SetValue (CodeGen.AssemblyBuilder, true, null);
1375                         }
1376
1377                         TypeManager.AddModule (CodeGen.ModuleBuilder);
1378
1379                         if (modules.Count > 0) {
1380                                 MethodInfo adder_method = typeof (AssemblyBuilder).GetMethod ("AddModule", BindingFlags.Instance|BindingFlags.NonPublic);
1381                                 if (adder_method == null) {
1382                                         Report.Error (0, new Location (-1), "Cannot use /addmodule on this runtime: Try the Mono runtime instead.");
1383                                         Environment.Exit (1);
1384                                 }
1385
1386                                 foreach (string module in modules)
1387                                         LoadModule (adder_method, module);
1388                         }
1389
1390                         TypeManager.ComputeNamespaces ();
1391                         
1392                         //
1393                         // Before emitting, we need to get the core
1394                         // types emitted from the user defined types
1395                         // or from the system ones.
1396                         //
1397                         if (timestamps)
1398                                 ShowTime ("Initializing Core Types");
1399                         if (!RootContext.StdLib){
1400                                 RootContext.ResolveCore ();
1401                                 if (Report.Errors > 0)
1402                                         return false;
1403                         }
1404                         
1405                         TypeManager.InitCoreTypes ();
1406                         if (timestamps)
1407                                 ShowTime ("   Core Types done");
1408
1409                         //
1410                         // The second pass of the compiler
1411                         //
1412                         if (timestamps)
1413                                 ShowTime ("Resolving tree");
1414                         RootContext.ResolveTree ();
1415                         if (Report.Errors > 0)
1416                                 return false;
1417                         if (timestamps)
1418                                 ShowTime ("Populate tree");
1419                         if (!RootContext.StdLib)
1420                                 RootContext.BootCorlib_PopulateCoreTypes ();
1421                         RootContext.PopulateTypes ();
1422                         RootContext.DefineTypes ();
1423                         
1424                         TypeManager.InitCodeHelpers ();
1425
1426                         //
1427                         // Verify using aliases now
1428                         //
1429                         Namespace.VerifyUsing ();
1430                         
1431                         if (Report.Errors > 0){
1432                                 return false;
1433                         }
1434                         
1435                         //
1436                         // The code generator
1437                         //
1438                         if (timestamps)
1439                                 ShowTime ("Emitting code");
1440                         ShowTotalTime ("Total so far");
1441                         RootContext.EmitCode ();
1442                         if (timestamps)
1443                                 ShowTime ("   done");
1444
1445                         if (Report.Errors > 0){
1446                                 return false;
1447                         }
1448
1449                         if (timestamps)
1450                                 ShowTime ("Closing types");
1451
1452                         RootContext.CloseTypes ();
1453
1454                         PEFileKinds k = PEFileKinds.ConsoleApplication;
1455                         
1456                         switch (RootContext.Target) {
1457                         case Target.Library:
1458                         case Target.Module:
1459                                 k = PEFileKinds.Dll; break;
1460                         case Target.Exe:
1461                                 k = PEFileKinds.ConsoleApplication; break;
1462                         case Target.WinExe:
1463                                 k = PEFileKinds.WindowApplication; break;
1464                         }
1465
1466                         if (RootContext.NeedsEntryPoint) {
1467                                 MethodInfo ep = RootContext.EntryPoint;
1468
1469                                 if (ep == null) {
1470                                         if (Report.Errors == 0)
1471                                                 Report.Error (5001, "Program " + output_file +
1472                                                               " does not have an entry point defined");
1473                                         return false;
1474                                 }
1475                                 
1476                                 CodeGen.AssemblyBuilder.SetEntryPoint (ep, k);
1477                         } else if (RootContext.MainClass != null) {
1478                                 Report.Error (2017, "Can not specify -main: when building module or library");
1479                         }
1480
1481                         //
1482                         // Add the resources
1483                         //
1484                         if (resources != null){
1485                                 foreach (string spec in resources){
1486                                         string file, res;
1487                                         int cp;
1488                                         
1489                                         cp = spec.IndexOf (',');
1490                                         if (cp != -1){
1491                                                 file = spec.Substring (0, cp);
1492                                                 res = spec.Substring (cp + 1);
1493                                         } else
1494                                                 file = res = spec;
1495
1496                                         CodeGen.AssemblyBuilder.AddResourceFile (res, file);
1497                                 }
1498                         }
1499                         
1500                         if (embedded_resources != null){
1501                                 object[] margs = new object [2];
1502                                 Type[] argst = new Type [2];
1503                                 argst [0] = argst [1] = typeof (string);
1504
1505                                 MethodInfo embed_res = typeof (AssemblyBuilder).GetMethod ("EmbedResourceFile", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic, null, CallingConventions.Any, argst, null);
1506                                 if (embed_res == null) {
1507                                         Report.Warning (0, new Location (-1), "Cannot embed resources on this runtime: try the Mono runtime instead.");
1508                                 } else {
1509                                         foreach (string spec in embedded_resources) {
1510                                                 int cp;
1511
1512                                                 cp = spec.IndexOf (',');
1513                                                 if (cp != -1){
1514                                                         margs [0] = spec.Substring (cp + 1);
1515                                                         margs [1] = spec.Substring (0, cp);
1516                                                 } else
1517                                                         margs [0] = margs [1] = spec;
1518
1519                                                 if (File.Exists ((string) margs [1]))
1520                                                         embed_res.Invoke (CodeGen.AssemblyBuilder, margs);
1521                                                 else {
1522                                                         Report.Error (1566, "Can not find the resource " + margs [1]);
1523                                                 }
1524                                         }
1525                                 }
1526                         }
1527
1528                         //
1529                         // Add Win32 resources
1530                         //
1531
1532                         CodeGen.AssemblyBuilder.DefineVersionInfoResource ();
1533
1534                         if (win32ResourceFile != null) {
1535                                 try {
1536                                         CodeGen.AssemblyBuilder.DefineUnmanagedResource (win32ResourceFile);
1537                                 }
1538                                 catch (ArgumentException) {
1539                                         Report.Warning (0, new Location (-1), "Cannot embed win32 resources on this runtime: try the Mono runtime instead.");
1540                                 }
1541                         }
1542
1543                         if (win32IconFile != null) {
1544                                 MethodInfo define_icon = typeof (AssemblyBuilder).GetMethod ("DefineIconResource", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
1545                                 if (define_icon == null) {
1546                                         Report.Warning (0, new Location (-1), "Cannot embed icon resource on this runtime: try the Mono runtime instead.");
1547                                 }
1548                                 define_icon.Invoke (CodeGen.AssemblyBuilder, new object [] { win32IconFile });
1549                         }
1550
1551                         if (Report.Errors > 0)
1552                                 return false;
1553                         
1554                         CodeGen.Save (output_file);
1555                         if (timestamps) {
1556                                 ShowTime ("Saved output");
1557                                 ShowTotalTime ("Total");
1558                         }
1559
1560                         Timer.ShowTimers ();
1561                         
1562                         if (Report.ExpectedError != 0){
1563                                 Console.WriteLine("Failed to report expected error " + Report.ExpectedError);
1564                                 Environment.Exit (1);
1565                                 return false;
1566                         }
1567
1568 #if DEBUGME
1569                         Console.WriteLine ("Size of strings held: " + DeclSpace.length);
1570                         Console.WriteLine ("Size of strings short: " + DeclSpace.small);
1571 #endif
1572                         return (Report.Errors == 0);
1573                 }
1574
1575         }
1576
1577         //
1578         // This is the only public entry point
1579         //
1580         public class CompilerCallableEntryPoint : MarshalByRefObject {
1581                 static bool used = false;
1582                 
1583                 public bool InvokeCompiler (string [] args)
1584                 {
1585                         if (used)
1586                                 Reset ();
1587                         bool ok = Driver.MainDriver (args);
1588                         return ok && Report.Errors == 0;
1589                 }
1590
1591                 public void Reset ()
1592                 {
1593                 }
1594         }
1595 }