mainmodule
It is the main method usually called after the instantiation
# Do the full code generation of the program `mainmodule`
# It is the main method usually called after the instantiation
fun do_compilation is abstract
src/compiler/abstract_compiler.nit:648,2--650,31
redef fun do_compilation
do
var compiler = self
compiler.compile_header
var c_name = mainmodule.c_name
# compile class structures
modelbuilder.toolcontext.info("Property coloring", 2)
compiler.new_file("{c_name}.classes")
compiler.do_property_coloring
compiler.compile_class_infos
for m in mainmodule.in_importation.greaters do
for mclass in m.intro_mclasses do
#if mclass.kind == abstract_kind or mclass.kind == interface_kind then continue
compiler.compile_class_to_c(mclass)
end
end
# The main function of the C
compiler.new_file("{c_name}.main")
compiler.compile_nitni_global_ref_functions
compiler.compile_main_function
compiler.compile_finalizer_function
compiler.link_mmethods
# compile methods
for m in mainmodule.in_importation.greaters do
modelbuilder.toolcontext.info("Generate C for module {m.full_name}", 2)
compiler.new_file("{m.c_name}.sep")
compiler.compile_module_to_c(m)
end
# compile live & cast type structures
modelbuilder.toolcontext.info("Type coloring", 2)
compiler.new_file("{c_name}.types")
compiler.compile_types
end
src/compiler/separate_compiler.nit:160,2--197,4
redef fun do_compilation
do
var compiler = self
compiler.compile_header
if mainmodule.model.get_mclasses_by_name("Pointer") != null then
runtime_type_analysis.live_types.add(mainmodule.pointer_type)
end
for t in runtime_type_analysis.live_types do
compiler.declare_runtimeclass(t)
end
compiler.compile_class_names
# Init instance code (allocate and init-arguments)
for t in runtime_type_analysis.live_types do
if not t.is_c_primitive then
compiler.generate_init_instance(t)
if t.mclass.kind == extern_kind then
compiler.generate_box_instance(t)
end
else
compiler.generate_box_instance(t)
end
end
# The main function of the C
compiler.compile_nitni_global_ref_functions
compiler.compile_main_function
# Compile until all runtime_functions are visited
while not compiler.todos.is_empty do
var m = compiler.todos.shift
modelbuilder.toolcontext.info("Compile {m} ({compiler.seen.length-compiler.todos.length}/{compiler.seen.length})", 3)
m.compile_to_c(compiler)
end
modelbuilder.toolcontext.info("Total methods to compile to C: {compiler.seen.length}", 2)
end
src/compiler/global_compiler.nit:95,2--134,4