adjust branch names
IsXXX with xxx as condition, same as after if_xxx AlwaysBranch is back to Branch
This commit is contained in:
parent
50379a1fea
commit
1fd937927c
@ -96,13 +96,13 @@ module Interpreter
|
||||
end
|
||||
|
||||
# Instruction interpretation starts here
|
||||
def execute_AlwaysBranch
|
||||
def execute_Branch
|
||||
target = @instruction.block
|
||||
set_block target
|
||||
false
|
||||
end
|
||||
|
||||
def execute_IsZeroBranch
|
||||
def execute_IsZero
|
||||
#puts @instruction.inspect
|
||||
if( @flags[:zero] )
|
||||
target = @instruction.block
|
||||
|
@ -15,7 +15,7 @@ module Phisol
|
||||
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::IsZeroBranch.new( condition , true_block )
|
||||
@method.source.add_code Register::IsZero.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
|
||||
@ -25,7 +25,7 @@ module Phisol
|
||||
# compile the false block
|
||||
@method.source.current false_block
|
||||
last = process_all(if_false).last if if_false
|
||||
@method.source.add_code Register::AlwaysBranch.new(statement, merge_block )
|
||||
@method.source.add_code Register::Branch.new(statement, merge_block )
|
||||
|
||||
#puts "compiled if: end"
|
||||
@method.source.current merge_block
|
||||
|
@ -14,12 +14,12 @@ module Phisol
|
||||
|
||||
cond = process(condition)
|
||||
|
||||
@method.source.add_code Register::IsZeroBranch.new(condition,merge)
|
||||
@method.source.add_code Register::IsZero.new(condition,merge)
|
||||
|
||||
last = process_all(statements).last
|
||||
|
||||
# unconditionally branch to the start
|
||||
@method.source.add_code Register::AlwaysBranch.new(statement,start)
|
||||
@method.source.add_code Register::Branch.new(statement,start)
|
||||
|
||||
# continue execution / compiling at the merge block
|
||||
@method.source.current merge
|
||||
|
@ -16,16 +16,16 @@ module Register
|
||||
alias :inspect :to_s
|
||||
end
|
||||
|
||||
class IsZeroBranch < Branch
|
||||
class IsZero < Branch
|
||||
end
|
||||
|
||||
class IsNegativeBranch < Branch
|
||||
class IsNotzero < Branch
|
||||
end
|
||||
|
||||
class IsPositiveBranch < Branch
|
||||
class IsMinus < Branch
|
||||
end
|
||||
|
||||
class AlwaysBranch < Branch
|
||||
class IsPlus < Branch
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -118,7 +118,7 @@ module Virtual
|
||||
def boot
|
||||
boot_parfait!
|
||||
@init = Block.new("init", :__init__ )
|
||||
branch = Register::AlwaysBranch.new( "__init__" , self.space.get_init.source.blocks.first )
|
||||
branch = Register::Branch.new( "__init__" , self.space.get_init.source.blocks.first )
|
||||
@init.add_code branch
|
||||
@booted = true
|
||||
self
|
||||
|
@ -17,8 +17,8 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,LoadConstant,
|
||||
OperatorInstruction,IsZeroBranch] ,
|
||||
[LoadConstant,AlwaysBranch] ,[LoadConstant] ,[] ,
|
||||
OperatorInstruction,IsZero] ,
|
||||
[LoadConstant,Branch] ,[LoadConstant] ,[] ,
|
||||
[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
@ -35,8 +35,8 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,LoadConstant,
|
||||
OperatorInstruction,IsZeroBranch] ,
|
||||
[AlwaysBranch] ,[LoadConstant] ,[] ,
|
||||
OperatorInstruction,IsZero] ,
|
||||
[Branch] ,[LoadConstant] ,[] ,
|
||||
[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
|
@ -15,7 +15,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn],[LoadConstant,IsZeroBranch,LoadConstant,AlwaysBranch],
|
||||
@expect = [[SaveReturn],[LoadConstant,IsZero,LoadConstant,Branch],
|
||||
[],[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
@ -32,7 +32,7 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],[GetSlot,GetSlot,LoadConstant,OperatorInstruction,
|
||||
IsZeroBranch,GetSlot,GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,AlwaysBranch],
|
||||
IsZero,GetSlot,GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,Branch],
|
||||
[],[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
@ -51,9 +51,9 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],
|
||||
[GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsZeroBranch,GetSlot,
|
||||
[GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsZero,GetSlot,
|
||||
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,GetSlot,
|
||||
GetSlot,AlwaysBranch] ,
|
||||
GetSlot,Branch] ,
|
||||
[],[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ class AddTest < MiniTest::Test
|
||||
|
||||
def test_branch
|
||||
was = @interpreter.block
|
||||
assert_equal Register::AlwaysBranch , ticks(1).class
|
||||
assert_equal Register::Branch , ticks(1).class
|
||||
assert was != @interpreter.block
|
||||
end
|
||||
def test_load
|
||||
@ -66,7 +66,7 @@ class AddTest < MiniTest::Test
|
||||
|
||||
def test_chain
|
||||
#show_ticks # get output of what is
|
||||
["AlwaysBranch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||
"FunctionCall","SaveReturn","LoadConstant","LoadConstant","OperatorInstruction",
|
||||
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
|
||||
"NilClass"].each_with_index do |name , index|
|
||||
|
@ -59,7 +59,7 @@ HERE
|
||||
@interpreter = Interpreter::Interpreter.new
|
||||
@interpreter.start Virtual.machine.init
|
||||
#show_ticks # get output of what is
|
||||
["AlwaysBranch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||
"FunctionCall","SaveReturn","GetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","SaveReturn",
|
||||
"LoadConstant","GetSlot","SetSlot","GetSlot","GetSlot",
|
||||
@ -67,22 +67,22 @@ HERE
|
||||
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","IsZeroBranch","GetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","IsZero","GetSlot","GetSlot",
|
||||
"GetSlot","SetSlot","LoadConstant","SetSlot","GetSlot",
|
||||
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","IsZeroBranch","GetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","IsZero","GetSlot","GetSlot",
|
||||
"GetSlot","SetSlot","LoadConstant","SetSlot","GetSlot",
|
||||
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","IsZeroBranch","GetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","IsZero","GetSlot","GetSlot",
|
||||
"GetSlot","SetSlot","LoadConstant","SetSlot","GetSlot",
|
||||
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","IsZeroBranch","GetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","IsZero","GetSlot","GetSlot",
|
||||
"GetSlot"].each_with_index do |name , index|
|
||||
got = ticks(1)
|
||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||
|
@ -26,7 +26,7 @@ class TestPuts < MiniTest::Test
|
||||
|
||||
def test_branch
|
||||
was = @interpreter.block
|
||||
assert_equal Register::AlwaysBranch , ticks(1).class
|
||||
assert_equal Register::Branch , ticks(1).class
|
||||
assert was != @interpreter.block
|
||||
end
|
||||
def test_load
|
||||
@ -56,7 +56,7 @@ class TestPuts < MiniTest::Test
|
||||
|
||||
def test_chain
|
||||
#show_ticks # get output of what is
|
||||
["AlwaysBranch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||
"FunctionCall","SaveReturn","GetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","SaveReturn",
|
||||
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer",
|
||||
|
Loading…
Reference in New Issue
Block a user