work on branches

the concept is different in bosl, move appropriate to virtual
This commit is contained in:
Torsten Ruger
2015-10-07 10:02:51 +03:00
parent 4e26166dff
commit f0611e52db
7 changed files with 17 additions and 35 deletions

View File

@ -12,11 +12,10 @@ module Bosl
true_block = @method.source.new_block "if_true" # second, linked in after current, before merge
false_block = @method.source.new_block "if_false" # directly next in order, ie if we don't jump we land here
is = process(condition )
is = process(condition)
# TODO should/will use different branches for different conditions.
# just a scetch : cond_val = cond_val.is_true?(method) unless cond_val.is_a? BranchCondition
@method.source.add_code Virtual::IsTrueBranch.new( true_block )
@method.source.add_code Register::IsZeroBranch.new( condition , true_block )
# compile the true block (as we think of it first, even it is second in sequential order)
@method.source.current true_block
@ -26,7 +25,7 @@ module Bosl
# compile the false block
@method.source.current false_block
last = process_all(if_false).last if if_false
@method.source.add_code Virtual::UnconditionalBranch.new( merge_block )
@method.source.add_code Register::AlwaysBranch.new(expression, merge_block )
#puts "compiled if: end"
@method.source.current merge_block

View File

@ -14,12 +14,12 @@ module Bosl
cond = process(condition)
@method.source.add_code Virtual::IsTrueBranch.new(merge)
@method.source.add_code Register::IsZeroBranch.new(condition,merge)
last = process_all(expressions).last
# unconditionally branch to the start
@method.source.add_code Virtual::UnconditionalBranch.new(start)
@method.source.add_code Register::AlwaysBranch.new(expression,start)
# continue execution / compiling at the merge block
@method.source.current merge