modelbuilder: always create a main fictive module
authorJean Privat <jean@pryen.org>
Tue, 31 Jan 2017 19:24:58 +0000 (14:24 -0500)
committerJean Privat <jean@pryen.org>
Thu, 2 Feb 2017 18:51:14 +0000 (13:51 -0500)
This simplify the logic and the number of assumptions.

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

src/modelbuilder.nit

index 100aef1..a924c63 100644 (file)
@@ -38,17 +38,13 @@ redef class ToolContext
        do
                assert not mmodules.is_empty
                var mainmodule
-               if mmodules.length == 1 then
-                       mainmodule = mmodules.first
-               else
-                       # We need a main module, so we build it by importing all modules
-                       mainmodule = new MModule(modelbuilder.model, null, mmodules.first.name + "-m", new Location(mmodules.first.location.file, 0, 0, 0, 0))
-                       mainmodule.is_fictive = true
-                       mainmodule.first_real_mmodule = mmodules.first.first_real_mmodule
-                       mainmodule.set_imported_mmodules(mmodules)
-                       modelbuilder.apply_conditional_importations(mainmodule)
-                       modelbuilder.run_phases
-               end
+               # We need a main module, so we build it by importing all modules
+               mainmodule = new MModule(modelbuilder.model, null, mmodules.first.name + "-m", new Location(mmodules.first.location.file, 0, 0, 0, 0))
+               mainmodule.is_fictive = true
+               mainmodule.first_real_mmodule = mmodules.first.first_real_mmodule
+               mainmodule.set_imported_mmodules(mmodules)
+               modelbuilder.apply_conditional_importations(mainmodule)
+               modelbuilder.run_phases
                return mainmodule
        end