+ # --disable-phase
+ var opt_disable_phase = new OptionArray("Disable a specific phase; use `list` to get the list (debug)", "--disable-phase")
+
+ # --sloppy
+ var opt_sloppy = new OptionBool("Force lazy semantic analysis of the source-code (debug)", "--sloppy")
+
+ redef init
+ do
+ super
+
+ option_context.add_option(opt_disable_phase, opt_sloppy)
+ end
+
+ redef fun process_options(args)
+ do
+ super
+
+ for v in opt_disable_phase.value do
+ if v == "list" then
+ for p in phases_list do
+ var deps = p.in_hierarchy.direct_greaters
+ if deps.is_empty then
+ print p
+ else
+ print "{p} (dep: {deps.join(", ")})"
+ end
+ end
+ exit 0
+ end
+
+ var found = false
+ for p in phases do
+ if v != p.to_s then continue
+ found = true
+ p.disabled = true
+ end
+ if not found then fatal_error(null, "Error: no phase named `{v}`. Use `list` to list all phases.")
+ end
+
+ if opt_sloppy.value then semantize_is_lazy = true
+ end
+
+ # The list of registered phases in the application order.
+ var phases_list: Sequence[Phase] is lazy do
+ var phases = self.phases.to_a
+ self.phases.sort(phases)
+ return phases
+ end
+
+ # Is `phase_process_npropdef` not called automatically by `run_phases`?
+ #
+ # When set to true, it is the responsibility of the tools
+ #
+ # Is false by default.
+ var semantize_is_lazy = false is writable
+
+ # Set of already analyzed modules.
+ private var phased_modules = new HashSet[AModule]
+
+ # List of module to process according to `run_phases`
+ #
+ # This allow some new modules to be found and added while analysing the code.
+ var todo_nmodules: Sequence[AModule]
+