Rename REAMDE to README.md
[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.mprojects.length} projects"
35 print "I have {model.mmodules.length} modules"
36 var mclasses = mainmodule.flatten_mclass_hierarchy
37 print "I have {mclasses.length} classes"
38
39 var m_cpt = 0
40 var md_cpt = 0
41 var cd_cpt = 0
42 for m in mainmodule.in_importation.greaters do
43 for cd in m.mclassdefs do
44 cd_cpt += 1
45 for pd in cd.mpropdefs do
46 if pd isa MMethodDef then
47 md_cpt += 1
48 if pd.is_intro then m_cpt += 1
49 end
50 end
51 end
52 end
53 print "For {cd_cpt} definitions of classes"
54 print "I have {m_cpt} methods"
55 print "For {md_cpt} definitions of methods"
56 end