private var type_layout: nullable Layout[MType]
private var resolution_layout: nullable Layout[MType]
- protected var method_layout: nullable PropertyLayout[MMethod]
- protected var attr_layout: nullable PropertyLayout[MAttribute]
+ protected var method_layout: nullable Layout[MMethod]
+ protected var attr_layout: nullable Layout[MAttribute]
init(mainmodule: MModule, mmbuilder: ModelBuilder, runtime_type_analysis: RapidTypeAnalysis) do
super(mainmodule, mmbuilder)
fun do_property_coloring do
var mclasses = new HashSet[MClass].from(modelbuilder.model.mclasses)
+ # Layouts
+ var method_layout_builder: PropertyLayoutBuilder[MMethod]
+ var attribute_layout_builder: PropertyLayoutBuilder[MAttribute]
+ if modelbuilder.toolcontext.opt_bm_typing.value then
+ method_layout_builder = new MMethodBMizer(self.mainmodule)
+ attribute_layout_builder = new MAttributeBMizer(self.mainmodule)
+ else if modelbuilder.toolcontext.opt_phmod_typing.value then
+ method_layout_builder = new MMethodHasher(new PHModOperator, self.mainmodule)
+ attribute_layout_builder = new MAttributeHasher(new PHModOperator, self.mainmodule)
+ else if modelbuilder.toolcontext.opt_phand_typing.value then
+ method_layout_builder = new MMethodHasher(new PHAndOperator, self.mainmodule)
+ attribute_layout_builder = new MAttributeHasher(new PHAndOperator, self.mainmodule)
+ else
+ method_layout_builder = new MMethodColorer(self.mainmodule)
+ attribute_layout_builder = new MAttributeColorer(self.mainmodule)
+ end
+
# methods coloration
- var method_coloring = new CLPropertyLayoutBuilder[MMethod](new MMethodColorer(mainmodule))
- var method_layout = method_coloring.build_layout(mclasses)
+ var method_layout = method_layout_builder.build_layout(mclasses)
self.method_tables = build_method_tables(mclasses, method_layout)
self.compile_color_consts(method_layout.pos)
self.method_layout = method_layout
# attributes coloration
- var attribute_coloring = new CLPropertyLayoutBuilder[MAttribute](new MAttributeColorer(mainmodule))
- var attr_layout = attribute_coloring.build_layout(mclasses)
+ var attr_layout = attribute_layout_builder.build_layout(mclasses)
self.attr_tables = build_attr_tables(mclasses, attr_layout)
self.compile_color_consts(attr_layout.pos)
self.attr_layout = attr_layout
end
- fun build_method_tables(mclasses: Set[MClass], layout: PropertyLayout[MProperty]): Map[MClass, Array[nullable MPropDef]] do
+ fun build_method_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]
return tables
end
- fun build_attr_tables(mclasses: Set[MClass], layout: PropertyLayout[MProperty]): Map[MClass, Array[nullable MPropDef]] do
+ fun build_attr_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]
# Typing Layout
var layout_builder: TypingLayoutBuilder[MType]
if modelbuilder.toolcontext.opt_bm_typing.value then
- layout_builder = new BMTypeLayoutBuilder(self.mainmodule)
+ layout_builder = new MTypeBMizer(self.mainmodule)
else if modelbuilder.toolcontext.opt_phmod_typing.value then
- layout_builder = new PHTypeLayoutBuilder(self.mainmodule, new PHModOperator)
+ layout_builder = new MTypeHasher(new PHModOperator, self.mainmodule)
else if modelbuilder.toolcontext.opt_phand_typing.value then
- layout_builder = new PHTypeLayoutBuilder(self.mainmodule, new PHAndOperator)
+ layout_builder = new MTypeHasher(new PHAndOperator, self.mainmodule)
else
- layout_builder = new CLTypingLayoutBuilder[MType](new MTypeColorer(self.mainmodule))
+ layout_builder = new MTypeColorer(self.mainmodule)
end
# colorize types
# Compute the table layout with the prefered method
var resolution_builder: ResolutionLayoutBuilder
if modelbuilder.toolcontext.opt_bm_typing.value then
- resolution_builder = new BMResolutionLayoutBuilder
+ resolution_builder = new ResolutionBMizer
else if modelbuilder.toolcontext.opt_phmod_typing.value then
- resolution_builder = new PHResolutionLayoutBuilder(new PHModOperator)
+ resolution_builder = new ResolutionHasher(new PHModOperator)
else if modelbuilder.toolcontext.opt_phand_typing.value then
- resolution_builder = new PHResolutionLayoutBuilder(new PHAndOperator)
+ resolution_builder = new ResolutionHasher(new PHAndOperator)
else
- resolution_builder = new CLResolutionLayoutBuilder
+ resolution_builder = new ResolutionColorer
end
self.resolution_layout = resolution_builder.build_layout(mtype2unresolved)
self.resolution_tables = self.build_resolution_tables(mtype2unresolved)
return res
end
+ redef fun supercall(m: MMethodDef, recvtype: MClassType, args: Array[RuntimeVariable]): nullable RuntimeVariable
+ do
+ # FIXME implements a polymorphic access in tables
+ m = m.lookup_next_definition(m.mclassdef.mmodule, m.mclassdef.bound_mtype)
+ return self.call(m, recvtype, args)
+ end
+
redef fun vararg_instance(mpropdef, recv, varargs, elttype)
do
# A vararg must be stored into an new array