simple sends and all whiles working

This commit is contained in:
Torsten Ruger
2018-03-16 18:41:17 +05:30
parent 35a0952943
commit da0e1cdc5f
7 changed files with 40 additions and 40 deletions

View File

@ -7,7 +7,11 @@ module Vool
# eg if( @var % 5) is not normalized
# but if(tmp_123) is with tmp_123 = @var % 5 hoited above the if
def normalize_name( condition )
if( condition.is_a?(ScopeStatement) and condition.single?)
condition = condition.first
end
return [condition] if condition.is_a?(Named)
condition = condition.normalize
local = "tmp_#{object_id}"
assign = Statements.new [LocalAssignment.new( local , condition)]
[LocalVariable.new(local) , assign]

View File

@ -11,7 +11,7 @@ module Vool
end
def normalize
cond , rest = *normalize_name(@condition.normalize)
cond , rest = *normalize_name(@condition)
me = WhileStatement.new(cond , @body.normalize)
return me unless rest
rest << me