rta: add_monomorphic_send mark the mproperty as live
[nit.git] / src / modelbuilder.nit
index 1daf410..ef75a3f 100644 (file)
@@ -43,28 +43,52 @@ redef class ToolContext
        # Option --only-parse
        var opt_only_parse: OptionBool = new OptionBool("Only proceed to parse step of loaders", "--only-parse")
 
+       # Option --ignore-visibility
+       var opt_ignore_visibility: OptionBool = new OptionBool("Do not check, and produce errors, on visibility issues.", "--ignore-visibility")
+
        redef init
        do
                super
-               option_context.add_option(opt_path, opt_only_parse, opt_only_metamodel)
+               option_context.add_option(opt_path, opt_only_parse, opt_only_metamodel, opt_ignore_visibility)
        end
 
        fun modelbuilder: ModelBuilder do return modelbuilder_real.as(not null)
        private var modelbuilder_real: nullable ModelBuilder = null
 
-       fun run_global_phases(mainmodule: MModule)
+       # Run `process_mainmodule` on all phases
+       fun run_global_phases(mmodules: Array[MModule])
        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, "<main>", new Location(null, 0, 0, 0, 0))
+                       mainmodule.set_imported_mmodules(mmodules)
+               end
                for phase in phases_list do
-                       phase.process_mainmodule(mainmodule)
+                       if phase.disabled then continue
+                       phase.process_mainmodule(mainmodule, mmodules)
                end
        end
 end
 
 redef class Phase
-       # Specific action to execute on the whole program
-       # Called by the `ToolContext::run_global_phases`
+       # Specific action to execute on the whole program.
+       # Called by the `ToolContext::run_global_phases`.
+       #
+       # `mainmodule` is the main module of the program.
+       # It could be an implicit module (called "<main>").
+       #
+       # `given_modules` is the list of explicitely requested modules.
+       # from the command-line for instance.
+       #
+       # REQUIRE: `not given_modules.is_empty`
+       # REQUIRE: `(given_modules.length == 1) == (mainmodule == given_modules.first)`
+       #
        # @toimplement
-       fun process_mainmodule(mainmodule: MModule) do end
+       fun process_mainmodule(mainmodule: MModule, given_mmodules: SequenceRead[MModule]) do end
 end