private var unanchored_types_tables: nullable Map[MClassType, Array[nullable MType]]
private var unanchored_types_masks: nullable Map[MClassType, Int]
- protected var class_coloring: ClassColoring
-
protected var method_colors: Map[MMethod, Int]
protected var method_tables: Map[MClass, Array[nullable MMethodDef]]
# classes coloration
var mclasses = new HashSet[MClass].from(modelbuilder.model.mclasses)
- self.class_coloring = new ClassColoring(mainmodule)
+ var class_coloring = new ClassColoring(mainmodule)
class_coloring.colorize(mclasses)
# methods coloration
- var method_coloring = new MethodColoring(self.class_coloring)
+ var method_coloring = new MethodColoring(class_coloring)
self.method_colors = method_coloring.colorize
self.method_tables = method_coloring.build_property_tables
self.compile_color_consts(self.method_colors)
# attributes coloration
- var attribute_coloring = new AttributeColoring(self.class_coloring)
+ var attribute_coloring = new AttributeColoring(class_coloring)
self.attr_colors = attribute_coloring.colorize
self.attr_tables = attribute_coloring.build_property_tables
self.compile_color_consts(self.attr_colors)
- if modelbuilder.toolcontext.opt_bm_typing.value then
- self.class_coloring = new NaiveClassColoring(mainmodule)
- self.class_coloring.colorize(mclasses)
- end
-
# vt coloration
if modelbuilder.toolcontext.opt_bm_typing.value then
- var vt_coloring = new NaiveVTColoring(self.class_coloring)
+ var vt_coloring = new NaiveVTColoring(class_coloring)
self.vt_colors = vt_coloring.colorize
self.vt_tables = vt_coloring.build_property_tables
else if modelbuilder.toolcontext.opt_phmod_typing.value then
- var vt_coloring = new VTModPerfectHashing(self.class_coloring)
+ var vt_coloring = new VTModPerfectHashing(class_coloring)
self.vt_colors = vt_coloring.colorize
self.vt_masks = vt_coloring.compute_masks
self.vt_tables = vt_coloring.build_property_tables
else if modelbuilder.toolcontext.opt_phand_typing.value then
- var vt_coloring = new VTAndPerfectHashing(self.class_coloring)
+ var vt_coloring = new VTAndPerfectHashing(class_coloring)
self.vt_colors = vt_coloring.colorize
self.vt_masks = vt_coloring.compute_masks
self.vt_tables = vt_coloring.build_property_tables
else
- var vt_coloring = new VTColoring(self.class_coloring)
+ var vt_coloring = new VTColoring(class_coloring)
self.vt_colors = vt_coloring.colorize
self.vt_tables = vt_coloring.build_property_tables
end
self.compile_unanchored_tables(mtypes)
# colorize types
- var type_layout = self.type_layout_builder.build_layout(mtypes)
- if type_layout isa PHTypeLayout then
- self.type_tables = self.hash_type_tables(mtypes, type_layout.hashes)
- else
- self.type_tables = self.build_type_tables(mtypes, type_layout.pos)
- end
- self.type_layout = type_layout
+ self.type_layout = self.type_layout_builder.build_layout(mtypes)
+ self.type_tables = self.build_type_tables(mtypes)
return mtypes
end
# Build type tables
- fun build_type_tables(mtypes: Set[MType], colors: Map[MType, Int]): Map[MType, Array[nullable MType]] do
+ fun build_type_tables(mtypes: Set[MType]): Map[MType, Array[nullable MType]] do
var tables = new HashMap[MType, Array[nullable MType]]
-
+ var layout = self.type_layout
for mtype in mtypes do
var table = new Array[nullable MType]
var supers = new HashSet[MType]
supers.add_all(self.mainmodule.super_mtypes(mtype, mtypes))
supers.add(mtype)
for sup in supers do
- var color = colors[sup]
- if table.length <= color then
- for i in [table.length .. color[ do
- table[i] = null
- end
+ var color: Int
+ if layout isa PHTypeLayout then
+ color = layout.hashes[mtype][sup]
+ else
+ color = layout.pos[sup]
end
- table[color] = sup
- end
- tables[mtype] = table
- end
- return tables
- end
-
- # Build type tables
- fun hash_type_tables(mtypes: Set[MType], hashes: Map[MType, Map[MType, Int]]): Map[MType, Array[nullable MType]] do
- var tables = new HashMap[MType, Array[nullable MType]]
-
- for mtype in mtypes do
- var table = new Array[nullable MType]
- var supers = hashes[mtype]
- for sup, color in supers do
if table.length <= color then
for i in [table.length .. color[ do
table[i] = null