model: new metamodel
[nit.git] / src / exprbuilder.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2012 Jean Privat <jean@pryen.org>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Semantic analysis of the body of property definitions.
18 #
19 # This module is an entry point for various analysis.
20 #
21 # FIXME: find a better name for the module
22 module exprbuilder
23
24 import simple_misc_analysis
25 import literal
26 import scope
27 import flow
28 import local_var_init
29 import typing
30 import auto_super_init
31
32 redef class ModelBuilder
33 # Run the full_semantic_analysis on all propdefs of all modules
34 fun full_propdef_semantic_analysis
35 do
36 var time0 = get_time
37 self.toolcontext.info("*** SEMANTIC ANALYSIS ***", 1)
38 for nmodule in self.nmodules do
39 nmodule.do_simple_misc_analysis(self.toolcontext)
40 nmodule.do_literal(self.toolcontext)
41 for nclassdef in nmodule.n_classdefs do
42 for npropdef in nclassdef.n_propdefs do
43 npropdef.full_semantic_analysis(self)
44 end
45 end
46 self.toolcontext.check_errors
47 end
48 var time1 = get_time
49 self.toolcontext.info("*** END SEMANTIC ANALYSIS: {time1-time0} ***", 2)
50 end
51 end
52
53 redef class APropdef
54 # Run do_scope, do_flow, do_local_var_init and do_typing
55 fun full_semantic_analysis(modelbuilder: ModelBuilder)
56 do
57 modelbuilder.toolcontext.info("* SEMANTIC ANALYSIS: {self.location}", 3)
58 var errcount = modelbuilder.toolcontext.error_count
59 do_scope(modelbuilder.toolcontext)
60 if errcount != modelbuilder.toolcontext.error_count then return
61 do_flow(modelbuilder.toolcontext)
62 if errcount != modelbuilder.toolcontext.error_count then return
63 do_local_var_init(modelbuilder.toolcontext)
64 if errcount != modelbuilder.toolcontext.error_count then return
65 do_typing(modelbuilder)
66 if errcount != modelbuilder.toolcontext.error_count then return
67 if self isa AConcreteMethPropdef then self.do_auto_super_init(modelbuilder)
68 end
69 end