modelbuilder: use phases to build the model
authorJean Privat <jean@pryen.org>
Fri, 19 Jul 2013 02:59:36 +0000 (22:59 -0400)
committerJean Privat <jean@pryen.org>
Fri, 19 Jul 2013 13:00:11 +0000 (09:00 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/frontend.nit
src/modelbuilder.nit
src/nit.nit
src/nitg.nit
src/nitmetrics.nit
src/typing.nit
tests/sav/error_gen_f_inh_clash.res

index f196f21..d219ad8 100644 (file)
@@ -30,6 +30,8 @@ redef class ToolContext
        private var dummy: Bool = do_dummy
        fun do_dummy: Bool
        do
+               # Force easy warnings aftrm modelbuilder
+               phases.add_edge(simple_misc_analysis_phase, modelize_property_phase)
                # Force easy warnings before intraproc-errors
                phases.add_edge(scope_phase, simple_misc_analysis_phase)
                return true
index f12fc5c..4e186e9 100644 (file)
@@ -49,6 +49,28 @@ redef class ToolContext
 
        fun modelbuilder: ModelBuilder do return modelbuilder_real.as(not null)
        private var modelbuilder_real: nullable ModelBuilder = null
+
+       var modelize_class_phase: Phase = new ModelizeClassPhase(self, null)
+       var modelize_property_phase: Phase = new ModelizePropertyPhase(self, [modelize_class_phase])
+end
+
+private class ModelizeClassPhase
+       super Phase
+
+       redef fun process_nmodule(nmodule)
+       do
+               toolcontext.modelbuilder.build_classes(nmodule)
+       end
+end
+
+private class ModelizePropertyPhase
+       super Phase
+       redef fun process_nmodule(nmodule)
+       do
+               for nclassdef in nmodule.n_classdefs do
+                       toolcontext.modelbuilder.build_properties(nclassdef)
+               end
+       end
 end
 
 # A model builder knows how to load nit source files and build the associated model
index 981a85c..a658d4d 100644 (file)
@@ -44,7 +44,7 @@ end
 var progname = arguments.first
 
 # Here we load an process all modules passed on the command line
-var mmodules = modelbuilder.parse_and_build([progname])
+var mmodules = modelbuilder.parse([progname])
 modelbuilder.run_phases
 
 if toolcontext.opt_only_metamodel.value then exit(0)
index ed84e7c..58872b0 100644 (file)
@@ -47,7 +47,7 @@ end
 var progname = arguments.first
 
 # Here we load an process all modules passed on the command line
-var mmodules = modelbuilder.parse_and_build([progname])
+var mmodules = modelbuilder.parse([progname])
 if mmodules.is_empty then return
 modelbuilder.run_phases
 
index 1d5bfde..0f6f430 100644 (file)
@@ -39,7 +39,7 @@ var model = new Model
 var modelbuilder = new ModelBuilder(model, toolcontext)
 
 # Here we load an process all modules passed on the command line
-var mmodules = modelbuilder.parse_and_build(arguments)
+var mmodules = modelbuilder.parse(arguments)
 modelbuilder.run_phases
 
 if mmodules.length == 0 then return
index 9510a61..db1f656 100644 (file)
@@ -24,7 +24,7 @@ import phase
 import local_var_init
 
 redef class ToolContext
-       var typing_phase: Phase = new TypingPhase(self, [flow_phase, local_var_init_phase])
+       var typing_phase: Phase = new TypingPhase(self, [flow_phase, modelize_property_phase, local_var_init_phase])
 end
 
 private class TypingPhase
index 46edade..07b0762 100644 (file)
@@ -1,2 +1 @@
-error_gen_f_inh_clash.nit:19,7--8: Error: Cannot provide a defaut constructor: conflict for G1 and G2
 base_gen_f.nit:19,14: Type error: class E not found in module base_gen_f.