type MPROP: MProperty
type MPROPDEF: MPropDef
+ private var mmodule: MModule
private var class_coloring: ClassColoring
private var coloration_result: Map[MPROP, Int] = new HashMap[MPROP, Int]
- init(class_coloring: ClassColoring) do
+ init(mmodule: MModule, class_coloring: ClassColoring) do
+ self.mmodule = mmodule
self.class_coloring = class_coloring
end
return max_color
end
- # properties cache
- private var properties_cache: Map[MClass, Set[MPROP]] = new HashMap[MClass, Set[MPROP]]
-
# All 'mproperties' associated to all 'mclassdefs' of the class
private fun properties(mclass: MClass): Set[MPROP] do
- if not self.properties_cache.has_key(mclass) then
- var properties = new HashSet[MPROP]
- var parents = self.class_coloring.mmodule.super_mclasses(mclass)
- for parent in parents do
- properties.add_all(self.properties(parent))
- end
-
- for mclassdef in mclass.mclassdefs do
- for mpropdef in mclassdef.mpropdefs do
- var mproperty = mpropdef.mproperty
- if mproperty isa MPROP then
- properties.add(mproperty)
- end
- end
- end
- self.properties_cache[mclass] = properties
+ var properties = new HashSet[MPROP]
+ for mprop in self.mmodule.properties(mclass) do
+ if mprop isa MPROP then properties.add(mprop)
end
- return properties_cache[mclass]
+ return properties
end
end
redef type MPROP: MMethod
redef type MPROPDEF: MMethodDef
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
end
# MAttribute coloring
redef type MPROP: MAttribute
redef type MPROPDEF: MAttributeDef
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
end
# MVirtualTypeProp coloring
redef type MPROP: MVirtualTypeProp
redef type MPROPDEF: MVirtualTypeDef
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
end
class NaiveVTColoring
super VTColoring
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
redef fun colorize: Map[MPROP, Int] do
var mclasses = new HashSet[MClass]
private var masks: Map[MClass, Int] = new HashMap[MClass, Int]
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
redef fun colorize: Map[MPROP, Int] do
var mclasses = new HashSet[MClass]
class VTModPerfectHashing
super VTPerfectHashing
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
redef fun op(mask, id) do return mask % id
end
class VTAndPerfectHashing
super VTPerfectHashing
- init(class_coloring: ClassColoring) do end
+ init(mmodule: MModule, class_coloring: ClassColoring) do super
redef fun op(mask, id) do return mask.bin_and(id)
end
class_coloring.colorize(mclasses)
# methods coloration
- var method_coloring = new MethodColoring(class_coloring)
+ var method_coloring = new MethodColoring(mainmodule, class_coloring)
self.method_colors = method_coloring.colorize
self.method_tables = method_coloring.build_property_tables
self.compile_color_consts(self.method_colors)
# attributes coloration
- var attribute_coloring = new AttributeColoring(class_coloring)
+ var attribute_coloring = new AttributeColoring(mainmodule, class_coloring)
self.attr_colors = attribute_coloring.colorize
self.attr_tables = attribute_coloring.build_property_tables
self.compile_color_consts(self.attr_colors)
# vt coloration
if modelbuilder.toolcontext.opt_bm_typing.value then
- var vt_coloring = new NaiveVTColoring(class_coloring)
+ var vt_coloring = new NaiveVTColoring(mainmodule, 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(class_coloring)
+ var vt_coloring = new VTModPerfectHashing(mainmodule, 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(class_coloring)
+ var vt_coloring = new VTAndPerfectHashing(mainmodule, 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(class_coloring)
+ var vt_coloring = new VTColoring(mainmodule, class_coloring)
self.vt_colors = vt_coloring.colorize
self.vt_tables = vt_coloring.build_property_tables
end