- fun retieve_live_partial_types(mtype: MType) do
- # add formal types arguments to mtypes
- if mtype isa MGenericType then
- for ft in mtype.arguments do
- if ft.need_anchor then
- print("Why do we need anchor here ?")
- abort
- end
- self.partial_types.add(ft)
- retieve_live_partial_types(ft)
- end
- end
- var mclass_type: MClassType
- if mtype isa MNullableType then
- mclass_type = mtype.mtype.as(MClassType)
- else
- mclass_type = mtype.as(MClassType)
- end
-
- # add virtual types to mtypes
- for vt in self.vt_tables[mclass_type.mclass] do
- if vt != null then
- var anchored = vt.bound.anchor_to(self.mainmodule, mclass_type)
- self.partial_types.add(anchored)
- end
- end
- end
-
- # declare live generic types tables selection
- private fun compile_live_gentype_to_c(mclass: MClass) do
- if mclass.arity > 0 then
- if self.livetypes_tables.has_key(mclass) then
- var table = self.livetypes_tables[mclass]
- var sign = self.livetypes_tables_sizes[mclass]
- var table_buffer = new Buffer.from("const struct type *livetypes_{mclass.c_name}[{sign.join("][")}] = \{\n")
- compile_livetype_table(table, table_buffer, 1, mclass.arity)
- table_buffer.append("\};")
-
- var v = new SeparateCompilerVisitor(self)
- self.header.add_decl("extern const struct type *livetypes_{mclass.c_name}[{sign.join("][")}];")
- v.add_decl(table_buffer.to_s)
- else
- var sign = new Array[Int].filled_with(0, mclass.arity)
- var v = new SeparateCompilerVisitor(self)
- self.header.add_decl("extern const struct type *livetypes_{mclass.c_name}[{sign.join("][")}];")
- v.add_decl("const struct type *livetypes_{mclass.c_name}[{sign.join("][")}];")
- end
- end
- end
-
- private fun compile_livetype_table(table: Array[nullable Object], buffer: Buffer, depth: Int, max: Int) do
- for obj in table do
- if obj == null then
- if depth == max then
- buffer.append("NULL,\n")
- else
- buffer.append("\{\},\n")
+ 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 = opentype_colors[mtype]
+ if table.length <= color then
+ for i in [table.length .. color[ do
+ table[i] = null
+ end