Merge: nitc: inject importation
authorJean Privat <jean@pryen.org>
Mon, 6 Feb 2017 13:39:02 +0000 (08:39 -0500)
committerJean Privat <jean@pryen.org>
Mon, 6 Feb 2017 13:39:02 +0000 (08:39 -0500)
commit343b877d9b5dbac0b3848fa4bdf2047f70337f31
tree3d53edd0fa2ed43e94bd570ee44390887f16eacd
parenteb56644e6254978f32bb7d46a06aa9ac2e83a5be
parent2c708a92bc0399113e517a31097d0db03ede0d7b
Merge: nitc: inject importation

Extends the nitc code so a phase can inject new submodules.

The main new method the this PR is `ModelBuilder::inject_module_subimportation` that must be used during the analysis on a module.

Up to now, the module hierarchy was fixed and built by the loader before any phases are run.
The basic way was: 1. load the main module, 2. load its imported modules recursively and build the hierarchy, 3. run the phases on all the loaded modules from the most general to the most specific (top-down)
Now the phases can also extends the module hierarchy while running some phases.
This cause the following changes:
* `run_phase` use a work-list (instead of a simple loop)
* new modules can pop up even for the main module of a program, so a fictive main module is always created
* conditional_importations is extended to be used to by inject_module_subimportation.

Pull-Request: #2357
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>