A map-like structure to associate E toMModule

The advantage of this class is the various lookup_* method that allow to retrieve values trough the importation relation.

Introduced properties

fun [](mmodule: MModule): nullable E

nitc :: MModuleData :: []

The value locally defined in mmodule.
fun []=(mmodule: MModule, value: nullable E)

nitc :: MModuleData :: []=

Set the value locally defined in mmodule.
private var _defs: HashMap[MModule, E]

nitc :: MModuleData :: _defs

private var _model: Model

nitc :: MModuleData :: _model

The model associated with the data
private fun defs: HashMap[MModule, E]

nitc :: MModuleData :: defs

private fun defs=(defs: HashMap[MModule, E])

nitc :: MModuleData :: defs=

fun has_mmodule(mmodule: MModule): Bool

nitc :: MModuleData :: has_mmodule

is a value locally defined in mmodule
fun lookup_all_modules(mmodule: MModule, min_visibility: MVisibility): Sequence[MModule]

nitc :: MModuleData :: lookup_all_modules

Return all the super modules that defines a value
fun lookup_all_values(mmodule: MModule, min_visibility: MVisibility): Sequence[E]

nitc :: MModuleData :: lookup_all_values

Return all the values defined in mmodule and its imported modules.
fun lookup_first_value(mmodule: MModule, min_visibility: MVisibility): nullable E

nitc :: MModuleData :: lookup_first_value

Return the most specific values defined in mmodule and its imported modules.
fun lookup_values(mmodule: MModule, min_visibility: MVisibility): Sequence[E]

nitc :: MModuleData :: lookup_values

Return the most specific values defined in mmodule and its imported modules.
fun model: Model

nitc :: MModuleData :: model

The model associated with the data
protected fun model=(model: Model)

nitc :: MModuleData :: model=

The model associated with the data

Redefined properties

redef type SELF: MModuleData[E]

nitc $ MModuleData :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun [](mmodule: MModule): nullable E

nitc :: MModuleData :: []

The value locally defined in mmodule.
fun []=(mmodule: MModule, value: nullable E)

nitc :: MModuleData :: []=

Set the value locally defined in mmodule.
private var _defs: HashMap[MModule, E]

nitc :: MModuleData :: _defs

private var _model: Model

nitc :: MModuleData :: _model

The model associated with the data
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
private fun defs: HashMap[MModule, E]

nitc :: MModuleData :: defs

private fun defs=(defs: HashMap[MModule, E])

nitc :: MModuleData :: defs=

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun has_mmodule(mmodule: MModule): Bool

nitc :: MModuleData :: has_mmodule

is a value locally defined in mmodule
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun lookup_all_modules(mmodule: MModule, min_visibility: MVisibility): Sequence[MModule]

nitc :: MModuleData :: lookup_all_modules

Return all the super modules that defines a value
fun lookup_all_values(mmodule: MModule, min_visibility: MVisibility): Sequence[E]

nitc :: MModuleData :: lookup_all_values

Return all the values defined in mmodule and its imported modules.
fun lookup_first_value(mmodule: MModule, min_visibility: MVisibility): nullable E

nitc :: MModuleData :: lookup_first_value

Return the most specific values defined in mmodule and its imported modules.
fun lookup_values(mmodule: MModule, min_visibility: MVisibility): Sequence[E]

nitc :: MModuleData :: lookup_values

Return the most specific values defined in mmodule and its imported modules.
fun model: Model

nitc :: MModuleData :: model

The model associated with the data
protected fun model=(model: Model)

nitc :: MModuleData :: model=

The model associated with the data
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::MModuleData MModuleData core::Object Object nitc::MModuleData->core::Object nitc::MModuleMultiData MModuleMultiData nitc::MModuleMultiData->nitc::MModuleData

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

class MModuleMultiData[E: nullable Object]

nitc :: MModuleMultiData

A MModuleData where multiples values could be set on a single module

Class definitions

nitc $ MModuleData
# 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