X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fdriver.cs;h=f688846d991d93787f8598985831232e4503fdda;hb=b68b65ad17932bbe2d1fd565456063d90e08aaa5;hp=f0f98d2777314a71619382c37cef72b799761634;hpb=b87c7e29df7d04e3199e224c8b8e9a41292cec1b;p=mono.git diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs index f0f98d27773..f688846d991 100644 --- a/mcs/mcs/driver.cs +++ b/mcs/mcs/driver.cs @@ -26,6 +26,12 @@ namespace Mono.CSharp public enum Target { Library, Exe, Module, WinExe }; + +#if GMCS_SOURCE + enum Platform { + AnyCPU, X86, X64, IA64 + }; +#endif /// /// The compiler driver. @@ -237,7 +243,7 @@ namespace Mono.CSharp " -help Lists all compiler options (short: -?)\n" + " -keycontainer:NAME The key pair container used to sign the output assembly\n" + " -keyfile:FILE The key file used to strongname the ouput assembly\n" + - " -langversion:TEXT Specifies language version: ISO-1, ISO-2, Default, or future\n" + + " -langversion:TEXT Specifies language version: ISO-1, ISO-2, Default, or Future\n" + " -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n" + " -main:CLASS Specifies the class with the Main method (short: -m)\n" + " -noconfig Disables implicitly referenced assemblies\n" + @@ -248,6 +254,8 @@ namespace Mono.CSharp #if !SMCS_SOURCE " -pkg:P1[,Pn] References packages P1..Pn\n" + #endif + " -platform:ARCH Specifies the target platform of the output assembly\n" + + " ARCH can be one of: anycpu, x86, x64 or itanium\n" + " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" + " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + @@ -255,7 +263,7 @@ namespace Mono.CSharp " KIND can be one of: exe, winexe, library, module\n" + " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" + " -warnaserror[+|-] Treats all warnings as errors\n" + - " -warnaserror:W1[,Wn] Treats one or more compiler warnings as errors\n" + + " -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors\n" + " -warn:0-4 Sets warning level, the default is 4 (short -w:)\n" + " -help2 Shows internal compiler options\n" + "\n" + @@ -289,24 +297,25 @@ namespace Mono.CSharp public static int Main (string[] args) { - RootContext.Version = LanguageVersion.Default; - Location.InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t"; Driver d = Driver.Create (args, true); if (d == null) return 1; - else if (d.Compile () && Report.Errors == 0) { + if (d.Compile () && Report.Errors == 0) { if (Report.Warnings > 0) { Console.WriteLine ("Compilation succeeded - {0} warning(s)", Report.Warnings); } + Environment.Exit (0); return 0; - } else { - Console.WriteLine("Compilation failed: {0} error(s), {1} warnings", - Report.Errors, Report.Warnings); - return 1; } + + + Console.WriteLine("Compilation failed: {0} error(s), {1} warnings", + Report.Errors, Report.Warnings); + Environment.Exit (1); + return 1; } static public void LoadAssembly (string assembly, bool soft) @@ -402,9 +411,9 @@ namespace Mono.CSharp // Extern aliased refs require special handling if (alias == null) - RootNamespace.Global.AddAssemblyReference (a); + GlobalRootNamespace.Instance.AddAssemblyReference (a); else - RootNamespace.DefineRootNamespace (alias, a); + GlobalRootNamespace.Instance.DefineRootNamespace (alias, a); } catch (BadImageFormatException f) { // .NET 2.0 throws this if we try to load a module without an assembly manifest ... @@ -444,7 +453,7 @@ namespace Mono.CSharp } } - RootNamespace.Global.AddModuleReference (m); + GlobalRootNamespace.Instance.AddModuleReference (m); } catch (BadImageFormatException f) { Error9 ("module", f.FileName, f.FusionLog); @@ -476,7 +485,7 @@ namespace Mono.CSharp foreach (DictionaryEntry entry in external_aliases) LoadAssembly ((string) entry.Value, (string) entry.Key, false); - RootNamespace.ComputeNamespaces (); + GlobalRootNamespace.Instance.ComputeNamespaces (); } static string [] LoadArgs (string file) @@ -779,6 +788,8 @@ namespace Mono.CSharp if (RootContext.Version > LanguageVersion.ISO_2) soft_references.Add ("System.Core"); + if (RootContext.Version > LanguageVersion.V_3) + soft_references.Add ("Microsoft.CSharp"); } public static string OutputFile @@ -982,11 +993,6 @@ namespace Mono.CSharp Report.Fatal = true; return true; - case "--werror": - Report.Warning (-29, 1, "Compatibility: Use -warnaserror: option instead of --werror"); - Report.WarningsAreErrors = true; - return true; - case "--nowarn": Report.Warning (-29, 1, "Compatibility: Use -nowarn instead of --nowarn"); if ((i + 1) >= args.Length){ @@ -1345,6 +1351,11 @@ namespace Mono.CSharp return true; case "/debug": + if (value == "full" || value == "") + want_debugging_support = true; + + return true; + case "/debug+": want_debugging_support = true; return true; @@ -1376,6 +1387,7 @@ namespace Mono.CSharp return true; case "/warnaserror": + case "/warnaserror+": if (value.Length == 0) { Report.WarningsAreErrors = true; } else { @@ -1384,12 +1396,13 @@ namespace Mono.CSharp } return true; - case "/warnaserror+": - Report.WarningsAreErrors = true; - return true; - case "/warnaserror-": - Report.WarningsAreErrors = false; + if (value.Length == 0) { + Report.WarningsAreErrors = false; + } else { + foreach (string wid in value.Split (argument_value_separator)) + Report.RemoveWarningAsError (wid); + } return true; case "/warn": @@ -1426,6 +1439,33 @@ namespace Mono.CSharp load_default_config = false; return true; + case "/platform": +#if GMCS_SOURCE + switch (value.ToLower (CultureInfo.InvariantCulture)) { + case "anycpu": + RootContext.Platform = Platform.AnyCPU; + break; + case "x86": + RootContext.Platform = Platform.X86; + break; + case "x64": + RootContext.Platform = Platform.X64; + break; + case "itanium": + RootContext.Platform = Platform.IA64; + break; + default: + Report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'"); + break; + } +#endif + return true; + + // We just ignore this. + case "/errorreport": + case "/filealign": + return true; + case "/help2": OtherFlags (); Environment.Exit(0); @@ -1491,16 +1531,18 @@ namespace Mono.CSharp RootContext.AddConditional ("__V2__"); #endif return true; -#if GMCS_SOURCE case "iso-2": RootContext.Version = LanguageVersion.ISO_2; return true; + case "3": + RootContext.Version = LanguageVersion.V_3; + return true; case "future": RootContext.Version = LanguageVersion.Future; return true; -#endif } - Report.Error (1617, "Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or `Default'", value); + + Report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or `Default'", value); return true; case "/codepage": @@ -1598,6 +1640,9 @@ namespace Mono.CSharp // public bool Compile () { + // TODO: Should be passed to parser as an argument + RootContext.ToplevelTypes = new ModuleContainer (RootContext.Unsafe); + Parse (); if (Report.Errors > 0) return false; @@ -1641,7 +1686,7 @@ namespace Mono.CSharp set_method.Invoke (CodeGen.Assembly.Builder, BindingFlags.Default, null, new object[]{true}, null); } - RootNamespace.Global.AddModuleReference (CodeGen.Module.Builder); + GlobalRootNamespace.Instance.AddModuleReference (RootContext.ToplevelTypes.Builder); // // Load assemblies required @@ -1667,8 +1712,6 @@ namespace Mono.CSharp if (timestamps) ShowTime (" Core Types done"); - CodeGen.Module.Resolve (); - // // The second pass of the compiler // @@ -1789,7 +1832,7 @@ namespace Mono.CSharp try { CodeGen.Assembly.Builder.DefineUnmanagedResource (win32ResourceFile); } catch (ArgumentException) { - Report.RuntimeMissingSupport (Location.Null, "resource embeding"); + Report.RuntimeMissingSupport (Location.Null, "resource embedding "); } } else { CodeGen.Assembly.Builder.DefineVersionInfoResource (); @@ -1798,7 +1841,7 @@ namespace Mono.CSharp if (win32IconFile != null) { MethodInfo define_icon = typeof (AssemblyBuilder).GetMethod ("DefineIconResource", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (define_icon == null) { - Report.RuntimeMissingSupport (Location.Null, "resource embeding"); + Report.RuntimeMissingSupport (Location.Null, "resource embedding"); } else { define_icon.Invoke (CodeGen.Assembly.Builder, new object [] { win32IconFile }); } @@ -1987,14 +2030,14 @@ namespace Mono.CSharp { Driver.Reset (); RootContext.Reset (full_flag); - Tokenizer.Reset (); Location.Reset (); Report.Reset (); TypeManager.Reset (); + PredefinedAttributes.Reset (); TypeHandle.Reset (); if (full_flag) - RootNamespace.Reset (); + GlobalRootNamespace.Reset (); NamespaceEntry.Reset (); CodeGen.Reset ();