X-Git-Url: http://nitlanguage.org diff --git a/src/compiler/coloring.nit b/src/compiler/coloring.nit index ed9b466..b2f4837 100644 --- a/src/compiler/coloring.nit +++ b/src/compiler/coloring.nit @@ -47,8 +47,7 @@ class POSetConflictGraph[E: Object] var poset: POSet[E] - init(poset: POSet[E]) do - self.poset = poset + init do extract_core extract_border extract_crown @@ -125,6 +124,8 @@ end # Two elements from a POSet cannot have the same color if they share common subelements # # Example: +# +# ~~~raw # A # / | \ # / | \ @@ -135,22 +136,26 @@ end # E F G # | # H +# ~~~ +# # Conflicts: -# A: {B, C, D, E, F, G, H} -# B: {A, C, E, H} -# C: {A, E, H, F} -# D: {A, G} -# E: {A, B, C, H} -# F: {A, C} -# G: {A, D} -# H: {A, B, C, E} +# +# * A: {B, C, D, E, F, G, H} +# * B: {A, C, E, H} +# * C: {A, E, H, F} +# * D: {A, G} +# * E: {A, B, C, H} +# * F: {A, C} +# * G: {A, D} +# * H: {A, B, C, E} +# # Possible colors: -# A:0, B:1, C: 2, D: 1, E: 3, F:3, G:2, H:4 # -# see: -# Ducournau, R. (2011). -# Coloring, a versatile technique for implementing object-oriented languages. -# Software: Practice and Experience, 41(6), 627–659. +# * A:0, B:1, C: 2, D: 1, E: 3, F:3, G:2, H:4 +# +# see: Ducournau, R. (2011). +# Coloring, a versatile technique for implementing object-oriented languages. +# Software: Practice and Experience, 41(6), 627–659. class POSetColorer[E: Object] # Is the poset already colored? @@ -279,8 +284,6 @@ class BucketsColorer[H: Object, E: Object] private var colors = new HashMap[E, Int] private var conflicts = new HashMap[E, Set[E]] - init do end - # Start bucket coloring fun colorize(buckets: Map[H, Set[E]]): Map[E, Int] do compute_conflicts(buckets) @@ -333,11 +336,6 @@ class POSetBucketsColorer[H: Object, E: Object] private var poset: POSet[H] private var conflicts: Map[H, Set[H]] - init(poset: POSet[H], conflicts: Map[H, Set[H]]) do - self.poset = poset - self.conflicts = conflicts - end - # Colorize buckets using the POSet and conflict graph fun colorize(buckets: Map[H, Set[E]]): Map[E, Int] do colors.clear