Build a conflict graph from a POSet

Introduced properties

private var _border: HashSet[E]

nitc :: POSetConflictGraph :: _border

Border is composed by minimal elements of the core:
private var _conflicts: HashMap[E, Set[E]]

nitc :: POSetConflictGraph :: _conflicts

Conflict graph of the POSet
private var _core: HashSet[E]

nitc :: POSetConflictGraph :: _core

Core is composed by:
private var _crown: HashSet[E]

nitc :: POSetConflictGraph :: _crown

The crown is composed by the elements that are:
private var _order: Array[E]

nitc :: POSetConflictGraph :: _order

The linearisation order to visit elements in the poset
private var _poset: POSet[E]

nitc :: POSetConflictGraph :: _poset

The associated poset
private fun add_conflict(e: E, o: E)

nitc :: POSetConflictGraph :: add_conflict

fun border: HashSet[E]

nitc :: POSetConflictGraph :: border

Border is composed by minimal elements of the core:
protected fun border=(border: HashSet[E])

nitc :: POSetConflictGraph :: border=

Border is composed by minimal elements of the core:
private fun compute_conflicts

nitc :: POSetConflictGraph :: compute_conflicts

Check for conflict in the core.
fun conflicts: HashMap[E, Set[E]]

nitc :: POSetConflictGraph :: conflicts

Conflict graph of the POSet
protected fun conflicts=(conflicts: HashMap[E, Set[E]])

nitc :: POSetConflictGraph :: conflicts=

Conflict graph of the POSet
fun core: HashSet[E]

nitc :: POSetConflictGraph :: core

Core is composed by:
protected fun core=(core: HashSet[E])

nitc :: POSetConflictGraph :: core=

Core is composed by:
fun crown: HashSet[E]

nitc :: POSetConflictGraph :: crown

The crown is composed by the elements that are:
protected fun crown=(crown: HashSet[E])

nitc :: POSetConflictGraph :: crown=

The crown is composed by the elements that are:
private fun extract_border

nitc :: POSetConflictGraph :: extract_border

Compute the set of elements composing the border of the core
private fun extract_core

nitc :: POSetConflictGraph :: extract_core

Compute the set of elements forming the core of the poset hierarchy.
private fun extract_crown

nitc :: POSetConflictGraph :: extract_crown

Compute the set of elements belonging to the crown of the inheritance hierarchy.
private fun is_border(e: E): Bool

nitc :: POSetConflictGraph :: is_border

fun order: Array[E]

nitc :: POSetConflictGraph :: order

The linearisation order to visit elements in the poset
protected fun order=(order: Array[E])

nitc :: POSetConflictGraph :: order=

The linearisation order to visit elements in the poset
fun poset: POSet[E]

nitc :: POSetConflictGraph :: poset

The associated poset
protected fun poset=(poset: POSet[E])

nitc :: POSetConflictGraph :: poset=

The associated poset
fun pretty_print

nitc :: POSetConflictGraph :: pretty_print

Used for debugging only

Redefined properties

redef type SELF: POSetConflictGraph[E]

nitc $ POSetConflictGraph :: SELF

Type of this instance, automatically specialized in every class
redef init init

nitc $ POSetConflictGraph :: init

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
private var _border: HashSet[E]

nitc :: POSetConflictGraph :: _border

Border is composed by minimal elements of the core:
private var _conflicts: HashMap[E, Set[E]]

nitc :: POSetConflictGraph :: _conflicts

Conflict graph of the POSet
private var _core: HashSet[E]

nitc :: POSetConflictGraph :: _core

Core is composed by:
private var _crown: HashSet[E]

nitc :: POSetConflictGraph :: _crown

The crown is composed by the elements that are:
private var _order: Array[E]

nitc :: POSetConflictGraph :: _order

The linearisation order to visit elements in the poset
private var _poset: POSet[E]

nitc :: POSetConflictGraph :: _poset

The associated poset
private fun add_conflict(e: E, o: E)

nitc :: POSetConflictGraph :: add_conflict

fun border: HashSet[E]

nitc :: POSetConflictGraph :: border

Border is composed by minimal elements of the core:
protected fun border=(border: HashSet[E])

nitc :: POSetConflictGraph :: border=

Border is composed by minimal elements of the core:
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 compute_conflicts

nitc :: POSetConflictGraph :: compute_conflicts

Check for conflict in the core.
fun conflicts: HashMap[E, Set[E]]

nitc :: POSetConflictGraph :: conflicts

Conflict graph of the POSet
protected fun conflicts=(conflicts: HashMap[E, Set[E]])

nitc :: POSetConflictGraph :: conflicts=

Conflict graph of the POSet
fun core: HashSet[E]

nitc :: POSetConflictGraph :: core

Core is composed by:
protected fun core=(core: HashSet[E])

nitc :: POSetConflictGraph :: core=

Core is composed by:
fun crown: HashSet[E]

nitc :: POSetConflictGraph :: crown

The crown is composed by the elements that are:
protected fun crown=(crown: HashSet[E])

nitc :: POSetConflictGraph :: crown=

The crown is composed by the elements that are:
private fun extract_border

nitc :: POSetConflictGraph :: extract_border

Compute the set of elements composing the border of the core
private fun extract_core

nitc :: POSetConflictGraph :: extract_core

Compute the set of elements forming the core of the poset hierarchy.
private fun extract_crown

nitc :: POSetConflictGraph :: extract_crown

Compute the set of elements belonging to the crown of the inheritance hierarchy.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
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".
private fun is_border(e: E): Bool

nitc :: POSetConflictGraph :: is_border

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.
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 order: Array[E]

nitc :: POSetConflictGraph :: order

The linearisation order to visit elements in the poset
protected fun order=(order: Array[E])

nitc :: POSetConflictGraph :: order=

The linearisation order to visit elements in the poset
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 poset: POSet[E]

nitc :: POSetConflictGraph :: poset

The associated poset
protected fun poset=(poset: POSet[E])

nitc :: POSetConflictGraph :: poset=

The associated poset
fun pretty_print

nitc :: POSetConflictGraph :: pretty_print

Used for debugging 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::POSetConflictGraph POSetConflictGraph core::Object Object nitc::POSetConflictGraph->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitc $ POSetConflictGraph
# Build a conflict graph from a POSet
class POSetConflictGraph[E]

	# Core is composed by:
	#  * elements that have mutiple direct parents
	#  * parents of elements that have multiple direct parents
	# REQUIRE: is_colored
	var core = new HashSet[E]

	# Border is composed by minimal elements of the core:
	#  * that have multiple direct parents
	#  * but whose subelements are all in single inheritance
	# REQUIRE: is_colored
	var border = new HashSet[E]

	# The crown is composed by the elements that are:
	#  * not part of the core nor the border
	#  * are in single inheritance
	# REQUIRE: is_colored
	var crown = new HashSet[E]

	# Conflict graph of the POSet
	# Elements X and Y are in conflict if either:
	#  * X and Y are the same element
	#  * Y is a subelement of X
	#  * X and Y have common sub elements
	# REQUIRE: is_colored
	var conflicts = new HashMap[E, Set[E]]

	# The associated poset
	var poset: POSet[E]

	# The linearisation order to visit elements in the poset
	var order: Array[E] is noinit

	init do
		extract_core
		extract_border
		extract_crown
		compute_conflicts
		order = poset.linearize(poset)
	end

	# Compute the set of elements forming the core of the poset hierarchy.
	private fun extract_core do
		core.clear
		for e in poset do
			if poset[e].direct_greaters.length > 1 then
				core.add_all(poset[e].greaters)
			end
		end
	end

	# Compute the set of elements composing the border of the core
	# Elements belonging to the `border` are removed from the `core`
	private fun extract_border do
		border.clear
		for e in core do
			if not is_border(e) then continue
			border.add(e)
		end
		for e in border do core.remove(e)
	end

	private fun is_border(e: E): Bool do
		for child in poset[e].direct_smallers do
			if core.has(child) then return false
		end
		return true
	end

	# Compute the set of elements belonging to the crown of the inheritance hierarchy.
	private fun extract_crown do
		crown.clear
		for e in poset do
			if not core.has(e) and not border.has(e) then crown.add(e)
		end
	end

	# Check for conflict in the core.
	# Start from border and tag every ancestors
	private fun compute_conflicts do
		conflicts.clear
		for e in border do add_conflicts(poset[e].greaters)
	end

	private fun add_conflict(e, o: E) do
		if not conflicts.has_key(e) then conflicts[e] = new HashSet[E]
		if not conflicts.has_key(o) then conflicts[o] = new HashSet[E]
		conflicts[e].add(o)
		conflicts[o].add(e)
	end

	private fun add_conflicts(es: Collection[E]) do
		for e1 in es do
			for e2 in es do add_conflict(e1, e2)
		end
	end

	# Used for debugging only
	fun pretty_print do
		#print "core: {core.join(" ")} ({core.length})"
		#print "border: {border.join(" ")} ({border.length})"
		#print "crown: {crown.join(" ")} ({crown.length})"
		print "conflicts:"
		for e, c in conflicts do print "  {e or else "NULL"}: {c.join(" ")}"
	end
end
src/compiler/coloring.nit:19,1--126,3