compile: move some class processing to program to do it before analysis
authorJean-Sebastien Gelinas <calestar@gmail.com>
Tue, 8 Sep 2009 15:29:57 +0000 (11:29 -0400)
committerJean Privat <jean@pryen.org>
Fri, 11 Sep 2009 17:52:13 +0000 (13:52 -0400)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiling/table_computation.nit
src/program.nit

index cad65e6..9a8a423 100644 (file)
@@ -170,17 +170,10 @@ redef class Program
 
                # 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
+               for c in 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
index 6952c42..9d45a1a 100644 (file)
@@ -53,6 +53,21 @@ class Program
        # of _sep files so that we do not corrupt separate compilation
        fun get_file_ending: String do return if tc.global then "_glob" else "_sep"
 
+       # This method will ensure that all the metamodel is computed before we
+       # start using all the classes
+       private fun finish_processing_classes do
+               var classes = new Array[MMLocalClass]
+               for c in module.local_classes do
+                       c.compute_super_classes
+                       classes.add(c)
+               end
+
+               for c in classes do
+                       c.compute_ancestors
+                       c.inherit_global_properties
+               end
+       end
+
        fun compute_main_method do
                # Check for the 'Sys' class
                var sysname = once "Sys".to_symbol
@@ -143,6 +158,7 @@ class Program
        init(m: MMModule, toolcontext: ToolContext) do
                _module = m
                _tc = toolcontext
+               finish_processing_classes
        end
 end