Run all registered phases on a set of modules

Property definitions

nitc :: phase $ ToolContext :: run_phases
	# Run all registered phases on a set of modules
	fun run_phases(nmodules: Collection[AModule])
	do
		var time0 = get_time
		self.info("*** SEMANTIC ANALYSIS ***", 1)
		#phases.show_dot

		var phases = phases_list

		for phase in phases do
			self.info(" registered phases: {phase}", 2)
		end

		var todo_nmodules = nmodules.to_a
		self.todo_nmodules = todo_nmodules

		while not todo_nmodules.is_empty do
			var nmodule = todo_nmodules.shift
			if phased_modules.has(nmodule) then continue
			phased_modules.add nmodule

			self.info("Semantic analysis module {nmodule.location.file.filename}", 2)

			var vannot = new AnnotationPhaseVisitor
			vannot.enter_visit(nmodule)

			for phase in phases do
				if phase.disabled then continue
				assert phase.toolcontext == self
				var errcount = self.error_count
				phase.process_nmodule(nmodule)
				if errcount != self.error_count then
					self.check_errors
				end
				errcount = self.error_count
				for nclassdef in nmodule.n_classdefs do
					assert phase.toolcontext == self
					phase.process_nclassdef(nclassdef)
					if not semantize_is_lazy then for npropdef in nclassdef.n_propdefs do
						assert phase.toolcontext == self
						phase_process_npropdef(phase, npropdef)
					end
				end
				if errcount != self.error_count then
					self.check_errors
				end
				for na in vannot.annotations do
					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
				end
				phase.process_nmodule_after(nmodule)
			end
			self.check_errors
		end

		var time1 = get_time
		self.info("*** END SEMANTIC ANALYSIS: {time1-time0} ***", 2)

		self.check_errors
	end
src/phase.nit:94,2--158,4