# Then execute the build.sh
fun compile_prog_to_c
do
- tc.compdir.mkdir
+ var compdir = tc.compdir.as(not null)
+ compdir.mkdir
var files = new Array[String]
var includes = new ArraySet[String]
files.add("$CLIBDIR/gc_static_objects_list.c")
tc.info("Generating C code",1)
for m in module.mhe.greaters_and_self do
- files.add("{tc.compdir}/{m.name}.{get_file_ending}.c")
+ files.add("{compdir}/{m.name}.{get_file_ending}.c")
tc.info("Generating C code for module: {m.name}",2)
m.compile_separate_module(self)
var native_name = m.location.file.strip_extension(".nit")
end
tc.info("Generating main, tables and makefile ...",1)
- files.add("{tc.compdir}/{module.name}._tables.c")
+ files.add("{compdir}/{module.name}._tables.c")
compile_main
- var fn = "{tc.compdir}/{module.name}._build.sh"
+ var fn = "{compdir}/{module.name}._build.sh"
var f = new OFStream.open(fn)
var verbose = ""
f.write("#!/bin/sh\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(" ")}")
+ f.write("CLIBDIR=\"{tc.clibdir.as(not null)}\"\n")
+ f.write("{tc.bindir.as(not null)}/gccx {verbose} -d {compdir} -I $CLIBDIR {includes.join(" ")}")
if tc.output_file != null then
- f.write(" -o {tc.output_file}")
+ f.write(" -o {tc.output_file.as(not null)}")
else if tc.ext_prefix.is_empty then
f.write(" -o {module.name}")
else
v.add_decl("#include <nit_common.h>")
compile_tables_to_c(v)
compile_main_part(v)
- var f = new OFStream.open("{tc.compdir}/{module.name}._tables.c")
+ var f = new OFStream.open("{tc.compdir.as(not null)}/{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}.{get_file_ending}.h\"\n")
if native_name.file_exists then v.add_decl("#include <{native_name.basename("")}>")
declare_class_tables_to_c(v)
compile_mod_to_c(v)
- var f = new OFStream.open("{tc.compdir}/{name}.{program.get_file_ending}.h")
+ var f = new OFStream.open("{tc.compdir.as(not null)}/{name}.{program.get_file_ending}.h")
f.write("/* This C header file is generated by NIT to compile modules and programs that requires {name}. */\n")
f.write("#ifndef {name}{program.get_file_ending}\n")
f.write("#define {name}{program.get_file_ending}\n")
f.write("#endif\n")
f.close
- f = new OFStream.open("{tc.compdir}/{name}.{program.get_file_ending}.c")
+ f = new OFStream.open("{tc.compdir.as(not null)}/{name}.{program.get_file_ending}.c")
f.write("/* This C file is generated by NIT to compile module {name}. */\n")
f.write("#include \"{name}.{program.get_file_ending}.h\"\n")
for s in v.ctx.instrs do