else
self.add("{res} = 1; /* arg is null and recv is not */")
end
- if maybenull then
- self.add("\}")
- end
- return res
+ self.add("\}") # closes the null case
+ self.add("if (0) \{") # what follow is useless, CC will drop it
end
end
+ return res
+ end
+
+ private fun table_send(mmethod: MMethod, arguments: Array[RuntimeVariable], const_color: String): nullable RuntimeVariable
+ do
+ compiler.modelbuilder.nb_invok_by_tables += 1
+ if compiler.modelbuilder.toolcontext.opt_invocation_metrics.value then add("count_invoke_by_tables++;")
+
+ assert arguments.length == mmethod.intro.msignature.arity + 1 else debug("Invalid arity for {mmethod}. {arguments.length} arguments given.")
+ var recv = arguments.first
+
+ var res0 = before_send(mmethod, arguments)
+
+ var res: nullable RuntimeVariable
+ var msignature = mmethod.intro.msignature.resolve_for(mmethod.intro.mclassdef.bound_mtype, mmethod.intro.mclassdef.bound_mtype, mmethod.intro.mclassdef.mmodule, true)
+ var ret = msignature.return_mtype
+ if mmethod.is_new then
+ ret = arguments.first.mtype
+ res = self.new_var(ret)
+ else if ret == null then
+ res = null
+ else
+ res = self.new_var(ret)
+ end
+
- var s = new Buffer
- var ss = new Buffer
++ var s = new FlatBuffer
++ var ss = new FlatBuffer
+
+ s.append("val*")
+ ss.append("{recv}")
+ for i in [0..msignature.arity[ do
+ var a = arguments[i+1]
+ var t = msignature.mparameters[i].mtype
+ if i == msignature.vararg_rank then
+ t = arguments[i+1].mcasttype
+ end
+ s.append(", {t.ctype}")
+ a = self.autobox(a, t)
+ ss.append(", {a}")
+ end
+
var r
if ret == null then r = "void" else r = ret.ctype