# Separately compile all the method definitions of the module
fun compile_module_to_c(mmodule: MModule)
do
var old_module = self.mainmodule
self.mainmodule = mmodule
for cd in mmodule.mclassdefs do
for pd in cd.mpropdefs do
if not pd isa MMethodDef then continue
if pd.mproperty.is_broken or pd.is_broken or pd.msignature == null then continue # Skip broken method
var rta = runtime_type_analysis
if modelbuilder.toolcontext.opt_skip_dead_methods.value and rta != null and not rta.live_methoddefs.has(pd) then continue
#print "compile {pd} @ {cd} @ {mmodule}"
var r = pd.separate_runtime_function
r.compile_to_c(self)
var r2 = pd.virtual_runtime_function
if r2 != r then r2.compile_to_c(self)
# Generate trampolines
if modelbuilder.toolcontext.opt_trampoline_call.value then
r2.compile_trampolines(self)
end
end
end
var compiled_thunks = new Array[SeparateRuntimeFunction]
# Compile thunks here to write them in the same module they are declared.
for thunk in thunks_to_compile do
if thunk.mmethoddef.mclassdef.mmodule == mmodule then
thunk.compile_to_c(self)
compiled_thunks.add(thunk)
end
end
thunks_to_compile.remove_all(compiled_thunks)
self.mainmodule = old_module
end
src/compiler/separate_compiler.nit:628,2--661,4