nitg: add option -m for mix-in modules
authorJean Privat <jean@pryen.org>
Wed, 4 Sep 2013 14:08:11 +0000 (10:08 -0400)
committerJean Privat <jean@pryen.org>
Wed, 4 Sep 2013 17:15:11 +0000 (13:15 -0400)
because super is not yet polymorph in nitg-s, the test nitg_args6 is
not saved

Signed-off-by: Jean Privat <jean@pryen.org>

src/nitg.nit
tests/nitg.args
tests/niti.skip
tests/sav/nitg.res
tests/sav/nitg_args5.res [new file with mode: 0644]

index 636b0b4..1341b0f 100644 (file)
@@ -32,6 +32,9 @@ var toolcontext = new ToolContext
 var opt_global = new OptionBool("Use global compilation", "--global")
 toolcontext.option_context.add_option(opt_global)
 
+var opt_mixins = new OptionArray("Additionals module to min-in", "-m")
+toolcontext.option_context.add_option(opt_mixins)
+
 # We do not add other options, so process them now!
 toolcontext.process_options
 
@@ -54,13 +57,19 @@ var progname = arguments.first
 
 # Here we load an process all modules passed on the command line
 var mmodules = modelbuilder.parse([progname])
+mmodules.add_all modelbuilder.parse(opt_mixins.value)
 
 if mmodules.is_empty then return
 modelbuilder.run_phases
 
-# Here we launch the interpreter on the main module
-assert mmodules.length == 1
-var mainmodule = mmodules.first
+var mainmodule
+if mmodules.length == 1 then
+       mainmodule = mmodules.first
+else
+       mainmodule = new MModule(model, null, mmodules.first.name, mmodules.first.location)
+       mainmodule.set_imported_mmodules(mmodules)
+end
+
 var analysis = modelbuilder.do_rapid_type_analysis(mainmodule)
 
 if toolcontext.opt_erasure.value then
index 1f1e8d5..ac3c10d 100644 (file)
@@ -2,3 +2,5 @@
 --global base_simple3.nit -o out/nitg-base_simple3 ; out/nitg-base_simple3
 --separate ../examples/hello_world.nit -o out/nitgs-hello_world ; out/nitgs-hello_world
 --separate base_simple3.nit -o out/nitgs-base_simple3 ; out/nitgs-base_simple3
+--global ../examples/hello_world.nit -m test_mixin.nit -o out/nitg-hello_world_mixed ; out/nitg-hello_world_mixed
+--separate ../examples/hello_world.nit -m test_mixin.nit -o out/nitgs-hello_world_mixed ; out/nitgs-hello_world_mixed
index e107b9e..535a964 100644 (file)
@@ -10,3 +10,5 @@ nit_args3
 nitc_args1
 nitg_args1
 nitg_args3
+nitg_args5
+nitg_args6
index 5f5c45f..bcfe38c 100644 (file)
@@ -33,3 +33,4 @@
   --erasure                   Erase generic types
   --no-check-erasure-cast     Disable implicit casts on unsafe return with erasure-typing policy (dangerous)
   --global                    Use global compilation
+  -m                          Additionals module to min-in
diff --git a/tests/sav/nitg_args5.res b/tests/sav/nitg_args5.res
new file mode 100644 (file)
index 0000000..c76ebf3
--- /dev/null
@@ -0,0 +1,3 @@
+MIX: Before
+MIX: hello world
+MIX: After