Fast prototypes can just start with this skeleton.
nitc :: actors_injection_phase
Injects model for the classes annotated with "is actor" sonitc :: astbuilder
Instantiation and transformation of semantic nodes in the AST of expressions and statementsnitc :: i18n_phase
Basic support of internationalization through the generation of id-to-string tablesSerializable::inspect
to show more useful information
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.threaded
annotation
serialization :: serialization_core
Abstract services to serialize Nit objects to different formatsnitc :: serialization_model_phase
Phase generating methods (model-only) to serialize Nit objectsnitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagescore :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Example of simple module that aims to do some specific work on nit programs.
#
# Fast prototypes can just start with this skeleton.
module test_test_phase
# We need the framework that performs standard code for the main-program
import test_phase
# We usualy need specific phases
# NOTE: `frontend` is sufficient in most case (it is often too much)
import frontend
# The body of the specific work.
# The main entry point is provided by `test_phase`,
# This function is then automatically (unless errors where found).
redef fun do_work(mainmodule, given_mmodules, modelbuilder)
do
print "It works"
var model = modelbuilder.model
print "I have {model.mpackages.length} packages"
print "I have {model.mmodules.length} modules"
var mclasses = mainmodule.flatten_mclass_hierarchy
print "I have {mclasses.length} classes"
var m_cpt = 0
var md_cpt = 0
var cd_cpt = 0
for m in mainmodule.in_importation.greaters do
for cd in m.mclassdefs do
cd_cpt += 1
for pd in cd.mpropdefs do
if pd isa MMethodDef then
md_cpt += 1
if pd.is_intro then m_cpt += 1
end
end
end
end
print "For {cd_cpt} definitions of classes"
print "I have {m_cpt} methods"
print "For {md_cpt} definitions of methods"
end
src/test_test_phase.nit:15,1--56,3