nitg-s: cleaned useless ClassColoring uses
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 7 Feb 2013 21:08:18 +0000 (16:08 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 4 Mar 2013 18:20:01 +0000 (13:20 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/coloring.nit
src/separate_compiler.nit

index 339f0b4..4208c13 100644 (file)
@@ -521,79 +521,6 @@ class ClassColoring
        redef fun reverse_linearize(elements) do return self.mmodule.reverse_linearize_mclasses(elements)
 end
 
-# incremental coloring (very naive)
-class NaiveClassColoring
-       super ClassColoring
-
-       init(mainmodule: MModule) do
-               super(mainmodule)
-       end
-
-       # naive coloring that use incremental coloring
-       redef fun colorize_elements(elements) do
-               for e in elements do
-                       self.coloration_result[e] = self.coloration_result.length
-               end
-       end
-end
-
-abstract class ClassPerfectHashing
-       super ClassColoring
-
-       init(mainmodule: MModule) do
-               super(mainmodule)
-       end
-
-       fun compute_masks(elements: Set[T], ids: Map[T, Int]): Map[T, Int] do
-               for e in elements do
-                       # Create super type list
-                       var supers = new HashSet[T]
-                       supers.add_all(self.super_elements(e, elements))
-                       supers.add(e)
-                       # Compute the hashing 'mask'
-                       self.coloration_result[e] = compute_mask(supers, ids)
-               end
-               return self.coloration_result
-       end
-
-       private fun compute_mask(mtypes: Set[T], ids: Map[T, Int]): Int do
-               var mask = 0
-               loop
-                       var used = new List[Int]
-                       for sup in mtypes do
-                               var res = op(mask, ids[sup])
-                               if used.has(res) then
-                                       break
-                               else
-                                       used.add(res)
-                               end
-                       end
-                       if used.length == mtypes.length then break
-                       mask += 1
-               end
-               return mask
-       end
-
-       private fun op(mask: Int, id:Int): Int is abstract
-       private fun phash(id: Int, mask: Int): Int do return op(mask, id)
-end
-
-class ClassModPerfectHashing
-       super ClassPerfectHashing
-       init(mainmodule: MModule) do
-               super(mainmodule)
-       end
-       redef fun op(mask, id) do return mask % id
-end
-
-class ClassAndPerfectHashing
-       super ClassPerfectHashing
-       init(mainmodule: MModule) do
-               super(mainmodule)
-       end
-       redef fun op(mask, id) do return mask.bin_and(id)
-end
-
 # MProperty coloring
 class PropertyColoring
 
index 37cdad3..cd9768b 100644 (file)
@@ -117,8 +117,6 @@ class SeparateCompiler
        private var unanchored_types_tables: nullable Map[MClassType, Array[nullable MType]]
        private var unanchored_types_masks: nullable Map[MClassType, Int]
 
-       protected var class_coloring: ClassColoring
-
        protected var method_colors: Map[MMethod, Int]
        protected var method_tables: Map[MClass, Array[nullable MMethodDef]]
 
@@ -240,43 +238,38 @@ class SeparateCompiler
 
                # classes coloration
                var mclasses = new HashSet[MClass].from(modelbuilder.model.mclasses)
-               self.class_coloring = new ClassColoring(mainmodule)
+               var class_coloring = new ClassColoring(mainmodule)
                class_coloring.colorize(mclasses)
 
                # methods coloration
-               var method_coloring = new MethodColoring(self.class_coloring)
+               var method_coloring = new MethodColoring(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(self.class_coloring)
+               var attribute_coloring = new AttributeColoring(class_coloring)
                self.attr_colors = attribute_coloring.colorize
                self.attr_tables = attribute_coloring.build_property_tables
                self.compile_color_consts(self.attr_colors)
 
-               if modelbuilder.toolcontext.opt_bm_typing.value then
-                       self.class_coloring = new NaiveClassColoring(mainmodule)
-                       self.class_coloring.colorize(mclasses)
-               end
-
                # vt coloration
                if modelbuilder.toolcontext.opt_bm_typing.value then
-                       var vt_coloring = new NaiveVTColoring(self.class_coloring)
+                       var vt_coloring = new NaiveVTColoring(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(self.class_coloring)
+                       var vt_coloring = new VTModPerfectHashing(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(self.class_coloring)
+                       var vt_coloring = new VTAndPerfectHashing(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(self.class_coloring)
+                       var vt_coloring = new VTColoring(class_coloring)
                        self.vt_colors = vt_coloring.colorize
                        self.vt_tables = vt_coloring.build_property_tables
                end