diff --git a/lib/ruby/send_statement.rb b/lib/ruby/send_statement.rb index 0b8a0303..cd80b8fb 100644 --- a/lib/ruby/send_statement.rb +++ b/lib/ruby/send_statement.rb @@ -27,7 +27,7 @@ module Ruby arguments << arg.to_vool return end - assign = Vool::LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg) + assign = Vool::LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg.to_vool) statements << assign arguments << Vool::LocalVariable.new(assign.name) end diff --git a/lib/ruby/yield_statement.rb b/lib/ruby/yield_statement.rb index 27817860..946d6bf2 100644 --- a/lib/ruby/yield_statement.rb +++ b/lib/ruby/yield_statement.rb @@ -27,7 +27,7 @@ module Ruby arguments << arg return end - assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg) + assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg.to_vool) statements << assign arguments << LocalVariable.new(assign.name) end diff --git a/lib/vool/assignment.rb b/lib/vool/assignment.rb index 1c44135f..67a3e6cb 100644 --- a/lib/vool/assignment.rb +++ b/lib/vool/assignment.rb @@ -15,5 +15,10 @@ module Vool at_depth(depth , "#{@name} = #{@value}") end + + def chain_assign(assign , compiler) + return assign unless @value.is_a?(SendStatement) + @value.to_mom(compiler) << assign + end end end diff --git a/lib/vool/local_assignment.rb b/lib/vool/local_assignment.rb index 6533f7ed..c8f423d3 100644 --- a/lib/vool/local_assignment.rb +++ b/lib/vool/local_assignment.rb @@ -8,11 +8,7 @@ module Vool from = @value.slot_definition(compiler) return chain_assign( Mom::SlotLoad.new(to,from) , compiler) end - - def chain_assign(assign , compiler) - return assign unless @value.is_a?(SendStatement) - @value.to_mom(compiler) << assign - end + end end diff --git a/lib/vool/statements.rb b/lib/vool/statements.rb index 58fbb74c..60484f74 100644 --- a/lib/vool/statements.rb +++ b/lib/vool/statements.rb @@ -27,6 +27,9 @@ module Vool @statements << o self end + def prepend(o) + @statements = [o] + @statements + end # create mom instructions def to_mom( compiler ) diff --git a/test/ruby/test_variables.rb b/test/ruby/test_variables.rb index 1dc1e32a..859b5842 100644 --- a/test/ruby/test_variables.rb +++ b/test/ruby/test_variables.rb @@ -70,7 +70,7 @@ module Ruby def test_instance_return lst = compile( "return @var" ).to_vool - assert_equal InstanceVariable , lst.return_value.class + assert_equal Vool::InstanceVariable , lst.return_value.class end def test_class_basic @@ -81,7 +81,7 @@ module Ruby def test_class_return lst = compile( "return @@var" ).to_vool - assert_equal ClassVariable , lst.return_value.class + assert_equal Vool::ClassVariable , lst.return_value.class end def test_module_basic