From: Alexis Laferrière Date: Tue, 31 Mar 2015 20:10:23 +0000 (-0400) Subject: model: intro `MModule::first_real_mmodule` to get the first non-fictive module X-Git-Tag: v0.7.4~42^2~5 X-Git-Url: http://nitlanguage.org model: intro `MModule::first_real_mmodule` to get the first non-fictive module Signed-off-by: Alexis Laferrière --- diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 43fd172..011b146 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -300,15 +300,8 @@ class MakefileToolchain # Get the default name of the executable to produce fun default_outname: String do - var mainmodule = compiler.mainmodule - - # Search a non fictive module - var res = mainmodule.name - while mainmodule.is_fictive do - mainmodule = mainmodule.in_importation.direct_greaters.first - res = mainmodule.name - end - return res + var mainmodule = compiler.mainmodule.first_real_mmodule + return mainmodule.name end # Combine options and platform informations to get the final path of the outfile diff --git a/src/model/mmodule.nit b/src/model/mmodule.nit index d88a0ba..ef548a8 100644 --- a/src/model/mmodule.nit +++ b/src/model/mmodule.nit @@ -243,5 +243,15 @@ class MModule # Is `self` a unit test module used by `nitunit`? var is_test_suite: Bool = false is writable + # Get the first non `is_fictive` module greater than self + fun first_real_mmodule: MModule + do + var mmodule = self + while mmodule.is_fictive do + mmodule = mmodule.in_importation.direct_greaters.first + end + return mmodule + end + redef fun parent_concern do return mgroup end