From 1685ba5a4496823823d6161a1e559fa645d127cf Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 27 Apr 2018 21:55:41 +0300 Subject: [PATCH] fix send normalisation --- lib/vool/statements/send_statement.rb | 5 +++-- test/vool/normalization/test_send_statement.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/vool/statements/send_statement.rb b/lib/vool/statements/send_statement.rb index b98efe39..16d5dffe 100644 --- a/lib/vool/statements/send_statement.rb +++ b/lib/vool/statements/send_statement.rb @@ -20,7 +20,7 @@ module Vool def normalize statements = Statements.new([]) arguments = [] - @arguments.dup.each_with_index do |arg , index | + @arguments.each_with_index do |arg , index | normalize_arg(arg , arguments , statements) end if statements.empty? @@ -30,6 +30,7 @@ module Vool return statements end end + def normalize_arg(arg , arguments , statements) if arg.respond_to?(:slot_definition) and !arg.is_a?(SendStatement) arguments << arg @@ -37,7 +38,7 @@ module Vool end assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg) statements << assign - arguments << assign.name + arguments << LocalVariable.new(assign.name) end def to_s diff --git a/test/vool/normalization/test_send_statement.rb b/test/vool/normalization/test_send_statement.rb index 2df12806..d58133b9 100644 --- a/test/vool/normalization/test_send_statement.rb +++ b/test/vool/normalization/test_send_statement.rb @@ -30,6 +30,18 @@ module Vool def test_assigned assert_equal SendStatement , @stm.first.value.class end + def test_length + assert_equal 2 , @stm.length + end + def test_last_class + assert_equal SendStatement , @stm.last.class + end + def test_last_arg + assert_equal LocalVariable , @stm.last.arguments.first.class + end + def test_last_send + assert_equal :foo , @stm.last.name + end end end end