return coloration_result
end
- fun build_tables(elements: Map[MClassType, Set[MType]]): Map[MClassType, Array[nullable MType]] do
- var tables = new HashMap[MClassType, Array[nullable MType]]
-
- for mclasstype, mtypes in elements do
- var table = new Array[nullable MType]
- for mtype in mtypes do
- var color = self.coloration_result[mtype]
- if table.length <= color then
- for i in [table.length .. color[ do
- table[i] = null
- end
- end
- table[color] = mtype
- end
- tables[mclasstype] = table
- end
- return tables
- end
-
# Colorize a collection of elements
fun colorize_elements(elements: Map[MClassType, Set[MType]]) do
var min_color = 0
return mask
end
- redef fun build_tables(elements: Map[MClassType, Set[MType]]): Map[MClassType, Array[nullable MType]] do
- var tables = new HashMap[MClassType, Array[nullable MType]]
-
- for mclasstype, mtypes in elements do
- var table = new Array[nullable MType]
- for mtype in mtypes do
- var color = phash(self.coloration_result[mtype], masks[mclasstype])
- if table.length <= color then
- for i in [table.length .. color[ do
- table[i] = null
- end
- end
- table[color] = mtype
- end
- tables[mclasstype] = table
- end
- return tables
- end
-
private fun op(mask: Int, id:Int): Int is abstract
private fun phash(id: Int, mask: Int): Int do return op(mask, id)
end
if modelbuilder.toolcontext.opt_bm_typing.value then
var unanchored_type_coloring = new NaiveUnanchoredTypeColoring
self.unanchored_types_colors = unanchored_type_coloring.colorize(mtype2unanchored)
- self.unanchored_types_tables = unanchored_type_coloring.build_tables(mtype2unanchored)
+ self.unanchored_types_tables = self.build_resolution_tables(mtype2unanchored)
else if modelbuilder.toolcontext.opt_phmod_typing.value then
var unanchored_type_coloring = new UnanchoredTypeModPerfectHashing
self.unanchored_types_colors = unanchored_type_coloring.colorize(mtype2unanchored)
self.unanchored_types_masks = unanchored_type_coloring.compute_masks(mtype2unanchored)
- self.unanchored_types_tables = unanchored_type_coloring.build_tables(mtype2unanchored)
+ self.unanchored_types_tables = self.hash_resolution_tables(mtype2unanchored, unanchored_type_coloring)
else if modelbuilder.toolcontext.opt_phand_typing.value then
var unanchored_type_coloring = new UnanchoredTypeAndPerfectHashing
self.unanchored_types_colors = unanchored_type_coloring.colorize(mtype2unanchored)
self.unanchored_types_masks = unanchored_type_coloring.compute_masks(mtype2unanchored)
- self.unanchored_types_tables = unanchored_type_coloring.build_tables(mtype2unanchored)
+ self.unanchored_types_tables = self.hash_resolution_tables(mtype2unanchored, unanchored_type_coloring)
else
var unanchored_type_coloring = new UnanchoredTypeColoring
self.unanchored_types_colors = unanchored_type_coloring.colorize(mtype2unanchored)
- self.unanchored_types_tables = unanchored_type_coloring.build_tables(mtype2unanchored)
+ self.unanchored_types_tables = self.build_resolution_tables(mtype2unanchored)
end
# Compile a C constant for each collected unanchored type.
#print ""
end
+ fun build_resolution_tables(elements: Map[MClassType, Set[MType]]): Map[MClassType, Array[nullable MType]] do
+ var tables = new HashMap[MClassType, Array[nullable MType]]
+
+ for mclasstype, mtypes in elements do
+ var table = new Array[nullable MType]
+ for mtype in mtypes do
+ var color = self.unanchored_types_colors[mtype]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ table[color] = mtype
+ end
+ tables[mclasstype] = table
+ end
+ return tables
+ end
+
+ fun hash_resolution_tables(elements: Map[MClassType, Set[MType]], colorer: UnanchoredTypePerfectHashing): Map[MClassType, Array[nullable MType]] do
+ var tables = new HashMap[MClassType, Array[nullable MType]]
+
+ for mclasstype, mtypes in elements do
+ var table = new Array[nullable MType]
+ for mtype in mtypes do
+ var color = colorer.phash(self.unanchored_types_colors[mtype], self.unanchored_types_masks[mclasstype])
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ table[color] = mtype
+ end
+ tables[mclasstype] = table
+ end
+ return tables
+ end
+
fun retieve_live_partial_types(mtype: MType) do
# add formal types arguments to mtypes
if mtype isa MGenericType then