# --disable-phase
var opt_disable_phase = new OptionArray("DEBUG: Disable a specific phase; use `list` to get the list.", "--disable-phase")
+ # --disable-phase
+ var opt_sloppy = new OptionBool("DEBUG: force lazy semantic analysis of the source-code", "--sloppy")
+
redef init
do
super
- option_context.add_option(opt_disable_phase)
+ option_context.add_option(opt_disable_phase, opt_sloppy)
end
redef fun process_options(args)
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.
- fun phases_list: Sequence[Phase]
- do
+ 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]
for nclassdef in nmodule.n_classdefs do
assert phase.toolcontext == self
phase.process_nclassdef(nclassdef)
- for npropdef in nclassdef.n_propdefs do
+ if not semantize_is_lazy then for npropdef in nclassdef.n_propdefs do
assert phase.toolcontext == self
phase_process_npropdef(phase, npropdef)
end
break
end
for na in vannot.annotations do
- phase.process_annotated_node(na.parent.parent.as(not null), na)
+ var p = na.parent
+ if p isa AAnnotations then p = p.parent
+ assert p != null
+ phase.process_annotated_node(p, na)
end
if errcount != self.error_count then
self.check_errors
do
phase.process_npropdef(npropdef)
end
+
+ # Run the phase on the given npropdef.
+ # Does nothing if `semantize_is_lazy` is false.
+ fun run_phases_on_npropdef(npropdef: APropdef)
+ do
+ if not semantize_is_lazy then return
+ if npropdef.is_phased then return
+ npropdef.is_phased = true
+
+ #self.info("Semantic analysis of property {npropdef.location.file.filename}", 0)
+
+ var phases = phases_list
+ for phase in phases do
+ if phase.disabled then continue
+ assert phase.toolcontext == self
+ phase_process_npropdef(phase, npropdef)
+ self.check_errors
+ end
+ end
+end
+
+redef class APropdef
+ # Is the propdef already analyzed by `run_phases_on_npropdef`.
+ # Unused unless `semantize_is_lazy` is true.
+ private var is_phased = false
end
# Collect all annotation