fix while.to_vool
sanitize normalizer on the way - return ruby, let caller to_vool - return single statement, not single? statements
This commit is contained in:
@ -14,11 +14,9 @@ module Ruby
|
||||
|
||||
def to_vool
|
||||
cond , rest = *normalize_name(@condition)
|
||||
fals = @if_false ? @if_false.to_vool : nil
|
||||
me = Vool::IfStatement.new(cond , @if_true.to_vool, fals)
|
||||
me = Vool::IfStatement.new(cond.to_vool , @if_true.to_vool, @if_false&.to_vool)
|
||||
return me unless rest
|
||||
rest << me
|
||||
rest
|
||||
Vool::Statements.new([ rest.to_vool , me])
|
||||
end
|
||||
|
||||
def has_false?
|
||||
|
@ -12,11 +12,10 @@ module Ruby
|
||||
if( condition.is_a?(ScopeStatement) and condition.single?)
|
||||
condition = condition.first
|
||||
end
|
||||
return [condition.to_vool] if condition.is_a?(Named) or condition.is_a?(Constant)
|
||||
condition = condition.to_vool
|
||||
return [condition] if condition.is_a?(Named) or condition.is_a?(Constant)
|
||||
local = "tmp_#{object_id}".to_sym
|
||||
assign = Vool::Statements.new [Vool::LocalAssignment.new( local , condition)]
|
||||
[Vool::LocalVariable.new(local) , assign]
|
||||
assign = LocalAssignment.new( local , condition)
|
||||
[LocalVariable.new(local) , assign]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ module Ruby
|
||||
|
||||
def to_vool
|
||||
cond , rest = *normalize_name(@condition)
|
||||
WhileStatement.new(cond , @body.normalize , rest)
|
||||
Vool::WhileStatement.new(cond.to_vool , @body.to_vool , rest&.to_vool)
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
|
Reference in New Issue
Block a user