# All information and results of the global analysis.
class TableInformation
-special ColorContext
+ super ColorContext
# FIXME: do something better.
readable writable var _max_class_table_length: Int = 0
end
# A compiled class is a class in a program
class CompiledClass
-special ColorContext
+ super ColorContext
# The corresponding local class in the main module of the prgram
readable var _local_class: MMLocalClass
readable var _instance_layout: Array[TableElt] = new Array[TableElt]
# Build the local layout of the class and feed the module table
- private fun build_layout_in(tc: ToolContext, module_table: Array[ModuleTableElt])
+ private fun build_layout_in(module_table: Array[ModuleTableElt])
do
var clt = _class_layout
var ilt = _instance_layout
# Associate global classes to compiled classes
readable var _compiled_classes: HashMap[MMGlobalClass, CompiledClass] = new HashMap[MMGlobalClass, CompiledClass]
- fun do_table_computation(tc: ToolContext)
+ fun do_table_computation
do
tc.info("Building tables",1)
- for m in module.mhe.greaters_and_self do
+ for m in main_module.mhe.greaters_and_self do
tc.info("Building tables for module: {m.name}",2)
- m.local_analysis(tc)
+ m.local_analysis
end
tc.info("Merging all tables",2)
- do_global_table_analysis(tc)
+ do_global_table_analysis
end
# Do the complete global analysis
- private fun do_global_table_analysis(cctx: ToolContext)
+ private fun do_global_table_analysis
do
- #print "Do the complete global analysis"
var smallest_classes = new Array[MMLocalClass]
var global_properties = new HashSet[MMGlobalProperty]
var ctab = new Array[TableElt]
# We have to work on ALL the classes of the module
var classes = new Array[MMLocalClass]
- for c in module.local_classes do
- c.compute_super_classes
- classes.add(c)
- end
- (new ClassSorter).sort(classes)
+ for c in main_module.local_classes do classes.add(c)
+ classes.sort !cmp(x,y) = x.total_order_compare(y)
for c in classes do
- # Finish processing the class (if invisible)
- c.compute_ancestors
- c.inherit_global_properties
-
# Associate a CompiledClass to the class
var cc = new CompiledClass(c)
compiled_classes[c.global] = cc
# Assign a unique class identifier
# (negative are for primitive classes)
var gc = c.global
- var bm = gc.module
+ var bm = gc.mmmodule
if c.primitive_info != null then
cc.id = pclassid
pclassid = pclassid - 4
readable var _local_table: Array[ModuleTableElt] = new Array[ModuleTableElt]
# Builds the local tables and local classes layouts
- private fun local_analysis(tc: ToolContext)
+ private fun local_analysis
do
for c in local_classes do
if c isa MMConcreteClass then
- c.build_layout_in(tc, _local_table)
+ c.build_layout_in(_local_table)
end
end
end
# An element of a class or an instance table
# Such an elements represent method function pointers, attribute values, etc.
abstract class TableElt
-special AbsTableElt
+ super AbsTableElt
# Is the element conflict to class `c' (used for coloring)
fun is_related_to(c: MMLocalClass): Bool is abstract
# An element of a module table
# Such an elements represent colors or identifiers
abstract class ModuleTableElt
-special AbsTableElt
+ super AbsTableElt
end
# An element of a module table that represents a group of TableElt defined in the same local class
class ModuleTableEltGroup
-special ModuleTableElt
+ super ModuleTableElt
readable var _elements: Array[TableElt] = new Array[TableElt]
end
# An element that represents a class property
abstract class TableEltProp
-special TableElt
+ super TableElt
readable var _property: MMLocalProperty
init(p: MMLocalProperty)
# An element that represents a function pointer to a global method
class TableEltMeth
-special TableEltProp
+ super TableEltProp
end
# An element that represents a function pointer to the super method of a local method
class TableEltSuper
-special TableEltProp
+ super TableEltProp
end
# An element that represents the value stored for a global attribute
class TableEltAttr
-special TableEltProp
+ super TableEltProp
end
# An element representing a class information
class AbsTableEltClass
-special AbsTableElt
+ super AbsTableElt
# The local class where the information comes from
readable var _local_class: MMLocalClass
# An element of a class table representing a class information
class TableEltClass
-special TableElt
-special AbsTableEltClass
+ super TableElt
+ super AbsTableEltClass
redef fun is_related_to(c)
do
- var bc = c.module[_local_class.global]
+ var bc = c.mmmodule[_local_class.global]
return c.cshe <= bc
end
end
# An element representing the id of a class in a module table
class TableEltClassId
-special ModuleTableElt
-special AbsTableEltClass
+ super ModuleTableElt
+ super AbsTableEltClass
end
# An element representing the constructor marker position in a class table
class TableEltClassInitTable
-special TableEltClass
+ super TableEltClass
end
# An element used for a cast
# At the TableElt offset, there is the id of the super-class
# At the ModuleTableElt offset, there is the TableElt offset (ie. the color of the super-class).
class TableEltClassColor
-special TableEltClass
-special ModuleTableElt
+ super TableEltClass
+ super ModuleTableElt
end
# A Group of elements introduced in the same global-class that are colored together
class TableEltComposite
-special TableElt
+ super TableElt
var _table: Array[TableElt]
var _cc: CompiledClass
var _offsets: HashMap[MMLocalClass, Int]
# The element that represent the class id
class TableEltClassSelfId
-special TableElt
+ super TableElt
redef fun is_related_to(c) do return true
end
# The element that represent the Object Size
class TableEltClassObjectSize
-special TableElt
+ super TableElt
redef fun is_related_to(c) do return true
end
# The element that represent the object id
class TableEltObjectId
-special TableElt
+ super TableElt
redef fun is_related_to(c) do return true
end
# The element that
class TableEltVftPointer
-special TableElt
+ super TableElt
redef fun is_related_to(c) do return true
end
-
-###############################################################################
-
-# Used to sort local class in a deterministic total order
-# The total order superset the class refinement and the class specialisation relations
-class ClassSorter
-special AbstractSorter[MMLocalClass]
- redef fun compare(a, b) do return a.compare(b)
- init do end
-end
-
-redef class MMLocalClass
- # Comparaison in a total order that superset the class refinement and the class specialisation relations
- fun compare(b: MMLocalClass): Int
- do
- var a = self
- if a == b then
- return 0
- else if a.module.mhe < b.module then
- return 1
- else if b.module.mhe < a.module then
- return -1
- end
- var ar = a.cshe.rank
- var br = b.cshe.rank
- if ar > br then
- return 1
- else if br > ar then
- return -1
- else
- return b.name.to_s <=> a.name.to_s
- end
- end
-end