X-Git-Url: http://nitlanguage.org diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 75e9cc5..c74933c 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -196,7 +196,7 @@ class MakefileToolchain var time1 = get_time self.toolcontext.info("*** END WRITING C: {time1-time0} ***", 2) - if not toolcontext.check_errors then return + toolcontext.check_errors # Execute the Makefile @@ -465,6 +465,13 @@ ifneq ($(findstring MINGW64,$(uname_S)),) CFLAGS += -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast endif +# Add the compilation dir to the Java CLASSPATH +ifeq ($(CLASSPATH),) + CLASSPATH := . +else + CLASSPATH := $(CLASSPATH):. +endif + """ makefile.write("all: {outpath}\n") @@ -528,8 +535,7 @@ endif var java_files = new Array[ExternFile] for f in compiler.extern_bodies do var o = f.makefile_rule_name - var ff = f.filename.basename - makefile.write("{o}: {ff}\n") + makefile.write("{o}: {f.filename}\n") makefile.write("\t{f.makefile_rule_content}\n\n") dep_rules.add(f.makefile_rule_name) @@ -556,9 +562,9 @@ endif end makefile.write("{outpath}: {dep_rules.join(" ")}\n\t$(CC) $(LDFLAGS) -o {outpath.escape_to_sh} {ofiles.join(" ")} $(LDLIBS) {pkg}\n\n") # Clean - makefile.write("clean:\n\trm {ofiles.join(" ")} 2>/dev/null\n") + makefile.write("clean:\n\trm -f {ofiles.join(" ")} 2>/dev/null\n") if outpath != real_outpath then - makefile.write("\trm -- {outpath.escape_to_sh} 2>/dev/null\n") + makefile.write("\trm -f -- {outpath.escape_to_sh} 2>/dev/null\n") end makefile.close self.toolcontext.info("Generated makefile: {makepath}", 2) @@ -712,7 +718,7 @@ abstract class AbstractCompiler stream.write("const char* get_nit_name(register const char* procname, register unsigned int len);\n") stream.close - extern_bodies.add(new ExternCFile("{compile_dir}/c_functions_hash.c", "")) + extern_bodies.add(new ExternCFile("c_functions_hash.c", "")) end # Compile C headers @@ -4079,10 +4085,24 @@ redef class ASendExpr redef fun expr(v) do var recv = v.expr(self.n_expr, null) + if is_safe then + v.add "if ({recv}!=NULL) \{" + end var callsite = self.callsite.as(not null) if callsite.is_broken then return null var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments) - return v.compile_callsite(callsite, args) + var res = v.compile_callsite(callsite, args) + if is_safe then + if res != null then + var orig_res = res + res = v.new_var(self.mtype.as(not null)) + v.add("{res} = {orig_res};") + v.add("\} else \{") + v.add("{res} = NULL;") + end + v.add("\}") + end + return res end end @@ -4250,6 +4270,13 @@ redef class AVarargExpr end end +redef class ASafeExpr + redef fun expr(v) + do + return v.expr(self.n_expr, null) + end +end + redef class ANamedargExpr redef fun expr(v) do