X-Git-Url: http://nitlanguage.org diff --git a/src/compiler/separate_compiler.nit b/src/compiler/separate_compiler.nit index f50a2a7..b971cdb 100644 --- a/src/compiler/separate_compiler.nit +++ b/src/compiler/separate_compiler.nit @@ -625,6 +625,7 @@ class SeparateCompiler for cd in mmodule.mclassdefs do for pd in cd.mpropdefs do if not pd isa MMethodDef then continue + if pd.msignature == null then continue # Skip broken method var rta = runtime_type_analysis if modelbuilder.toolcontext.opt_skip_dead_methods.value and rta != null and not rta.live_methoddefs.has(pd) then continue #print "compile {pd} @ {cd} @ {mmodule}" @@ -2208,13 +2209,18 @@ class SeparateRuntimeFunction # The C type for the function pointer. var c_funptrtype: String is lazy do return "{c_ret}(*){c_sig}" - # The arguments, as generated by `compile_to_c` - private var arguments: Array[RuntimeVariable] is noinit - redef fun compile_to_c(compiler) do var mmethoddef = self.mmethoddef + var sig = "{c_ret} {c_name}{c_sig}" + compiler.provide_declaration(self.c_name, "{sig};") + + var rta = compiler.as(SeparateCompiler).runtime_type_analysis + if rta != null and not rta.live_mmodules.has(mmethoddef.mclassdef.mmodule) then + return + end + var recv = self.mmethoddef.mclassdef.bound_mtype var v = compiler.new_visitor var selfvar = new RuntimeVariable("self", called_recv, recv) @@ -2225,12 +2231,7 @@ class SeparateRuntimeFunction var msignature = called_signature var ret = called_signature.return_mtype - var sig = new FlatBuffer var comment = new FlatBuffer - sig.append(c_ret) - sig.append(" ") - sig.append(self.c_name) - sig.append(c_sig) comment.append("({selfvar}: {selfvar.mtype}") arguments.add(selfvar) for i in [0..msignature.arity[ do @@ -2246,8 +2247,6 @@ class SeparateRuntimeFunction if ret != null then comment.append(": {ret}") end - compiler.provide_declaration(self.c_name, "{sig};") - self.arguments = arguments.to_a v.add_decl("/* method {self} for {comment} */") v.add_decl("{sig} \{") @@ -2280,8 +2279,10 @@ class SeparateRuntimeFunction fun compile_trampolines(compiler: SeparateCompiler) do var recv = self.mmethoddef.mclassdef.bound_mtype - var selfvar = arguments.first + var selfvar = new RuntimeVariable("self", called_recv, recv) var ret = called_signature.return_mtype + var arguments = ["self"] + for i in [0..called_signature.arity[ do arguments.add "p{i}" if mmethoddef.is_intro and not recv.is_c_primitive then var m = mmethoddef.mproperty