fix the if syntax and branches
This commit is contained in:
@ -103,14 +103,16 @@ module Interpreter
|
||||
end
|
||||
|
||||
def execute_IsZero
|
||||
#puts @instruction.inspect
|
||||
if( @flags[:zero] )
|
||||
target = @instruction.block
|
||||
set_block target
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
@flags[:zero] ? execute_Branch : true
|
||||
end
|
||||
def execute_IsNotzero
|
||||
@flags[:zero] ? true : execute_Branch
|
||||
end
|
||||
def execute_IsPlus
|
||||
@flags[:plus] ? execute_Branch : true
|
||||
end
|
||||
def execute_IsMinus
|
||||
@flags[:minus] ? execute_Branch : true
|
||||
end
|
||||
|
||||
def execute_LoadConstant
|
||||
|
@ -13,9 +13,8 @@ module Phisol
|
||||
false_block = @method.source.new_block "if_false" # directly next in order, ie if we don't jump we land here
|
||||
|
||||
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 Register::IsZero.new( condition , true_block )
|
||||
branch_class = Object.const_get "Register::Is#{branch_type.capitalize}"
|
||||
@method.source.add_code branch_class.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
|
||||
|
Reference in New Issue
Block a user