X-Git-Url: http://nitlanguage.org diff --git a/src/compiler/separate_compiler.nit b/src/compiler/separate_compiler.nit index f6c483c..362bb52 100644 --- a/src/compiler/separate_compiler.nit +++ b/src/compiler/separate_compiler.nit @@ -1053,7 +1053,7 @@ class SeparateCompiler v.add_abort("type null") v.add("\}") v.add("if({t}->table_size < 0) \{") - v.add("PRINT_ERROR(\"Insantiation of a dead type: %s\\n\", {t}->name);") + v.add("PRINT_ERROR(\"Instantiation of a dead type: %s\\n\", {t}->name);") v.add_abort("type dead") v.add("\}") end @@ -1174,8 +1174,9 @@ class SeparateCompilerVisitor args.first = self.autobox(args.first, m.mclassdef.mclass.mclass_type) end for i in [0..msignature.arity[ do - var t = msignature.mparameters[i].mtype - if i == msignature.vararg_rank then + var mp = msignature.mparameters[i] + var t = mp.mtype + if mp.is_vararg then t = args[i+1].mtype end args[i+1] = self.autobox(args[i+1], t) @@ -1189,8 +1190,9 @@ class SeparateCompilerVisitor args.first = self.unbox_extern(args.first, m.mclassdef.mclass.mclass_type) end for i in [0..msignature.arity[ do - var t = msignature.mparameters[i].mtype - if i == msignature.vararg_rank then + var mp = msignature.mparameters[i] + var t = mp.mtype + if mp.is_vararg then t = args[i+1].mtype end if m.is_extern then args[i+1] = self.unbox_extern(args[i+1], t) @@ -1397,8 +1399,7 @@ class SeparateCompilerVisitor var res: nullable RuntimeVariable = null var recv = arguments.first var consider_null = not self.compiler.modelbuilder.toolcontext.opt_no_check_null.value or mmethod.name == "==" or mmethod.name == "!=" - var maybenull = (recv.mcasttype isa MNullableType or recv.mcasttype isa MNullType) and consider_null - if maybenull then + if maybenull(recv) and consider_null then self.add("if ({recv} == NULL) \{") if mmethod.name == "==" or mmethod.name == "is_same_instance" then res = self.new_var(bool_type) @@ -2108,18 +2109,24 @@ class SeparateCompilerVisitor var res = self.new_expr("{recv}[{arguments[1]}]", compiler.mainmodule.object_type) res.mcasttype = ret_type.as(not null) self.ret(res) - return + return true else if pname == "[]=" then self.add("{recv}[{arguments[1]}]={arguments[2]};") - return + return true else if pname == "length" then self.ret(self.new_expr("((struct instance_{nclass.c_name}*){arguments[0]})->length", ret_type.as(not null))) - return + return true else if pname == "copy_to" then var recv1 = "((struct instance_{nclass.c_name}*){arguments[1]})->values" self.add("memmove({recv1}, {recv}, {arguments[2]}*sizeof({elttype.ctype}));") - return + return true + else if pname == "memmove" then + # fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int) is intern do + var recv1 = "((struct instance_{nclass.c_name}*){arguments[3]})->values" + self.add("memmove({recv1}+{arguments[4]}, {recv}+{arguments[1]}, {arguments[2]}*sizeof({elttype.ctype}));") + return true end + return false end redef fun native_array_get(nat, i) @@ -2246,8 +2253,9 @@ class SeparateRuntimeFunction var sig = new FlatBuffer sig.append("({called_recv.ctype} self") for i in [0..called_signature.arity[ do - var mtype = called_signature.mparameters[i].mtype - if i == called_signature.vararg_rank then + var mp = called_signature.mparameters[i] + var mtype = mp.mtype + if mp.is_vararg then mtype = mmethoddef.mclassdef.mmodule.array_type(mtype) end sig.append(", {mtype.ctype} p{i}") @@ -2282,8 +2290,9 @@ class SeparateRuntimeFunction comment.append("({selfvar}: {selfvar.mtype}") arguments.add(selfvar) for i in [0..msignature.arity[ do - var mtype = msignature.mparameters[i].mtype - if i == msignature.vararg_rank then + var mp = msignature.mparameters[i] + var mtype = mp.mtype + if mp.is_vararg then mtype = v.mmodule.array_type(mtype) end comment.append(", {mtype}")