fix send normalisation
This commit is contained in:
parent
672ccb351d
commit
1685ba5a44
@ -20,7 +20,7 @@ module Vool
|
|||||||
def normalize
|
def normalize
|
||||||
statements = Statements.new([])
|
statements = Statements.new([])
|
||||||
arguments = []
|
arguments = []
|
||||||
@arguments.dup.each_with_index do |arg , index |
|
@arguments.each_with_index do |arg , index |
|
||||||
normalize_arg(arg , arguments , statements)
|
normalize_arg(arg , arguments , statements)
|
||||||
end
|
end
|
||||||
if statements.empty?
|
if statements.empty?
|
||||||
@ -30,6 +30,7 @@ module Vool
|
|||||||
return statements
|
return statements
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_arg(arg , arguments , statements)
|
def normalize_arg(arg , arguments , statements)
|
||||||
if arg.respond_to?(:slot_definition) and !arg.is_a?(SendStatement)
|
if arg.respond_to?(:slot_definition) and !arg.is_a?(SendStatement)
|
||||||
arguments << arg
|
arguments << arg
|
||||||
@ -37,7 +38,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg)
|
assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg)
|
||||||
statements << assign
|
statements << assign
|
||||||
arguments << assign.name
|
arguments << LocalVariable.new(assign.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
@ -30,6 +30,18 @@ module Vool
|
|||||||
def test_assigned
|
def test_assigned
|
||||||
assert_equal SendStatement , @stm.first.value.class
|
assert_equal SendStatement , @stm.first.value.class
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user