[svn] r5966: nemerle/trunk/ncc: CompilationOptions.n generation/HierarchyEmitter.n testsuite/positive/main...

malekith svnadmin at nemerle.org
Wed Nov 23 15:50:57 CET 2005


Log:
Add the -main option.

Author: malekith
Date: Wed Nov 23 15:50:55 2005
New Revision: 5966

Added:
   nemerle/trunk/ncc/testsuite/positive/main.n
Modified:
   nemerle/trunk/ncc/CompilationOptions.n
   nemerle/trunk/ncc/generation/HierarchyEmitter.n

Modified: nemerle/trunk/ncc/CompilationOptions.n
==============================================================================
--- nemerle/trunk/ncc/CompilationOptions.n	(original)
+++ nemerle/trunk/ncc/CompilationOptions.n	Wed Nov 23 15:50:55 2005
@@ -59,6 +59,7 @@
     public mutable IndentationSyntax : bool;
     // do not unload external libraries in consecutive compilations
     public mutable PersistentLibraries : bool; 
+    public mutable MainClass : string;
 
     public mutable LinkedResources : list [string];
     public mutable EmbeddedResources : list [string];
@@ -113,6 +114,7 @@
       Sources = [];
       disabled_keywords.Clear ();
       CommandDefines = Map ();
+      MainClass = null;
     }
 
     /// default null value for [in_namespace] means that keyword 
@@ -580,6 +582,11 @@
 
         Getopt.CliOption.Flag (name = "-stats", aliases = [], help = "NOHELP",
                                handler = fun () { Stats.DoPrintStats = true; }),
+
+        Getopt.CliOption.String (name = "-main", 
+                                 aliases = [], 
+                                 help = "Specify the class that contains the entry point",
+                                 handler = fun (s) { Options.MainClass = s; })
       ]
     }
   }

Modified: nemerle/trunk/ncc/generation/HierarchyEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/HierarchyEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/HierarchyEmitter.n	Wed Nov 23 15:50:55 2005
@@ -640,7 +640,9 @@
         Util.cassert (mb != null, $"method builder is null for $this");
 
         /* update the entry point settings, if necessary */
-        when (emitter._need_entry_point && Name == "Main") {
+        when (emitter._need_entry_point && Name == "Main" &&
+              (Options.MainClass == null ||
+               declaring_type.FullName == Options.MainClass)) {
           def has_correct_signature () {
             mb.IsStatic &&
             (ReturnType.Equals (InternalType.Int32) || 

Added: nemerle/trunk/ncc/testsuite/positive/main.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/positive/main.n	Wed Nov 23 15:50:55 2005
@@ -0,0 +1,12 @@
+// OPTIONS: -main:A.B.C
+
+namespace A {
+  namespace B {
+    class X {
+      public static Main () : void { }
+    }
+    class C {
+      public static Main () : void { }
+    }
+  }
+}



More information about the svn mailing list