From 4ca15449be2e3c9b71f56eccbbcd82d6fcb044a8 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 22 Oct 2015 11:32:37 +0300 Subject: [PATCH] test and fix arg passing offset too --- lib/phisol/compiler/call_site.rb | 5 +++-- test/compiler/statements/test_call.rb | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/phisol/compiler/call_site.rb b/lib/phisol/compiler/call_site.rb index c11d8ef7..a143d4f4 100644 --- a/lib/phisol/compiler/call_site.rb +++ b/lib/phisol/compiler/call_site.rb @@ -28,8 +28,9 @@ module Phisol # processing should return the register with the value val = process( arg) raise "Not register #{val}" unless val.is_a?(Register::RegisterValue) - # which we load int the new_message at the argument's index - @method.source.add_code Register.set_slot( statement , val , :new_message , i + 1) + # which we load int the new_message at the argument's index (the one comes from c index) + set = Register.set_slot( statement , val , :new_message , i + 1 + Parfait::Message.offset) + @method.source.add_code set end # now we have to resolve the method name (+ receiver) into a callable method diff --git a/test/compiler/statements/test_call.rb b/test/compiler/statements/test_call.rb index 33d3a090..7373d533 100644 --- a/test/compiler/statements/test_call.rb +++ b/test/compiler/statements/test_call.rb @@ -97,8 +97,10 @@ HERE @expect = [ [SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant, SetSlot,RegisterTransfer,FunctionCall,GetSlot], [RegisterTransfer,GetSlot,FunctionReturn]] - check + was = check + set = was[0].codes[7] + assert_equal SetSlot , set.class + assert_equal 8, set.index , "Set to message must be offset, not #{set.index}" end - end end