From 942c28dd31d24598206eca9d3e333bf6b2de5e4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 31 Mar 2015 16:10:23 -0400 Subject: [PATCH] model: intro `MModule::first_real_mmodule` to get the first non-fictive module MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- src/compiler/abstract_compiler.nit | 11 ++--------- src/model/mmodule.nit | 10 ++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) 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 -- 1.7.9.5