From: Alexandre Terrasa Date: Tue, 5 Mar 2013 22:42:26 +0000 (-0500) Subject: layout_builders: simplified ResolutionLayoutBuilder (for future refactoring) X-Git-Tag: v0.6~77^2~11 X-Git-Url: http://nitlanguage.org layout_builders: simplified ResolutionLayoutBuilder (for future refactoring) Signed-off-by: Alexandre Terrasa --- diff --git a/src/layout_builders.nit b/src/layout_builders.nit index 7c7ec06..423238a 100644 --- a/src/layout_builders.nit +++ b/src/layout_builders.nit @@ -79,25 +79,9 @@ class PHPropertyLayoutBuilder[E: MProperty] end abstract class ResolutionLayoutBuilder - type LAYOUT: Layout[MType] - init do end - fun build_layout(elements: Map[MClassType, Set[MType]]): LAYOUT is abstract - - fun compute_ids(elements: Map[MClassType, Set[MType]]): Map[MType, Int] do - var ids = new HashMap[MType, Int] - var color = 0 - for mclasstype, mclasstypes in elements do - for element in mclasstypes do - if ids.has_key(element) then continue - ids[element] = color - color += 1 - end - end - return ids - end end # Layout builder for MClass using Binary Matrix (BM) @@ -113,6 +97,19 @@ class BMResolutionLayoutBuilder result.pos = result.ids return result end + + fun compute_ids(elements: Map[MClassType, Set[MType]]): Map[MType, Int] do + var ids = new HashMap[MType, Int] + var color = 0 + for mclasstype, mclasstypes in elements do + for element in mclasstypes do + if ids.has_key(element) then continue + ids[element] = color + color += 1 + end + end + return ids + end end # Layout builder for resolution tables using Coloring (CL) @@ -130,6 +127,19 @@ class CLResolutionLayoutBuilder result.pos = self.colorer.colorize(elements) return result end + + fun compute_ids(elements: Map[MClassType, Set[MType]]): Map[MType, Int] do + var ids = new HashMap[MType, Int] + var color = 0 + for mclasstype, mclasstypes in elements do + for element in mclasstypes do + if ids.has_key(element) then continue + ids[element] = color + color += 1 + end + end + return ids + end end # Layout builder for resolution table using Perfect Hashing (PH) @@ -152,7 +162,7 @@ class PHResolutionLayoutBuilder return result end - redef fun compute_ids(elements) do + fun compute_ids(elements: Map[MClassType, Set[MType]]): Map[MType, Int] do var ids = new HashMap[MType, Int] var color = 1 for mclasstype, mclasstypes in elements do