private import compiling_global
private import compiling_icode
-redef class MMModule
+redef class Program
# Compile the program
# Generate all sep files (_sep.[ch]), the main file (_table.c) and the build file (_build.sh)
# Then execute the build.sh
fun compile_prog_to_c(tc: ToolContext)
do
tc.info("Building tables",1)
- for m in mhe.greaters_and_self do
+ for m in module.mhe.greaters_and_self do
tc.info("Building tables for module: {m.name}",2)
m.local_analysis(tc)
end
files.add("$CLIBDIR/gc.c")
files.add("$CLIBDIR/gc_static_objects_list.c")
tc.info("Generating C code",1)
- for m in mhe.greaters_and_self do
+ for m in module.mhe.greaters_and_self do
files.add("{tc.compdir}/{m.name}._sep.c")
tc.info("Generating C code for module: {m.name}",2)
m.compile_separate_module(tc, ga)
end
tc.info("Generating main, tables and makefile ...",1)
- files.add("{tc.compdir}/{name}._tables.c")
+ files.add("{tc.compdir}/{module.name}._tables.c")
compile_main(tc, ga)
- var fn = "{tc.compdir}/{name}._build.sh"
+ var fn = "{tc.compdir}/{module.name}._build.sh"
var f = new OFStream.open(fn)
var verbose = ""
end
f.write("#!/bin/sh\n")
- f.write("# This shell script is generated by NIT to compile the program {name}.\n")
+ f.write("# This shell script is generated by NIT to compile the program {module.name}.\n")
f.write("CLIBDIR=\"{tc.clibdir}\"\n")
f.write("{tc.bindir}/gccx {verbose} -d {tc.compdir} -I $CLIBDIR {includes.join(" ")}")
if tc.output_file != null then
f.write(" -o {tc.output_file}")
else if tc.ext_prefix.is_empty then
- f.write(" -o {name}")
+ f.write(" -o {module.name}")
else
- f.write(" -o {name}_{tc.ext_prefix}")
+ f.write(" -o {module.name}_{tc.ext_prefix}")
end
if tc.boost then f.write(" -O")
f.write(" \"$@\" \\\n {files.join("\\\n ")}\n")
# Compile the main file
private fun compile_main(tc: ToolContext, ga: GlobalAnalysis)
do
- var v = new GlobalCompilerVisitor(self, tc, ga)
+ var v = new GlobalCompilerVisitor(module, tc, ga)
v.add_decl("#include <nit_common.h>")
compile_tables_to_c(v)
compile_main_part(v)
- var f = new OFStream.open("{tc.compdir}/{name}._tables.c")
- f.write("/* This C file is generated by NIT to compile program {name}. */\n")
- for m in mhe.greaters_and_self do
+ var f = new OFStream.open("{tc.compdir}/{module.name}._tables.c")
+ f.write("/* This C file is generated by NIT to compile program {module.name}. */\n")
+ for m in module.mhe.greaters_and_self do
f.write("#include \"{m.name}._sep.h\"\n")
end
f.write(v.to_s)
f.close
end
+end
+redef class MMModule
# Compile the sep files (of the current module only)
private fun compile_separate_module(tc: ToolContext, ga: GlobalAnalysis)
do