fx ruby send args

This commit is contained in:
Torsten Ruger 2018-07-20 20:06:14 +03:00
parent d03592dfb1
commit 0238874c20
6 changed files with 13 additions and 9 deletions

View File

@ -27,7 +27,7 @@ module Ruby
arguments << arg.to_vool arguments << arg.to_vool
return return
end 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 statements << assign
arguments << Vool::LocalVariable.new(assign.name) arguments << Vool::LocalVariable.new(assign.name)
end end

View File

@ -27,7 +27,7 @@ module Ruby
arguments << arg arguments << arg
return return
end 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 statements << assign
arguments << LocalVariable.new(assign.name) arguments << LocalVariable.new(assign.name)
end end

View File

@ -15,5 +15,10 @@ module Vool
at_depth(depth , "#{@name} = #{@value}") at_depth(depth , "#{@name} = #{@value}")
end end
def chain_assign(assign , compiler)
return assign unless @value.is_a?(SendStatement)
@value.to_mom(compiler) << assign
end
end end
end end

View File

@ -8,11 +8,7 @@ module Vool
from = @value.slot_definition(compiler) from = @value.slot_definition(compiler)
return chain_assign( Mom::SlotLoad.new(to,from) , compiler) return chain_assign( Mom::SlotLoad.new(to,from) , compiler)
end end
def chain_assign(assign , compiler)
return assign unless @value.is_a?(SendStatement)
@value.to_mom(compiler) << assign
end
end end
end end

View File

@ -27,6 +27,9 @@ module Vool
@statements << o @statements << o
self self
end end
def prepend(o)
@statements = [o] + @statements
end
# create mom instructions # create mom instructions
def to_mom( compiler ) def to_mom( compiler )

View File

@ -70,7 +70,7 @@ module Ruby
def test_instance_return def test_instance_return
lst = compile( "return @var" ).to_vool lst = compile( "return @var" ).to_vool
assert_equal InstanceVariable , lst.return_value.class assert_equal Vool::InstanceVariable , lst.return_value.class
end end
def test_class_basic def test_class_basic
@ -81,7 +81,7 @@ module Ruby
def test_class_return def test_class_return
lst = compile( "return @@var" ).to_vool lst = compile( "return @@var" ).to_vool
assert_equal ClassVariable , lst.return_value.class assert_equal Vool::ClassVariable , lst.return_value.class
end end
def test_module_basic def test_module_basic