nitc :: MModuleData
E
toMModule
The advantage of this class is the various lookup_*
method that
allow to retrieve values trough the importation relation.
nitc :: MModuleData :: defaultinit
nitc :: MModuleData :: has_mmodule
is a value locally defined inmmodule
nitc :: MModuleData :: lookup_all_modules
Return all the super modules that defines a valuenitc :: MModuleData :: lookup_all_values
Return all the values defined inmmodule
and its imported modules.
nitc :: MModuleData :: lookup_first_value
Return the most specific values defined inmmodule
and its imported modules.
nitc :: MModuleData :: lookup_values
Return the most specific values defined inmmodule
and its imported modules.
nitc $ MModuleData :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: MModuleData :: defaultinit
core :: Object :: defaultinit
nitc :: MModuleData :: has_mmodule
is a value locally defined inmmodule
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: MModuleData :: lookup_all_modules
Return all the super modules that defines a valuenitc :: MModuleData :: lookup_all_values
Return all the values defined inmmodule
and its imported modules.
nitc :: MModuleData :: lookup_first_value
Return the most specific values defined inmmodule
and its imported modules.
nitc :: MModuleData :: lookup_values
Return the most specific values defined inmmodule
and its imported modules.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).MModuleData
where multiples values could be set on a single module
# A map-like structure to associate `E` to` MModule`
# The advantage of this class is the various `lookup_*` method that
# allow to retrieve values trough the importation relation.
class MModuleData[E: Object]
# The model associated with the data
# Used to execute correclty mmodule-related operation
var model: Model
# is a value locally defined in `mmodule`
fun has_mmodule(mmodule: MModule): Bool
do
return defs.has_key(mmodule)
end
# The value locally defined in `mmodule`.
# Return null if no value locally defined.
fun [](mmodule: MModule): nullable E
do
return defs.get_or_null(mmodule)
end
# Set the value locally defined in `mmodule`.
# Gining `null` just undefine the value
fun []=(mmodule: MModule, value: nullable E)
do
if value == null then
defs.keys.remove(mmodule)
else
defs[mmodule] = value
end
end
private var defs = new HashMap[MModule, E]
# Return all the super modules that defines a value
# `min_visibility` is used to filter modules by their visibility in `mmodule`.
fun lookup_all_modules(mmodule: MModule, min_visibility: MVisibility): Sequence[MModule]
do
var res = new Array[MModule]
for m in mmodule.in_importation.greaters do
if mmodule.visibility_for(m) < min_visibility then continue
if self.defs.has_key(m) then res.add(m)
end
return res
end
# Return all the values defined in `mmodule` and its imported modules.
# `min_visibility` is used to filter modules by their visibility in `mmodule`.
# This method could be usefull to check possible static conflicts.
fun lookup_all_values(mmodule: MModule, min_visibility: MVisibility): Sequence[E]
do
var mmodules = lookup_all_modules(mmodule, min_visibility)
mmodules = model.mmodule_importation_hierarchy.linearize(mmodules)
var res = new Array[E]
for m in mmodules do res.add defs[m]
return res
end
# Return the most specific values defined in `mmodule` and its imported modules.
# `min_visibility_` is used to filter modules by their visibility in `mmodule`.
# Unlike `lookup_all_values`, redefined values are hidden,
# However, in case of conflit, all conflicting definitions are returned
fun lookup_values(mmodule: MModule, min_visibility: MVisibility): Sequence[E]
do
var mmodules = lookup_all_modules(mmodule, min_visibility)
mmodules = model.mmodule_importation_hierarchy.select_smallest(mmodules)
var res = new Array[E]
for m in mmodules do res.add defs[m]
return res
end
# Return the most specific values defined in `mmodule` and its imported modules.
# Unlike `lookup_values`, only the most specific value, according to importation, is returned.
fun lookup_first_value(mmodule: MModule, min_visibility: MVisibility): nullable E
do
var mmodules = lookup_all_modules(mmodule, min_visibility)
if mmodules.is_empty then return null
mmodules = model.mmodule_importation_hierarchy.linearize(mmodules)
return defs[mmodules.last]
end
end
src/model/mmodule_data.nit:22,1--102,3