nitc: fix calling extern constructors from extern code in separate compiler
[nit.git] / src / test_test_phase.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Example of simple module that aims to do some specific work on nit programs.
16 #
17 # Fast prototypes can just start with this skeletton.
18 module test_test_phase
19
20 # We need the framework that perfoms standard code for the main-program
21 import test_phase
22
23 # We usualy need specific phases
24 # NOTE: `frontend` is sufficent in most case (it is often too much)
25 import frontend
26
27 # The body of the specific work.
28 # The main entry point is provided by `test_phase`,
29 # This function is then automatically (unless errors where found).
30 redef fun do_work(mainmodule, given_mmodules, modelbuilder)
31 do
32 print "It works"
33 var model = modelbuilder.model
34 print "I have {model.mmodules.length} modules"
35 var mclasses = mainmodule.flatten_mclass_hierarchy
36 print "I have also {mclasses.length} classes"
37
38 var meth_cpt = 0
39 for m in mainmodule.in_importation.greaters do
40 for cd in m.mclassdefs do
41 for pd in cd.mpropdefs do
42 if pd isa MMethodDef then meth_cpt += 1
43 end
44 end
45 end
46 print "And {meth_cpt} definitions of methods"
47 end