# Transform relative paths (starting with '../') into absolute paths
private fun module_absolute_path(path: String): String do
- if path.has_prefix("..") then
- return getcwd.join_path(path).simplify_path
- end
- return path
+ return getcwd.join_path(path).simplify_path
end
- # loaded module by absolute path
- private var loaded_nmodules = new HashMap[String, AModule]
-
# Try to load a module AST using a path.
# Display an error if there is a problem (IO / lexer / parser) and return null
fun load_module_ast(filename: String): nullable AModule
return null
end
- var module_path = module_absolute_path(filename)
- if loaded_nmodules.keys.has(module_path) then
- return loaded_nmodules[module_path]
- end
-
self.toolcontext.info("load module {filename}", 2)
# Load the file
return null
end
- loaded_nmodules[module_path] = nmodule
return nmodule
end
# Update the file information
file.mmodule = mmodule
+ # Load imported module
+ build_module_importation(nmodule)
+
return nmodule
end
end
# Visit the AST and create the `MModule` object
- # Then, recursively load imported modules
private fun build_a_mmodule(mgroup: nullable MGroup, mod_name: String, nmodule: AModule): nullable MModule
do
# Check the module name
nmodules.add(nmodule)
self.mmodule2nmodule[mmodule] = nmodule
- build_module_importation(nmodule)
-
return mmodule
end
error(aimport.n_visibility, "Error: only properties can be protected.")
return
end
+ if sup == mmodule then
+ error(aimport.n_name, "Error: Dependency loop in module {mmodule}.")
+ end
+ if sup.in_importation < mmodule then
+ error(aimport.n_name, "Error: Dependency loop between modules {mmodule} and {sup}.")
+ return
+ end
mmodule.set_visibility_for(sup, mvisibility)
end
if stdimport then