- redef fun compile_class_names do
- # Build type names table
- var type_array = new Array[nullable MClass]
- for t, i in class_ids do
- if i >= type_array.length then
- type_array[i] = null
+ fun build_vt_tables(mclasses: Set[MClass], layout: Layout[MProperty]): 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]
+ # first, fill table from parents by reverse linearization order
+ var parents = self.mainmodule.super_mclasses(mclass)
+ var lin = self.mainmodule.reverse_linearize_mclasses(parents)
+ for parent in lin do
+ for mproperty in self.mainmodule.properties(parent) do
+ if not mproperty isa MVirtualTypeProp then continue
+ var color = layout.pos[mproperty]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ for mpropdef in mproperty.mpropdefs do
+ if mpropdef.mclassdef.mclass == parent then
+ table[color] = mpropdef
+ end
+ end
+ end
+ end
+
+ # then override with local properties
+ for mproperty in self.mainmodule.properties(mclass) do
+ if not mproperty isa MVirtualTypeProp then continue
+ var color = layout.pos[mproperty]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ for mpropdef in mproperty.mpropdefs do
+ if mpropdef.mclassdef.mclass == mclass then
+ table[color] = mpropdef
+ end
+ end