nmodules.add(mmodule2nmodule[mm])
end
toolcontext.run_phases(nmodules)
+
+ if toolcontext.opt_only_metamodel.value then
+ self.toolcontext.info("*** ONLY METAMODEL", 1)
+ exit(0)
+ end
end
# Instantiate a modelbuilder for a model and a toolcontext
end
# Load a bunch of modules.
- # `modules' can contains filenames or module names.
+ # `modules` can contains filenames or module names.
# Imported modules are automatically loaded and modelized.
# The result is the corresponding model elements.
# Errors and warnings are printed with the toolcontext.
self.toolcontext.info("*** END PARSE: {time1-time0} ***", 2)
self.toolcontext.check_errors
+
+ if toolcontext.opt_only_parse.value then
+ self.toolcontext.info("*** ONLY PARSE...", 1)
+ exit(0)
+ end
+
return mmodules
end
- # Return a class named `name' visible by the module `mmodule'.
+ # Return a class named `name` visible by the module `mmodule`.
# Visibility in modules is correctly handled.
# If no such a class exists, then null is returned.
- # If more than one class exists, then an error on `anode' is displayed and null is returned.
+ # If more than one class exists, then an error on `anode` is displayed and null is returned.
# FIXME: add a way to handle class name conflict
fun try_get_mclass_by_name(anode: ANode, mmodule: MModule, name: String): nullable MClass
do
return res
end
- # Return a property named `name' on the type `mtype' visible in the module `mmodule'.
+ # Return a property named `name` on the type `mtype` visible in the module `mmodule`.
# Visibility in modules is correctly handled.
# Protected properties are returned (it is up to the caller to check and reject protected properties).
# If no such a property exists, then null is returned.
- # If more than one property exists, then an error on `anode' is displayed and null is returned.
+ # If more than one property exists, then an error on `anode` is displayed and null is returned.
# FIXME: add a way to handle property name conflict
fun try_get_mproperty_by_name2(anode: ANode, mmodule: MModule, mtype: MType, name: String): nullable MProperty
do
var paths: Array[String] = new Array[String]
# Get a module by its short name; if required, the module is loaded, parsed and its hierarchies computed.
- # If `mmodule' is set, then the module search starts from it up to the top level (see `paths');
- # if `mmodule' is null then the module is searched in the top level only.
- # If no module exists or there is a name conflict, then an error on `anode' is displayed and null is returned.
+ # If `mmodule` is set, then the module search starts from it up to the top level (see `paths`);
+ # if `mmodule` is null then the module is searched in the top level only.
+ # If no module exists or there is a name conflict, then an error on `anode` is displayed and null is returned.
# FIXME: add a way to handle module name conflict
fun get_mmodule_by_name(anode: ANode, mmodule: nullable MModule, name: String): nullable MModule
do
var mod_name = aimport.n_name.n_id.text
var sup = self.get_mmodule_by_name(aimport.n_name, mmodule, mod_name)
if sup == null then continue # Skip error
+ aimport.mmodule = sup
imported_modules.add(sup)
var mvisibility = aimport.n_visibility.mvisibility
+ if mvisibility == protected_visibility then
+ error(aimport.n_visibility, "Error: only properties can be protected.")
+ return
+ end
mmodule.set_visibility_for(sup, mvisibility)
end
if stdimport then
var nmodules: Array[AModule] = new Array[AModule]
# Register the nmodule associated to each mmodule
- # FIXME: why not refine the MModule class with a nullable attribute?
+ # FIXME: why not refine the `MModule` class with a nullable attribute?
var mmodule2nmodule: HashMap[MModule, AModule] = new HashMap[MModule, AModule]
# Helper function to display an error on a node.
- # Alias for `self.toolcontext.error(n.hot_location, text)'
+ # Alias for `self.toolcontext.error(n.hot_location, text)`
fun error(n: ANode, text: String)
do
self.toolcontext.error(n.hot_location, text)
end
# Helper function to display a warning on a node.
- # Alias for: `self.toolcontext.warning(n.hot_location, text)'
+ # Alias for: `self.toolcontext.warning(n.hot_location, text)`
fun warning(n: ANode, text: String)
do
self.toolcontext.warning(n.hot_location, text)
end
- # Force to get the primitive method named `name' on the type `recv' or do a fatal error on `n'
- fun force_get_primitive_method(n: ANode, name: String, recv: MType, mmodule: MModule): MMethod
+ # Force to get the primitive method named `name` on the type `recv` or do a fatal error on `n`
+ fun force_get_primitive_method(n: ANode, name: String, recv: MClass, mmodule: MModule): MMethod
do
var res = mmodule.try_get_primitive_method(name, recv)
if res == null then
end
end
+redef class AStdImport
+ # The imported module once determined
+ var mmodule: nullable MModule = null
+end
+
redef class AModule
- # The associated MModule once build by a `ModelBuilder'
+ # The associated MModule once build by a `ModelBuilder`
var mmodule: nullable MModule
# Flag that indicate if the importation is already completed
var is_importation_done: Bool = false