compiler: use `adapt_signature` to simplify and clean `table_send`
authorJean Privat <jean@pryen.org>
Thu, 7 May 2015 14:11:40 +0000 (10:11 -0400)
committerJean Privat <jean@pryen.org>
Thu, 7 May 2015 14:11:40 +0000 (10:11 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/separate_compiler.nit

index 34e7be4..3e7fbcb 100644 (file)
@@ -1436,13 +1436,14 @@ class SeparateCompilerVisitor
                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 runtime_function = mmethod.intro.virtual_runtime_function
                var msignature = runtime_function.called_signature
 
+               adapt_signature(mmethod.intro, arguments)
+
                var res: nullable RuntimeVariable
                var ret = msignature.return_mtype
                if ret == null then
@@ -1451,18 +1452,7 @@ class SeparateCompilerVisitor
                        res = self.new_var(ret)
                end
 
-               var ss = new FlatBuffer
-
-               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
-                       a = self.autobox(a, t)
-                       ss.append(", {a}")
-               end
+               var ss = arguments.join(", ")
 
                var const_color = mentity.const_color
                var ress