fix the resolve

without return and not being a function
This commit is contained in:
Torsten Ruger
2018-04-08 22:30:18 +03:00
parent e5d014b936
commit 580c53cdae
5 changed files with 58 additions and 84 deletions

View File

@ -9,42 +9,40 @@ module Risc
@input = "@a.mod4"
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
IsZero, SlotToReg, SlotToReg, LoadConstant, RegToSlot,
LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label,
SlotToReg, LoadConstant, RegToSlot, Label, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
DynamicJump]
LoadConstant, LoadConstant, SlotToReg, SlotToReg, Label,
LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg,
OperatorInstruction, IsZero, SlotToReg, Branch, Label,
Transfer, Syscall, Transfer, Transfer, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot,
Label, RegToSlot, Label, LoadConstant, LoadConstant,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, DynamicJump]
end
def test_send_instructions
assert_nil msg = check_nil , msg
end
def test_function_call
def test_sys
produced = produce_body
assert_equal DynamicJump , produced.next(65).class
assert_equal Syscall , produced.next(26).class
assert_equal :exit , produced.next(26).name
end
def test_load_address
produced = produce_body
assert_equal LoadConstant , produced.next(63).class
assert_equal Parfait::CacheEntry , produced.next(63).constant.class
assert_equal LoadConstant , produced.next(38).class
assert_equal Parfait::CacheEntry , produced.next(38).constant.class
end
def test_function_call
produced = produce_body
assert_equal DynamicJump , produced.next(59).class
end
def test_cache_check
produced = produce_body
assert_equal IsZero , produced.next(5).class
assert_equal Label , produced.next(43).class
assert_equal produced.next(43) , produced.next(5).label
end
def test_check_resolve
produced = produce_body
assert_equal FunctionCall , produced.next(38).class
assert_equal :resolve_method ,produced.next(38).method.name
assert_equal Label , produced.next(37).class
assert_equal produced.next(37) , produced.next(5).label
end
end
end

View File

@ -14,25 +14,11 @@ module Risc
check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero,
SlotToReg, SlotToReg, LoadConstant, RegToSlot, LoadConstant,
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, LoadConstant, FunctionCall, Label, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, Label,
LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg,
OperatorInstruction, IsNotZero, Label, SlotToReg, Branch,
Label, LoadConstant, SlotToReg, OperatorInstruction, IsZero,
SlotToReg, OperatorInstruction, IsNotZero, Label, SlotToReg,
Branch, Label, LoadConstant, SlotToReg, OperatorInstruction,
IsZero, SlotToReg, OperatorInstruction, IsNotZero, Label,
SlotToReg, Branch, Label, LoadConstant, SlotToReg,
OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, IsNotZero,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, LoadConstant, RegToSlot,
Label, LoadConstant, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg]
LoadConstant, SlotToReg, SlotToReg, Label, LoadConstant,
SlotToReg, OperatorInstruction, IsZero, SlotToReg, OperatorInstruction,
IsZero, SlotToReg, Branch, Label, LoadConstant,
SlotToReg, OperatorInstruction, IsZero, Label, Transfer,
Syscall, NilClass]
#assert_equal 1 , get_return
end
@ -41,24 +27,10 @@ module Risc
assert_equal FunctionCall , call_ins.class
assert_equal :main , call_ins.method.name
end
def test_call_resolve
call_ins = main_ticks(43)
assert_equal FunctionCall , call_ins.class
assert_equal :resolve_method , call_ins.method.name
end
def test_label
call_ins = main_ticks(44)
assert_equal Label , call_ins.class
assert_equal "Word_Type.resolve_method" , call_ins.name
end
def test_arg_15_to_resolve
sl = main_ticks( 47 )
assert_equal SlotToReg , sl.class
assert_equal :r2 , sl.array.symbol #load from message
assert_equal 2 , sl.index
assert_equal :r2 , sl.register.symbol
assert_equal Parfait::Integer, @interpreter.get_register( :r2 ).class
assert_equal 15, @interpreter.get_register( :r2 ).value
def test_load_entry
call_ins = main_ticks(5)
assert_equal LoadConstant , call_ins.class
assert_equal Parfait::CacheEntry , call_ins.constant.class
end
def est_dyn

View File

@ -21,6 +21,10 @@ module Risc
move = @r0 << Parfait.object_space
assert_equal LoadConstant , move.class
end
def test_load_symbol
move = @r1 << :puts
assert_equal LoadConstant , move.class
end
def test_transfer
transfer = @r0 << @r1
assert_equal Transfer , transfer.class