2 // driver.cs: The compiler command line driver.
4 // Author: Miguel de Icaza (miguel@gnu.org)
6 // Licensed under the terms of the GNU GPL
8 // (C) 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
14 using System.Reflection;
15 using System.Reflection.Emit;
16 using System.Collections;
19 using System.Globalization;
23 Library, Exe, Module, WinExe
27 /// The compiler driver.
33 // Assemblies references to be linked. Initialized with
35 static ArrayList references;
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.
42 static ArrayList soft_references;
45 static ArrayList link_paths;
47 // Whether we want Yacc to output its progress
48 static bool yacc_verbose = false;
50 // Whether we want to only run the tokenizer
51 static bool tokenize = false;
53 static string first_source;
55 static Target target = Target.Exe;
56 static string target_ext = ".exe";
58 static bool want_debugging_support = false;
60 static bool parse_only = false;
61 static bool timestamps = false;
62 static bool pause = false;
63 static bool show_counters = false;
64 public static bool parser_verbose = false;
67 // Whether to load the initial config file (what CSC.RSP has by default)
69 static bool load_default_config = true;
71 static Hashtable response_file_list;
74 // A list of resource files
76 static ArrayList resources;
77 static ArrayList embedded_resources;
80 // An array of the defines from the command line
82 static ArrayList defines;
87 static string output_file = null;
90 // Last time we took the time
92 static DateTime last_time, first_time;
95 // Encoding: ISO-Latin1 is 28591
97 static Encoding encoding;
100 // Whether the user has specified a different encoder manually
102 static bool using_default_encoder = true;
104 public static void ShowTime (string msg)
109 DateTime now = DateTime.Now;
110 TimeSpan span = now - last_time;
114 "[{0:00}:{1:000}] {2}",
115 (int) span.TotalSeconds, span.Milliseconds, msg);
118 public static void ShowTotalTime (string msg)
123 DateTime now = DateTime.Now;
124 TimeSpan span = now - first_time;
128 "[{0:00}:{1:000}] {2}",
129 (int) span.TotalSeconds, span.Milliseconds, msg);
132 static void tokenize_file (SourceFile file)
137 input = File.OpenRead (file.Name);
139 Report.Error (2001, "Source file '" + file.Name + "' could not be opened");
144 SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
145 Tokenizer lexer = new Tokenizer (reader, file, defines);
146 int token, tokens = 0, errors = 0;
148 while ((token = lexer.token ()) != Token.EOF){
149 Location l = lexer.Location;
151 if (token == Token.ERROR)
154 Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
160 // MonoTODO("Change error code for aborted compilation to something reasonable")]
161 static void parse (SourceFile file)
167 input = File.OpenRead (file.Name);
169 Report.Error (2001, "Source file '" + file.Name + "' could not be opened");
173 SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
175 parser = new CSharpParser (reader, file, defines);
176 parser.yacc_verbose = yacc_verbose;
179 } catch (Exception ex) {
180 Report.Error(666, "Compilation aborted: " + ex);
189 "Mono C# compiler, (C) 2001 - 2003 Ximian, Inc.\n" +
190 "mcs [options] source-files\n" +
191 " --about About the Mono C# compiler\n" +
192 " -checked[+|-] Set default context to checked\n" +
193 " -codepage:ID Sets code page to the one in ID\n" +
194 " (number, `utf8' or `reset')\n" +
195 " -define:S1[;S2] Defines one or more symbols (short: /d:)\n" +
196 " -debug[+-] Generate debugging information\n" +
197 " -doc:FILE XML Documentation file to generate\n" +
198 " -g Generate debugging information\n" +
199 " --fatal Makes errors fatal\n" +
200 " -lib:PATH1,PATH2 Adds the paths to the assembly link path\n" +
201 " -main:class Specified the class that contains the entry point\n" +
202 " -noconfig[+|-] Disables implicit references to assemblies\n" +
203 " -nostdlib[+|-] Does not load core libraries\n" +
204 " -nowarn:W1[,W2] Disables one or more warnings\n" +
205 " -out:FNAME Specifies output file\n" +
206 " --parse Only parses the source file\n" +
207 " --expect-error X Expect that error X will be encountered\n" +
208 " -recurse:SPEC Recursively compiles the files in SPEC ([dir]/file)\n" +
209 " -reference:ASS References the specified assembly (-r:ASS)\n" +
210 " --stacktrace Shows stack trace at error location\n" +
211 " -target:KIND Specifies the target (KIND is one of: exe, winexe,\n" +
212 " library, module), (short: /t:)\n" +
213 " --timestamp Displays time stamps of various compiler events\n" +
214 " -unsafe[+|-] Allows unsafe code\n" +
215 " -warnaserror[+|-] Treat warnings as errors\n" +
216 " -warn:LEVEL Sets warning level (the highest is 4, the default is 2)\n" +
217 " -v Verbose parsing (for debugging the parser)\n" +
218 " -2 Enables experimental C# features\n" +
221 " -linkresource:FILE[,ID] Links FILE as a resource\n" +
222 " -resource:FILE[,ID] Embed FILE as a resource\n" +
223 " --mcs-debug X Sets MCS debugging level to X\n" +
224 " @file Read response file for more options\n\n" +
225 "Options can be of the form -option or /option");
228 static void TargetUsage ()
230 Report.Error (2019, "Valid options for -target: are exe, winexe, library or module");
236 "The Mono C# compiler is (C) 2001, 2002, 2003 Ximian, Inc.\n\n" +
237 "The compiler source code is released under the terms of the GNU GPL\n\n" +
239 "For more information on Mono, visit the project Web site\n" +
240 " http://www.go-mono.com\n\n" +
242 "The compiler was written by Miguel de Icaza, Ravi Pratap and Martin Baulig");
243 Environment.Exit (0);
246 public static int counter1, counter2;
248 public static int Main (string[] args)
250 bool ok = MainDriver (args);
252 if (ok && Report.Errors == 0) {
253 Console.Write("Compilation succeeded");
254 if (Report.Warnings > 0) {
255 Console.Write(" - {0} warning(s)", Report.Warnings);
259 Console.WriteLine ("Counter1: " + counter1);
260 Console.WriteLine ("Counter2: " + counter2);
266 Console.WriteLine("Compilation failed: {0} error(s), {1} warnings",
267 Report.Errors, Report.Warnings);
272 static public void LoadAssembly (string assembly, bool soft)
275 string total_log = "";
278 char[] path_chars = { '/', '\\', '.' };
280 if (assembly.IndexOfAny (path_chars) != -1) {
281 a = Assembly.LoadFrom (assembly);
283 a = Assembly.Load (assembly);
285 TypeManager.AddAssembly (a);
287 } catch (FileNotFoundException){
288 foreach (string dir in link_paths){
289 string full_path = Path.Combine (dir, assembly);
290 if (!assembly.EndsWith (".dll"))
294 a = Assembly.LoadFrom (full_path);
295 TypeManager.AddAssembly (a);
297 } catch (FileNotFoundException ff) {
298 total_log += ff.FusionLog;
303 Report.Error (6, "Cannot find assembly `" + assembly + "'" );
304 Console.WriteLine ("Log: \n" + total_log);
306 } catch (BadImageFormatException f) {
307 Report.Error(6, "Cannot load assembly (bad file format)" + f.FusionLog);
308 } catch (FileLoadException f){
309 Report.Error(6, "Cannot load assembly " + f.FusionLog);
310 } catch (ArgumentNullException){
311 Report.Error(6, "Cannot load assembly (null argument)");
316 /// Loads all assemblies referenced on the command line
318 static public void LoadReferences ()
320 foreach (string r in references)
321 LoadAssembly (r, false);
323 foreach (string r in soft_references)
324 LoadAssembly (r, true);
329 static void SetupDefaultDefines ()
331 defines = new ArrayList ();
332 defines.Add ("__MonoCS__");
335 static string [] LoadArgs (string file)
338 ArrayList args = new ArrayList ();
341 f = new StreamReader (file);
346 StringBuilder sb = new StringBuilder ();
348 while ((line = f.ReadLine ()) != null){
351 for (int i = 0; i < t; i++){
354 if (c == '"' || c == '\''){
357 for (i++; i < t; i++){
364 } else if (c == ' '){
366 args.Add (sb.ToString ());
373 args.Add (sb.ToString ());
378 string [] ret_value = new string [args.Count];
379 args.CopyTo (ret_value, 0);
385 // Returns the directory where the system assemblies are installed
387 static string GetSystemDir ()
389 Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
391 foreach (Assembly a in assemblies){
392 string codebase = a.Location;
393 string fn = System.IO.Path.GetFileName (codebase);
394 if (fn == "corlib.dll" || fn == "mscorlib.dll"){
395 return codebase.Substring (0, codebase.LastIndexOf (System.IO.Path.DirectorySeparatorChar));
399 Report.Error (-15, "Can not compute my system path");
404 // Given a path specification, splits the path from the file/pattern
406 static void SplitPathAndPattern (string spec, out string path, out string pattern)
408 int p = spec.LastIndexOf ('/');
411 // Windows does not like /file.cs, switch that to:
416 pattern = spec.Substring (1);
418 path = spec.Substring (0, p);
419 pattern = spec.Substring (p + 1);
424 p = spec.LastIndexOf ('\\');
426 path = spec.Substring (0, p);
427 pattern = spec.Substring (p + 1);
435 static void ProcessFile (string f)
437 if (first_source == null)
440 Location.AddFile (f);
443 static void ProcessFiles ()
445 Location.Initialize ();
447 foreach (SourceFile file in Location.SourceFiles) {
449 tokenize_file (file);
456 static void CompileFiles (string spec, bool recurse)
458 string path, pattern;
460 SplitPathAndPattern (spec, out path, out pattern);
461 if (pattern.IndexOf ('*') == -1){
466 string [] files = null;
468 files = Directory.GetFiles (path, pattern);
469 } catch (System.IO.DirectoryNotFoundException) {
470 Report.Error (2001, "Source file `" + spec + "' could not be found");
472 } catch (System.IO.IOException){
473 Report.Error (2001, "Source file `" + spec + "' could not be found");
476 foreach (string f in files) {
483 string [] dirs = null;
486 dirs = Directory.GetDirectories (path);
490 foreach (string d in dirs) {
492 // Don't include path in this string, as each
493 // directory entry already does
494 CompileFiles (d + "/" + pattern, true);
498 static void DefineDefaultConfig ()
501 // For now the "default config" is harcoded into the compiler
502 // we can move this outside later
504 string [] default_config = {
509 // Is it worth pre-loading all this stuff?
512 "System.Configuration.Install",
515 "System.DirectoryServices",
516 "System.Drawing.Design",
518 "System.EnterpriseServices",
521 "System.Runtime.Remoting",
522 "System.Runtime.Serialization.Formatters.Soap",
524 "System.ServiceProcess",
526 "System.Web.RegularExpressions",
527 "System.Web.Services",
528 "System.Windows.Forms"
533 foreach (string def in default_config)
534 soft_references.Insert (p++, def);
537 static void SetOutputFile (string name)
542 static void SetWarningLevel (string s)
547 level = Int32.Parse (s);
551 "--wlevel requires a value from 0 to 4");
552 Environment.Exit (1);
554 if (level < 0 || level > 4){
555 Report.Error (1900, "Warning level must be 0 to 4");
556 Environment.Exit (1);
558 RootContext.WarningLevel = level;
559 TestWarningConflict ();
562 static void TestWarningConflict ()
564 if (RootContext.WarningLevel == 0 && Report.WarningsAreErrors) {
565 Report.Error (1901, "Conflicting options specified: Warning level 0; Treat warnings as errors");
566 Environment.Exit (1);
570 static void SetupV2 ()
572 RootContext.V2 = true;
573 defines.Add ("__V2__");
576 static void Version ()
578 string version = Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
579 Console.WriteLine ("Mono C# compiler version {0}", version);
580 Environment.Exit (0);
584 // Currently handles the Unix-like command line options, but will be
585 // deprecated in favor of the CSCParseOption, which will also handle the
586 // options that start with a dash in the future.
588 static bool UnixParseOption (string arg, ref string [] args, ref int i)
592 parser_verbose = true;
607 case "--main": case "-m":
608 if ((i + 1) >= args.Length){
610 Environment.Exit (1);
612 RootContext.MainClass = args [++i];
616 RootContext.Unsafe = true;
619 case "/?": case "/h": case "/help":
622 Environment.Exit (0);
626 if ((i + 1) >= args.Length){
628 Environment.Exit (1);
630 defines.Add (args [++i]);
633 case "--show-counters":
634 show_counters = true;
637 case "--expect-error": {
642 args [++i], NumberStyles.AllowLeadingSign);
643 Report.ExpectedError = code;
645 Report.Error (-14, "Invalid number specified");
656 if ((i + 1) >= args.Length){
658 Environment.Exit (1);
660 SetOutputFile (args [++i]);
664 RootContext.Checked = true;
668 Report.Stacktrace = true;
671 case "--linkresource":
673 if ((i + 1) >= args.Length){
675 Report.Error (5, "Missing argument to --linkres");
676 Environment.Exit (1);
678 if (resources == null)
679 resources = new ArrayList ();
681 resources.Add (args [++i]);
686 if ((i + 1) >= args.Length){
688 Report.Error (5, "Missing argument to --resource");
689 Environment.Exit (1);
691 if (embedded_resources == null)
692 embedded_resources = new ArrayList ();
694 embedded_resources.Add (args [++i]);
698 if ((i + 1) >= args.Length){
699 Environment.Exit (1);
703 string type = args [++i];
706 target = Target.Library;
715 target = Target.WinExe;
719 target = Target.Module;
724 Environment.Exit (1);
730 if ((i + 1) >= args.Length){
732 Environment.Exit (1);
735 references.Add (args [++i]);
739 if ((i + 1) >= args.Length){
741 Environment.Exit (1);
743 link_paths.Add (args [++i]);
747 RootContext.StdLib = false;
755 Report.WarningsAreErrors = true;
756 TestWarningConflict();
760 if ((i + 1) >= args.Length){
762 Environment.Exit (1);
767 warn = Int32.Parse (args [++i]);
770 Environment.Exit (1);
772 Report.SetIgnoreWarning (warn);
776 if ((i + 1) >= args.Length){
779 "--wlevel requires a value from 0 to 4");
780 Environment.Exit (1);
783 SetWarningLevel (args [++i]);
787 if ((i + 1) >= args.Length){
788 Report.Error (5, "--mcs-debug requires an argument");
789 Environment.Exit (1);
793 Report.DebugFlags = Int32.Parse (args [++i]);
795 Report.Error (5, "Invalid argument to --mcs-debug");
796 Environment.Exit (1);
805 if ((i + 1) >= args.Length){
806 Report.Error (5, "--recurse requires an argument");
807 Environment.Exit (1);
809 CompileFiles (args [++i], true);
814 last_time = first_time = DateTime.Now;
821 case "--debug": case "-g":
822 want_debugging_support = true;
826 load_default_config = false;
834 // Currently it is very basic option parsing, but eventually, this will
835 // be the complete option parser
837 static bool CSCParseOption (string option, ref string [] args, ref int i)
839 int idx = option.IndexOf (':');
846 arg = option.Substring (0, idx);
848 value = option.Substring (idx + 1);
863 target = Target.WinExe;
867 target = Target.Library;
872 target = Target.Module;
873 target_ext = ".netmodule";
878 Environment.Exit (1);
886 Environment.Exit (1);
888 SetOutputFile (value);
895 case "/incremental+":
896 case "/incremental-":
906 Environment.Exit (1);
909 defs = value.Split (new Char [] {';', ','});
910 foreach (string d in defs){
917 case "/linkresource":
919 Report.Error (5, arg + " requires an argument");
920 Environment.Exit (1);
922 if (resources == null)
923 resources = new ArrayList ();
925 resources.Add (value);
931 Report.Error (5, arg + " requires an argument");
932 Environment.Exit (1);
934 if (embedded_resources == null)
935 embedded_resources = new ArrayList ();
937 embedded_resources.Add (value);
942 Report.Error (5, "/recurse requires an argument");
943 Environment.Exit (1);
945 CompileFiles (value, true);
951 Report.Error (5, arg + " requires an argument");
952 Environment.Exit (1);
955 string [] refs = value.Split (new char [] { ';', ',' });
956 foreach (string r in refs){
963 Report.Error (5, arg + " requires an argument");
964 Environment.Exit (1);
966 // TODO handle the /doc argument to generate xml doc
973 Report.Error (5, "/lib requires an argument");
974 Environment.Exit (1);
977 libdirs = value.Split (new Char [] { ',' });
978 foreach (string dir in libdirs)
979 link_paths.Add (dir);
985 want_debugging_support = true;
990 RootContext.Checked = true;
994 RootContext.Checked = false;
999 RootContext.Unsafe = true;
1003 RootContext.Unsafe = false;
1006 case "/warnaserror":
1007 case "/warnaserror+":
1008 Report.WarningsAreErrors = true;
1009 TestWarningConflict();
1012 case "/warnaserror-":
1013 Report.WarningsAreErrors = false;
1017 SetWarningLevel (value);
1024 Report.Error (5, "/nowarn requires an argument");
1025 Environment.Exit (1);
1028 warns = value.Split (new Char [] {','});
1029 foreach (string wc in warns){
1031 int warn = Int32.Parse (wc);
1033 throw new ArgumentOutOfRangeException("warn");
1035 Report.SetIgnoreWarning (warn);
1037 Report.Error (1904, String.Format("'{0}' is not a valid warning number", wc));
1038 Environment.Exit (1);
1045 load_default_config = true;
1050 load_default_config = false;
1056 Environment.Exit (0);
1062 Report.Error (5, arg + " requires an argument");
1063 Environment.Exit (1);
1065 RootContext.MainClass = value;
1070 RootContext.StdLib = false;
1074 RootContext.StdLib = true;
1081 Report.Error (5, "/win32icon is currently not supported");
1092 if (value == "utf8"){
1093 encoding = new UTF8Encoding();
1094 using_default_encoder = false;
1097 if (value == "reset"){
1099 // 28591 is the code page for ISO-8859-1 encoding.
1102 using_default_encoder = true;
1106 cp = Int32.Parse (value);
1107 encoding = Encoding.GetEncoding (cp);
1108 using_default_encoder = false;
1110 Report.Error (2016, String.Format("Code page '{0}' is invalid or not installed", cp));
1111 Environment.Exit (1);
1115 //Report.Error (2007, String.Format ("Unrecognized command-line option: '{0}'", option));
1116 //Environment.Exit (1);
1121 /// Parses the arguments, and drives the compilation
1126 /// TODO: Mostly structured to debug the compiler
1127 /// now, needs to be turned into a real driver soon.
1129 // [MonoTODO("Change error code for unknown argument to something reasonable")]
1130 internal static bool MainDriver (string [] args)
1133 bool parsing_options = true;
1136 encoding = Encoding.GetEncoding (28591);
1138 Console.WriteLine ("Error: could not load encoding 28591, trying 1252");
1139 encoding = Encoding.GetEncoding (1252);
1142 references = new ArrayList ();
1143 soft_references = new ArrayList ();
1144 link_paths = new ArrayList ();
1146 SetupDefaultDefines ();
1151 // This is not required because Assembly.Load knows about this
1155 int argc = args.Length;
1156 for (i = 0; i < argc; i++){
1157 string arg = args [i];
1159 if (arg.StartsWith ("@")){
1160 string [] new_args, extra_args;
1161 string response_file = arg.Substring (1);
1163 if (response_file_list == null)
1164 response_file_list = new Hashtable ();
1166 if (response_file_list.Contains (response_file)){
1168 1515, "Response file `" + response_file +
1169 "' specified multiple times");
1170 Environment.Exit (1);
1173 response_file_list.Add (response_file, response_file);
1175 extra_args = LoadArgs (response_file);
1176 if (extra_args == null){
1177 Report.Error (2011, "Unable to open response file: " +
1182 new_args = new string [extra_args.Length + argc];
1183 args.CopyTo (new_args, 0);
1184 extra_args.CopyTo (new_args, argc);
1186 argc = new_args.Length;
1190 if (parsing_options){
1192 parsing_options = false;
1196 if (arg.StartsWith ("-")){
1197 if (UnixParseOption (arg, ref args, ref i))
1201 string csc_opt = "/" + arg.Substring (1);
1202 if (CSCParseOption (csc_opt, ref args, ref i))
1205 if (arg.StartsWith ("/")){
1206 if (CSCParseOption (arg, ref args, ref i))
1212 CompileFiles (arg, false);
1220 if (first_source == null){
1221 Report.Error (2008, "No files to compile were specified");
1225 if (Report.Errors > 0)
1232 // Load Core Library for default compilation
1234 if (RootContext.StdLib)
1235 references.Insert (0, "mscorlib");
1237 if (load_default_config)
1238 DefineDefaultConfig ();
1240 if (Report.Errors > 0){
1245 // Load assemblies required
1248 ShowTime ("Loading references");
1249 link_paths.Add (GetSystemDir ());
1253 ShowTime (" References loaded");
1255 if (Report.Errors > 0){
1262 if (output_file == null){
1263 int pos = first_source.LastIndexOf ('.');
1266 output_file = first_source.Substring (0, pos) + target_ext;
1268 output_file = first_source + target_ext;
1271 CodeGen.Init (output_file, output_file, want_debugging_support);
1273 TypeManager.AddModule (CodeGen.ModuleBuilder);
1275 DateTime start = DateTime.Now;
1276 TypeManager.ComputeNamespaces ();
1277 DateTime end = DateTime.Now;
1280 // Before emitting, we need to get the core
1281 // types emitted from the user defined types
1282 // or from the system ones.
1285 ShowTime ("Initializing Core Types");
1286 if (!RootContext.StdLib){
1287 RootContext.ResolveCore ();
1288 if (Report.Errors > 0)
1292 TypeManager.InitCoreTypes ();
1294 ShowTime (" Core Types done");
1297 // The second pass of the compiler
1300 ShowTime ("Resolving tree");
1301 RootContext.ResolveTree ();
1302 if (Report.Errors > 0)
1305 ShowTime ("Populate tree");
1306 if (!RootContext.StdLib)
1307 RootContext.BootCorlib_PopulateCoreTypes ();
1308 RootContext.PopulateTypes ();
1309 RootContext.DefineTypes ();
1311 TypeManager.InitCodeHelpers ();
1314 // Verify using aliases now
1316 Namespace.VerifyUsing ();
1318 if (Report.Errors > 0){
1323 // The code generator
1326 ShowTime ("Emitting code");
1327 ShowTotalTime ("Total so far");
1328 RootContext.EmitCode ();
1332 if (Report.Errors > 0){
1337 ShowTime ("Closing types");
1339 RootContext.CloseTypes ();
1341 PEFileKinds k = PEFileKinds.ConsoleApplication;
1343 if (target == Target.Library || target == Target.Module){
1344 k = PEFileKinds.Dll;
1346 if (RootContext.MainClass != null)
1347 Report.Error (2017, "Can not specify -main: when building module or library");
1348 } else if (target == Target.Exe)
1349 k = PEFileKinds.ConsoleApplication;
1350 else if (target == Target.WinExe)
1351 k = PEFileKinds.WindowApplication;
1353 if (target == Target.Exe || target == Target.WinExe){
1354 MethodInfo ep = RootContext.EntryPoint;
1357 if (Report.Errors == 0)
1358 Report.Error (5001, "Program " + output_file +
1359 " does not have an entry point defined");
1363 CodeGen.AssemblyBuilder.SetEntryPoint (ep, k);
1367 // Add the resources
1369 if (resources != null){
1370 foreach (string spec in resources){
1374 cp = spec.IndexOf (',');
1376 file = spec.Substring (0, cp);
1377 res = spec.Substring (cp + 1);
1381 CodeGen.AssemblyBuilder.AddResourceFile (res, file);
1385 if (embedded_resources != null){
1386 object[] margs = new object [2];
1387 Type[] argst = new Type [2];
1388 argst [0] = argst [1] = typeof (string);
1390 MethodInfo embed_res = typeof (AssemblyBuilder).GetMethod ("EmbedResourceFile", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic, null, CallingConventions.Any, argst, null);
1391 if (embed_res == null) {
1392 Report.Warning (0, new Location (-1), "Cannot embed resources on this runtime: try the Mono runtime instead.");
1394 foreach (string spec in embedded_resources) {
1397 cp = spec.IndexOf (',');
1399 margs [0] = spec.Substring (cp + 1);
1400 margs [1] = spec.Substring (0, cp);
1402 margs [0] = margs [1] = spec;
1404 if (File.Exists ((string) margs [1]))
1405 embed_res.Invoke (CodeGen.AssemblyBuilder, margs);
1407 Report.Error (1566, "Can not find the resource " + margs [1]);
1413 if (Report.Errors > 0)
1416 CodeGen.Save (output_file);
1418 ShowTime ("Saved output");
1419 ShowTotalTime ("Total");
1422 Timer.ShowTimers ();
1424 if (Report.ExpectedError != 0){
1425 Console.WriteLine("Failed to report expected error " + Report.ExpectedError);
1426 Environment.Exit (1);
1431 Console.WriteLine ("Size of strings held: " + DeclSpace.length);
1432 Console.WriteLine ("Size of strings short: " + DeclSpace.small);
1434 return (Report.Errors == 0);
1440 // This is the only public entry point
1442 public class CompilerCallableEntryPoint : MarshalByRefObject {
1443 static bool used = false;
1445 public bool InvokeCompiler (string [] args)
1449 bool ok = Driver.MainDriver (args);
1450 return ok && Report.Errors == 0;
1453 public void Reset ()