- var attribute_coloring = new AttributeColoring(self.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(modelbuilder.model.mclasses)
- end
-
- # vt coloration
- if modelbuilder.toolcontext.opt_bm_typing.value then
- var vt_coloring = new NaiveVTColoring(self.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)
- 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)
- 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)
- self.vt_colors = vt_coloring.colorize
- self.vt_tables = vt_coloring.build_property_tables
+ var attr_colorer = new POSetBucketsColorer[MClass, MAttribute](poset, colorer.conflicts)
+ attr_colors = attr_colorer.colorize(mattributes)
+ attr_tables = build_attr_tables(mclasses)
+ compile_color_consts(attr_colors)
+ end
+
+ fun build_method_tables(mclasses: Set[MClass], super_calls: Set[MMethodDef]): Map[MClass, Array[nullable MPropDef]] do
+ var tables = new HashMap[MClass, Array[nullable MPropDef]]
+ for mclass in mclasses do
+ var table = new Array[nullable MPropDef]
+ tables[mclass] = table
+
+ var mproperties = self.mainmodule.properties(mclass)
+ var mtype = mclass.intro.bound_mtype
+
+ for mproperty in mproperties do
+ if not mproperty isa MMethod then continue
+ if not method_colors.has_key(mproperty) then continue
+ var color = method_colors[mproperty]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ table[color] = mproperty.lookup_first_definition(mainmodule, mtype)
+ end
+
+ for supercall in super_calls do
+ if not mtype.collect_mclassdefs(mainmodule).has(supercall.mclassdef) then continue
+
+ var color = method_colors[supercall]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ var mmethoddef = supercall.lookup_next_definition(mainmodule, mtype)
+ table[color] = mmethoddef
+ end
+
+ end
+ return tables
+ end
+
+ fun build_attr_tables(mclasses: Set[MClass]): Map[MClass, Array[nullable MPropDef]] do
+ var tables = new HashMap[MClass, Array[nullable MPropDef]]
+ for mclass in mclasses do
+ var table = new Array[nullable MPropDef]
+ tables[mclass] = table
+
+ var mproperties = self.mainmodule.properties(mclass)
+ var mtype = mclass.intro.bound_mtype
+
+ for mproperty in mproperties do
+ if not mproperty isa MAttribute then continue
+ if not attr_colors.has_key(mproperty) then continue
+ var color = attr_colors[mproperty]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ table[color] = mproperty.lookup_first_definition(mainmodule, mtype)
+ end