diff --git a/lib/vool/statements/assign_statement.rb b/lib/vool/statements/assign_statement.rb index 89ba9dd3..eb181cd9 100644 --- a/lib/vool/statements/assign_statement.rb +++ b/lib/vool/statements/assign_statement.rb @@ -7,9 +7,28 @@ module Vool end def normalize() - raise "not named left #{name.class}" unless @name.is_a?(Symbol) - raise "unsupported right #{value}" unless @value.is_a?(Named) or - @value.is_a?(SendStatement) or @value.is_a?(Constant) + raise "not named left #{name.class}" unless name.is_a?(Symbol) + case value + when Named , Constant + return copy + when SendStatement + return normalize_send + else + raise "unsupported right #{value}" + end + end + + def copy(value = nil) + value ||= @value + self.class.new(name,value) + end + + def normalize_send + statements = value.normalize() + return copy( statements ) if statements.is_a?(SendStatement) + assign = statements.statements.pop + statements << copy(assign) + statements end def chain_assign(assign , method) diff --git a/lib/vool/statements/local_assignment.rb b/lib/vool/statements/local_assignment.rb index a2305e5b..b71f33f5 100644 --- a/lib/vool/statements/local_assignment.rb +++ b/lib/vool/statements/local_assignment.rb @@ -2,11 +2,6 @@ module Vool class LocalAssignment < Assignment - def normalize - super - return LocalAssignment.new(@name , @value) - end - def to_mom( method ) if method.arguments_type.variable_index(@name) type = :arguments diff --git a/test/risc/methods/test_call_fibo.rb b/test/risc/methods/test_call_fibo.rb index ed8ad183..c636bbf9 100644 --- a/test/risc/methods/test_call_fibo.rb +++ b/test/risc/methods/test_call_fibo.rb @@ -3,7 +3,26 @@ require_relative 'helper' module Methods class TestFibo < MethodsTest - def est_ruby_adds + def test_count_down + run_space <