X-Git-Url: http://nitlanguage.org diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index f177ef6..f0a05c9 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -853,12 +853,14 @@ extern void nitni_global_ref_decr( struct nitni_ref *ref ); v.add_decl("int main(int argc, char** argv) \{") end + v.add "#ifndef ANDROID" v.add("signal(SIGABRT, sig_handler);") v.add("signal(SIGFPE, sig_handler);") v.add("signal(SIGILL, sig_handler);") v.add("signal(SIGINT, sig_handler);") v.add("signal(SIGTERM, sig_handler);") v.add("signal(SIGSEGV, sig_handler);") + v.add "#endif" v.add("signal(SIGPIPE, SIG_IGN);") v.add("glob_argc = argc; glob_argv = argv;") @@ -1178,7 +1180,7 @@ abstract class AbstractCompilerVisitor fun calloc_array(ret_type: MType, arguments: Array[RuntimeVariable]) is abstract - fun native_array_def(pname: String, ret_type: nullable MType, arguments: Array[RuntimeVariable]) is abstract + fun native_array_def(pname: String, ret_type: nullable MType, arguments: Array[RuntimeVariable]): Bool do return false # Return an element of a native array. # The method is unsafe and is just a direct wrapper for the specific implementation of native arrays @@ -2078,19 +2080,20 @@ redef class MMethodDef var msignature = self.msignature.as(not null) for i in [0..msignature.arity[ do + var mp = msignature.mparameters[i] # skip test for vararg since the array is instantiated with the correct polymorphic type - if msignature.vararg_rank == i then continue + if mp.is_vararg then continue # skip if the cast is not required var origmtype = self.mproperty.intro.msignature.mparameters[i].mtype if not origmtype.need_anchor then continue # get the parameter type - var mtype = msignature.mparameters[i].mtype + var mtype = mp.mtype # generate the cast # note that v decides if and how to implements the cast - v.add("/* Covariant cast for argument {i} ({msignature.mparameters[i].name}) {arguments[i+1].inspect} isa {mtype} */") + v.add("/* Covariant cast for argument {i} ({mp.name}) {arguments[i+1].inspect} isa {mtype} */") v.add_cast(arguments[i+1], mtype, "covariance") end end @@ -2247,6 +2250,21 @@ redef class AMethPropdef else if pname == "to_b" then v.ret(v.new_expr("(unsigned char){arguments[0]}", ret.as(not null))) return true + else if pname == "code_point" then + v.ret(v.new_expr("(uint32_t){arguments[0]}", ret.as(not null))) + return true + else if pname == "&" then + v.ret(v.new_expr("{arguments[0]} & {arguments[1]}", ret.as(not null))) + return true + else if pname == "|" then + v.ret(v.new_expr("{arguments[0]} | {arguments[1]}", ret.as(not null))) + return true + else if pname == ">>" then + v.ret(v.new_expr("{arguments[0]} >> {arguments[1]}", ret.as(not null))) + return true + else if pname == "<<" then + v.ret(v.new_expr("{arguments[0]} << {arguments[1]}", ret.as(not null))) + return true end else if cname == "Char" then if pname == "object_id" then @@ -2280,6 +2298,9 @@ redef class AMethPropdef else if pname == "to_i" then v.ret(v.new_expr("{arguments[0]}-'0'", ret.as(not null))) return true + else if pname == "code_point" then + v.ret(v.new_expr("(long){arguments[0]}", ret.as(not null))) + return true end else if cname == "Byte" then if pname == "output" then @@ -2328,6 +2349,15 @@ redef class AMethPropdef else if pname == ">=" then v.ret(v.new_expr("{arguments[0]} >= {arguments[1]}", ret.as(not null))) return true + else if pname == ">>" then + v.ret(v.new_expr("{arguments[0]} >> {arguments[1]}", ret.as(not null))) + return true + else if pname == "<<" then + v.ret(v.new_expr("{arguments[0]} << {arguments[1]}", ret.as(not null))) + return true + else if pname == "&" then + v.ret(v.new_expr("{arguments[0]} & {arguments[1]}", ret.as(not null))) + return true else if pname == "to_i" then v.ret(v.new_expr("(long){arguments[0]}", ret.as(not null))) return true @@ -2349,6 +2379,9 @@ redef class AMethPropdef else if pname == "to_u32" then v.ret(v.new_expr("(uint32_t){arguments[0]}", ret.as(not null))) return true + else if pname == "ascii" then + v.ret(v.new_expr("(uint32_t){arguments[0]}", ret.as(not null))) + return true end else if cname == "Bool" then if pname == "output" then @@ -2458,8 +2491,7 @@ redef class AMethPropdef return true end else if cname == "NativeArray" then - v.native_array_def(pname, ret, arguments) - return true + return v.native_array_def(pname, ret, arguments) else if cname == "Int8" then if pname == "output" then v.add("printf(\"%\"PRIi8 \"\\n\", {arguments.first});")