Try to load a module using a path.

Display an error if there is a problem (IO / lexer / parser) and return null. Note: usually, you do not need this method, use get_mmodule_by_name instead.

The MModule is located, created, parsed and the importation is performed.

Property definitions

nitc :: loader $ ModelBuilder :: load_module
	# Try to load a module using a path.
	# Display an error if there is a problem (IO / lexer / parser) and return null.
	# Note: usually, you do not need this method, use `get_mmodule_by_name` instead.
	#
	# The MModule is located, created, parsed and the importation is performed.
	fun load_module(filename: String): nullable AModule
	do
		# Look for the module
		var mmodule = identify_module(filename)
		if mmodule == null then
			var le = last_loader_error
			if le != null then
				toolcontext.error(null, le)
			else if filename.file_exists then
				toolcontext.error(null, "Error: `{filename}` is not a Nit source file.")
			else
				toolcontext.error(null, "Error: cannot find module `{filename}`.")
			end
			return null
		end

		# Load it
		return mmodule.load(self)
	end
src/loader.nit:736,2--759,4