end
# Build type tables
- private fun build_type_tables(mtypes: Set[T], colors: Map[T, Int]): Map[T, Array[nullable T]] do
+ fun build_type_tables(mtypes: Set[T], colors: Map[T, Int]): Map[T, Array[nullable T]] do
var tables = new HashMap[T, Array[nullable T]]
for mtype in mtypes do
end
end
+class NaiveTypeColoring
+ super TypeColoring
+
+ init(mainmodule: MModule, mtypes: Set[T]) do
+ super(mainmodule, mtypes)
+ end
+
+ # naive coloring that use incremental coloring
+ redef fun colorize_elements(elements) do
+ for e in elements do
+ self.coloration_result[e] = self.coloration_result.length
+ end
+ end
+end
+
# A sorter for linearize list of types
private class TypeSorter
super AbstractSorter[MType]
end
# Build type tables
- private fun build_type_tables(mclasses: Array[T], colors: Map[T, Int]): Map[T, Array[nullable T]] do
+ fun build_type_tables(mclasses: Array[T], colors: Map[T, Int]): Map[T, Array[nullable T]] do
var tables = new HashMap[T, Array[nullable T]]
for mclasse in mclasses do
end
end
+# incremental coloring (very naive)
+class NaiveClassColoring
+ super ClassColoring
+
+ init(mainmodule: MModule) do
+ super(mainmodule)
+ end
+
+ # naive coloring that use incremental coloring
+ redef fun colorize_elements(elements: Collection[MClass]) do
+ for e in elements do
+ self.coloration_result[e] = self.coloration_result.length
+ end
+ end
+end
+
# A sorter for linearize list of classes
private class ClassSorter
super AbstractSorter[MClass]
self.class_coloring = class_coloring
end
- private fun colorize: Map[MPROP, Int] do
+ fun colorize: Map[MPROP, Int] do
colorize_core_properties
colorize_crown_properties
return self.coloration_result
end
- private fun build_property_tables: Map[MClass, Array[nullable MPROPDEF]] do
+ fun build_property_tables: Map[MClass, Array[nullable MPROPDEF]] do
var tables = new HashMap[MClass, Array[nullable MPROPDEF]]
for mclass in self.class_coloring.coloration_result.keys do
redef type MPROP: MMethod
redef type MPROPDEF: MMethodDef
+ init(class_coloring: ClassColoring) do end
end
# MAttribute coloring
redef type MPROP: MAttribute
redef type MPROPDEF: MAttributeDef
+ init(class_coloring: ClassColoring) do end
end
# MVirtualTypeProp coloring
redef type MPROP: MVirtualTypeProp
redef type MPROPDEF: MVirtualTypeDef
+ init(class_coloring: ClassColoring) do end
end
# MParameterType coloring
self.class_coloring = class_coloring
end
- private fun colorize: Map[MParameterType, Int] do
+ fun colorize: Map[MParameterType, Int] do
colorize_core_properties
colorize_crown_properties
return self.coloration_result
return fts_cache[mclass]
end
- private fun build_ft_tables: Map[MClass, Array[nullable MParameterType]] do
+ fun build_ft_tables: Map[MClass, Array[nullable MParameterType]] do
var tables = new HashMap[MClass, Array[nullable MParameterType]]
for mclass in self.class_coloring.coloration_result.keys do
end
# Build type tables
- private fun build_livetype_tables(mtypes: Set[MType]): Map[MClass, Array[nullable Object]] do
+ fun build_livetype_tables(mtypes: Set[MType]): Map[MClass, Array[nullable Object]] do
var livetypes_tables = new HashMap[MClass, Array[nullable Object]]
self.livetypes_tables_sizes = new HashMap[MClass, Array[Int]]
private fun add_conflict(mtype: MType, otype: MType) do
if mtype == otype then return
- if not self.conflicts_graph_cache.has_key(mtype) then self.conflicts_graph_cache[mtype] = new HashSet[MClassType]
+ if not self.conflicts_graph_cache.has_key(mtype) then self.conflicts_graph_cache[mtype] = new HashSet[MType]
self.conflicts_graph_cache[mtype].add(otype)
- if not self.conflicts_graph_cache.has_key(otype) then self.conflicts_graph_cache[otype] = new HashSet[MClassType]
+ if not self.conflicts_graph_cache.has_key(otype) then self.conflicts_graph_cache[otype] = new HashSet[MType]
self.conflicts_graph_cache[otype].add(mtype)
end
private fun conflicts_graph: Map[MType, Set[MType]] do return conflicts_graph_cache.as(not null)