compile: move MMLocalClass::compare to AbstractMetamodel and rename to total_order_co...
authorJean-Sebastien Gelinas <calestar@gmail.com>
Tue, 8 Sep 2009 15:27:22 +0000 (11:27 -0400)
committerJean Privat <jean@pryen.org>
Fri, 11 Sep 2009 17:51:39 +0000 (13:51 -0400)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiling/table_computation.nit
src/metamodel/abstractmetamodel.nit

index 1da4f6d..0103fd5 100644 (file)
@@ -568,30 +568,6 @@ end
 # 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)
+       redef fun compare(a, b) do return a.total_order_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
index 6eb24b9..546b9fd 100644 (file)
@@ -325,7 +325,7 @@ end
 # Local classes are classes defined, refined or imported in a module
 class MMLocalClass
        # The name of the local class
-        readable var _name: Symbol
+       readable var _name: Symbol
 
        # Arity of the local class (if generic)
        # FIXME: How to move this into the generic module in a sane way?
@@ -506,6 +506,28 @@ class MMLocalClass
        do
                return _name.to_s
        end
+
+       # Comparaison in a total order that superset the class refinement and the class specialisation relations
+       fun total_order_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
 
 # A global property gather local properties that correspond to a same message