+ # Build type tables
+ fun build_class_typing_tables(mclasses: Set[MClass], colors: Map[MClass, Int], colorer: ClassColoring): Map[MClass, Array[nullable MClass]] do
+ var tables = new HashMap[MClass, Array[nullable MClass]]
+
+ for mclasse in mclasses do
+ var table = new Array[nullable MClass]
+ var supers = new HashSet[MClass]
+ supers.add_all(colorer.super_elements(mclasse, mclasses))
+ supers.add(mclasse)
+ 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
+ end
+ table[color] = sup
+ end
+ tables[mclasse] = table
+ end
+ return tables
+ end
+
+ # Build type tables
+ fun hash_class_typing_tables(mtypes: Set[MClass], ids: Map[MClass, Int], masks: Map[MClass, Int], colorer: ClassPerfectHashing): Map[MClass, Array[nullable MClass]] do
+ var tables = new HashMap[MClass, Array[nullable MClass]]
+
+ for mtype in mtypes do
+ var table = new Array[nullable MClass]
+ var supers = new HashSet[MClass]
+ supers.add_all(colorer.super_elements(mtype, mtypes))
+ supers.add(mtype)
+
+ for sup in supers do
+ var color = colorer.phash(ids[sup], masks[mtype])
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end
+ end
+ table[color] = sup
+ end
+ tables[mtype] = table
+ end
+ return tables
+ end
+