modelbuilder: split extract `parse` from `parse_and_build`
authorJean Privat <jean@pryen.org>
Thu, 18 Jul 2013 17:38:48 +0000 (13:38 -0400)
committerJean Privat <jean@pryen.org>
Fri, 19 Jul 2013 02:40:49 +0000 (22:40 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/modelbuilder.nit

index ca843b5..bd4fa35 100644 (file)
@@ -91,19 +91,7 @@ class ModelBuilder
        # FIXME: Maybe just let the client do the loop (instead of playing with Sequences)
        fun parse_and_build(modules: Sequence[String]): Array[MModule]
        do
-               var time0 = get_time
-               # Parse and recursively load
-               self.toolcontext.info("*** PARSE ***", 1)
-               var mmodules = new Array[MModule]
-               for a in modules do
-                       var nmodule = self.load_module(null, a)
-                       if nmodule == null then continue # Skip error
-                       mmodules.add(nmodule.mmodule.as(not null))
-               end
-               var time1 = get_time
-               self.toolcontext.info("*** END PARSE: {time1-time0} ***", 2)
-
-               self.toolcontext.check_errors
+               var mmodules = parse(modules)
 
                if self.toolcontext.opt_only_parse.value then
                        self.toolcontext.info("--only-parse: stop processing", 2)
@@ -111,6 +99,7 @@ class ModelBuilder
                end
 
                # Build the model
+               var time1 = get_time
                self.toolcontext.info("*** BUILD MODEL ***", 1)
                self.build_all_classes
                var time2 = get_time
@@ -121,6 +110,24 @@ class ModelBuilder
                return mmodules
        end
 
+       fun parse(modules: Sequence[String]): Array[MModule]
+       do
+               var time0 = get_time
+               # Parse and recursively load
+               self.toolcontext.info("*** PARSE ***", 1)
+               var mmodules = new Array[MModule]
+               for a in modules do
+                       var nmodule = self.load_module(null, a)
+                       if nmodule == null then continue # Skip error
+                       mmodules.add(nmodule.mmodule.as(not null))
+               end
+               var time1 = get_time
+               self.toolcontext.info("*** END PARSE: {time1-time0} ***", 2)
+
+               self.toolcontext.check_errors
+               return mmodules
+       end
+
        # Return a class named `name' visible by the module `mmodule'.
        # Visibility in modules is correctly handled.
        # If no such a class exists, then null is returned.