1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2012 Jean Privat <jean@pryen.org>
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Semantic analysis of the body of property definitions.
19 # This module is an entry point for various analysis.
21 # FIXME: find a better name for the module
24 import simple_misc_analysis
30 import auto_super_init
32 redef class ModelBuilder
33 # Run the full_semantic_analysis on all propdefs of all modules
34 fun full_propdef_semantic_analysis
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)
46 self.toolcontext
.check_errors
49 self.toolcontext
.info
("*** END SEMANTIC ANALYSIS: {time1-time0} ***", 2)
54 # Run do_scope, do_flow, do_local_var_init and do_typing
55 fun full_semantic_analysis
(modelbuilder
: ModelBuilder)
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
)