more fix for multilevel constant load
was ignoring first level which is already the second for a constant as the constant is the first load. first interpreter test working but looking dodgy
This commit is contained in:
@ -7,10 +7,11 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = "r = 5.mod4"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||
LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant ,
|
||||
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
@ -18,7 +19,7 @@ module Risc
|
||||
|
||||
def test_constant_load
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.next(11).constant.value
|
||||
assert_equal 5 , produced.next(16).constant.value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,15 +7,17 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = "@a.mod4"
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, NotSame, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, NotSame, SlotToReg ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot ,
|
||||
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot ,
|
||||
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot ,
|
||||
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant ,
|
||||
FunctionCall, Label, SlotToReg, RegToSlot, Label, LoadConstant ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot ,
|
||||
LoadConstant, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, DynamicJump]
|
||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, DynamicJump]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
@ -23,21 +25,22 @@ module Risc
|
||||
end
|
||||
def test_function_call
|
||||
produced = produce_body
|
||||
assert_equal DynamicJump , produced.next(52).class
|
||||
assert_equal DynamicJump , produced.next(63).class
|
||||
end
|
||||
def test_load_address
|
||||
produced = produce_body
|
||||
assert_equal Parfait::CacheEntry , produced.next(50).constant.class
|
||||
assert_equal LoadConstant , produced.next(61).class
|
||||
assert_equal Parfait::CacheEntry , produced.next(61).constant.class
|
||||
end
|
||||
def test_cache_check
|
||||
produced = produce_body
|
||||
assert_equal NotSame , produced.next(3).class
|
||||
assert_equal produced.next(34) , produced.next(3).label
|
||||
assert_equal NotSame , produced.next(4).class
|
||||
assert_equal produced.next(40) , produced.next(4).label
|
||||
end
|
||||
def test_check_resolve
|
||||
produced = produce_body
|
||||
assert_equal FunctionCall , produced.next(30).class
|
||||
assert_equal :resolve_method ,produced.next(30).method.name
|
||||
assert_equal FunctionCall , produced.next(36).class
|
||||
assert_equal :resolve_method ,produced.next(36).method.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,10 +7,11 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = "5.mod4"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||
LoadConstant, FunctionCall, Label]
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant ,
|
||||
FunctionCall, Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
@ -18,24 +19,24 @@ module Risc
|
||||
end
|
||||
def test_function_call
|
||||
produced = produce_body
|
||||
assert_equal FunctionCall , produced.next(19).class
|
||||
assert_equal :mod4 , produced.next(19).method.name
|
||||
assert_equal FunctionCall , produced.next(24).class
|
||||
assert_equal :mod4 , produced.next(24).method.name
|
||||
end
|
||||
def test_check_continue
|
||||
produced = produce_body
|
||||
assert produced.next(20).name.start_with?("continue_")
|
||||
assert produced.next(25).name.start_with?("continue_")
|
||||
end
|
||||
def test_load_label
|
||||
produced = produce_body
|
||||
assert_equal Label , produced.next(14).constant.class
|
||||
assert_equal Label , produced.next(19).constant.class
|
||||
end
|
||||
def test_load_5
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.next(11).constant.value
|
||||
assert_equal 5 , produced.next(16).constant.value
|
||||
end
|
||||
def test_call_reg_setup
|
||||
produced = produce_body
|
||||
assert_equal produced.next(18).register , produced.next(19).register
|
||||
assert_equal produced.next(23).register , produced.next(24).register
|
||||
end
|
||||
#TODO check the message setup, type and frame moves
|
||||
end
|
||||
|
Reference in New Issue
Block a user