2006-07-16 Marek Safar <marek.safar@seznam.cz>
[mono.git] / mcs / gmcs / driver.cs
index ea82b7486a78d6fdebcc92ab5f6af46198420e4c..4c2f0387f8c78bf4c4439815859d4e9ee146b526 100644 (file)
@@ -16,11 +16,10 @@ namespace Mono.CSharp
        using System.Reflection.Emit;
        using System.Collections;
        using System.Collections.Specialized;
-       using System.Diagnostics;
        using System.IO;
        using System.Text;
        using System.Globalization;
-       using System.Xml;
+       using System.Diagnostics;
 
        public enum Target {
                Library, Exe, Module, WinExe
@@ -988,7 +987,7 @@ namespace Mono.CSharp
                                return true;
 
                        case "/out":
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Usage ();
                                        Environment.Exit (1);
                                }
@@ -1014,7 +1013,7 @@ namespace Mono.CSharp
                        case "/define": {
                                string [] defs;
 
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Usage ();
                                        Environment.Exit (1);
                                }
@@ -1036,7 +1035,7 @@ namespace Mono.CSharp
                        case "/pkg": {
                                string packages;
 
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Usage ();
                                        Environment.Exit (1);
                                }
@@ -1109,7 +1108,7 @@ namespace Mono.CSharp
                                return true;
                                
                        case "/recurse":
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (5, "-recurse requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1118,7 +1117,7 @@ namespace Mono.CSharp
 
                        case "/r":
                        case "/reference": {
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (5, "-reference requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1139,7 +1138,7 @@ namespace Mono.CSharp
                                return true;
                        }
                        case "/addmodule": {
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (5, arg + " requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1151,7 +1150,7 @@ namespace Mono.CSharp
                                return true;
                        }
                        case "/win32res": {
-                               if (value == "") {
+                               if (value.Length == 0) {
                                        Report.Error (5, arg + " requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1160,7 +1159,7 @@ namespace Mono.CSharp
                                return true;
                        }
                        case "/win32icon": {
-                               if (value == "") {
+                               if (value.Length == 0) {
                                        Report.Error (5, arg + " requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1169,7 +1168,7 @@ namespace Mono.CSharp
                                return true;
                        }
                        case "/doc": {
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (2006, arg + " requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1179,7 +1178,7 @@ namespace Mono.CSharp
                        case "/lib": {
                                string [] libdirs;
                                
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (5, "/lib requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1241,7 +1240,7 @@ namespace Mono.CSharp
                        case "/nowarn": {
                                string [] warns;
 
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (5, "/nowarn requires an argument");
                                        Environment.Exit (1);
                                }
@@ -1283,7 +1282,7 @@ namespace Mono.CSharp
 
                        case "/main":
                        case "/m":
-                               if (value == ""){
+                               if (value.Length == 0){
                                        Report.Error (5, arg + " requires an argument");                                        
                                        Environment.Exit (1);
                                }
@@ -1468,7 +1467,7 @@ namespace Mono.CSharp
 
                        for (i = 0; i < args.Length; i++){
                                string arg = args [i];
-                               if (arg == "")
+                               if (arg.Length == 0)
                                        continue;
 
                                if (arg.StartsWith ("@")){
@@ -1610,10 +1609,13 @@ namespace Mono.CSharp
                                int pos = first_source.LastIndexOf ('.');
 
                                if (pos > 0)
-                                       output_file = first_source.Substring (0, pos) + RootContext.TargetExt;
+                                       output_file = first_source.Substring (0, pos);
                                else
-                                       output_file = first_source + RootContext.TargetExt;
+                                       output_file = first_source;
                        }
+                       
+                       if (!Path.HasExtension (output_file))
+                               output_file += RootContext.TargetExt;
 
                        if (!CodeGen.Init (output_file, output_file, want_debugging_support))
                                return false;
@@ -1742,7 +1744,7 @@ namespace Mono.CSharp
 
                                if (ep == null) {
                                        if (RootContext.MainClass != null) {
-                                               DeclSpace main_cont = RootContext.Tree.GetDecl (MemberName.FromDotted (RootContext.MainClass, Location.Null));
+                                               DeclSpace main_cont = RootContext.Tree.Types.GetDefinition (RootContext.MainClass) as DeclSpace;
                                                if (main_cont == null) {
                                                        Report.Error (1555, "Could not find `{0}' specified for Main method", RootContext.MainClass); 
                                                        return false;
@@ -1899,7 +1901,7 @@ namespace Mono.CSharp
 
                        public void Emit ()
                        {
-                               CodeGen.Assembly.Builder.AddResourceFile (name, file, attribute);
+                               CodeGen.Assembly.Builder.AddResourceFile (name, Path.GetFileName(file), attribute);
                        }
 
                        public string FileName {
@@ -1976,6 +1978,8 @@ namespace Mono.CSharp
                        RootNamespace.Reset ();
                        NamespaceEntry.Reset ();
                        CodeGen.Reset ();
+                       Attribute.Reset ();
+                       AttributeTester.Reset ();
                }
        }
 }