store method, not name, in message
changes the calling and thus too many test
This commit is contained in:
@ -9,10 +9,10 @@ module Risc
|
||||
@input = "r = 5.div4"
|
||||
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg,
|
||||
SlotToReg, RegToSlot]
|
||||
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
|
||||
RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
@ -20,7 +20,7 @@ module Risc
|
||||
|
||||
def test_constant_load
|
||||
produced = produce_body
|
||||
load = produced.next(15)
|
||||
load = produced.next(14)
|
||||
assert_equal LoadConstant , load.class
|
||||
assert_equal 5 , load.constant.value
|
||||
end
|
||||
|
@ -17,10 +17,10 @@ module Risc
|
||||
RegToSlot, RegToSlot, Label, RegToSlot, Label,
|
||||
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant,
|
||||
SlotToReg, DynamicJump, Label]
|
||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
|
||||
DynamicJump, Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
@ -38,7 +38,7 @@ module Risc
|
||||
end
|
||||
def test_function_call
|
||||
produced = produce_body
|
||||
assert_equal DynamicJump , produced.next(66).class
|
||||
assert_equal DynamicJump , produced.next(65).class
|
||||
end
|
||||
def test_cache_check
|
||||
produced = produce_body
|
||||
|
@ -9,9 +9,9 @@ module Risc
|
||||
@input = "5.div4"
|
||||
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, SlotToReg, FunctionCall, Label]
|
||||
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
SlotToReg, FunctionCall, Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
@ -19,24 +19,24 @@ module Risc
|
||||
end
|
||||
def test_load_5
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.next(15).constant.value
|
||||
assert_equal 5 , produced.next(14).constant.value
|
||||
end
|
||||
def test_load_label
|
||||
produced = produce_body
|
||||
assert_equal Label , produced.next(18).constant.class
|
||||
assert_equal Label , produced.next(17).constant.class
|
||||
end
|
||||
def test_call_reg_setup
|
||||
produced = produce_body
|
||||
assert_equal :div4 , produced.next(22).method.name
|
||||
assert_equal :div4 , produced.next(21).method.name
|
||||
end
|
||||
def test_function_call
|
||||
produced = produce_body
|
||||
assert_equal FunctionCall , produced.next(22).class
|
||||
assert_equal :div4 , produced.next(22).method.name
|
||||
assert_equal FunctionCall , produced.next(21).class
|
||||
assert_equal :div4 , produced.next(21).method.name
|
||||
end
|
||||
def test_check_continue
|
||||
produced = produce_body
|
||||
assert produced.next(23).name.start_with?("continue_")
|
||||
assert produced.next(22).name.start_with?("continue_")
|
||||
end
|
||||
#TODO check the message setup, type and frame moves
|
||||
end
|
||||
|
@ -9,10 +9,10 @@ module Risc
|
||||
@input = "5.get_internal_word(1)"
|
||||
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
SlotToReg, FunctionCall, Label]
|
||||
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
||||
FunctionCall, Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
@ -20,16 +20,16 @@ module Risc
|
||||
end
|
||||
def test_load_5
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.next(15).constant.value
|
||||
assert_equal 5 , produced.next(14).constant.value
|
||||
end
|
||||
def base
|
||||
18
|
||||
17
|
||||
end
|
||||
def test_load_arg_const
|
||||
produced = produce_body
|
||||
assert_equal LoadConstant , produced.next(base).class
|
||||
assert_equal Parfait::Integer , produced.next(base).constant.class
|
||||
assert_equal 1 , produced.next(18).constant.value
|
||||
assert_equal 1 , produced.next(base).constant.value
|
||||
end
|
||||
def test_load_next_m
|
||||
produced = produce_body
|
||||
|
@ -10,9 +10,9 @@ module Risc
|
||||
@input = "5.div4"
|
||||
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, SlotToReg, FunctionCall, Label]
|
||||
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
SlotToReg, FunctionCall, Label]
|
||||
@produced = produce_body
|
||||
end
|
||||
|
||||
@ -66,22 +66,16 @@ module Risc
|
||||
sl = @produced.next( 10 )
|
||||
assert_reg_to_slot( sl , :r4 , :r5 , 0 )
|
||||
end
|
||||
|
||||
def test_get_name
|
||||
def test_store_method_in_message
|
||||
sl = @produced.next( 11 )
|
||||
assert_slot_to_reg( sl , :r1 , 1 , :r6 )
|
||||
assert_reg_to_slot( sl , :r1 , :r3 , 7 )
|
||||
end
|
||||
def test_store_name_in_message
|
||||
sl = @produced.next( 12 )
|
||||
assert_reg_to_slot( sl , :r6 , :r3 , 7 )
|
||||
end
|
||||
|
||||
def test_get_next_next #reduce onto itself
|
||||
sl = @produced.next( 13 )
|
||||
sl = @produced.next( 12 )
|
||||
assert_slot_to_reg( sl , :r3 , 1 , :r3 )
|
||||
end
|
||||
def test_store_next_next_in_space
|
||||
sl = @produced.next( 14 )
|
||||
sl = @produced.next( 13 )
|
||||
assert_reg_to_slot( sl , :r3 , :r2 , 3 )
|
||||
end
|
||||
end
|
||||
|
@ -9,12 +9,12 @@ module Risc
|
||||
@input = "return 5.div4"
|
||||
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
SlotToReg, FunctionReturn]
|
||||
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
|
||||
FunctionReturn]
|
||||
end
|
||||
|
||||
def test_return_instructions
|
||||
@ -22,12 +22,12 @@ module Risc
|
||||
end
|
||||
def test_function_return
|
||||
produced = produce_body
|
||||
assert_equal FunctionReturn , produced.next(36).class
|
||||
assert_equal FunctionReturn , produced.next(35).class
|
||||
end
|
||||
def test_load_5
|
||||
produced = produce_body
|
||||
assert_equal LoadConstant , produced.next(15).class
|
||||
assert_equal 5 , produced.next(15).constant.value
|
||||
assert_equal LoadConstant , produced.next(14).class
|
||||
assert_equal 5 , produced.next(14).constant.value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,13 +17,12 @@ module Risc
|
||||
RegToSlot, RegToSlot, Label, RegToSlot, Label,
|
||||
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant,
|
||||
SlotToReg, DynamicJump, Label, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
|
||||
FunctionReturn]
|
||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
|
||||
DynamicJump, Label, SlotToReg, SlotToReg, RegToSlot,
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn]
|
||||
end
|
||||
|
||||
def test_return_instructions
|
||||
@ -31,7 +30,7 @@ module Risc
|
||||
end
|
||||
def test_function_return
|
||||
produced = produce_body
|
||||
assert_equal FunctionReturn , produced.next(80).class
|
||||
assert_equal FunctionReturn , produced.next(79).class
|
||||
end
|
||||
def test_cache_check
|
||||
produced = produce_body
|
||||
|
@ -9,13 +9,13 @@ module Risc
|
||||
@input = "while(5 > 0) ; @a = true; end"
|
||||
@expect = [Label, LoadConstant, LoadConstant, SlotToReg, RegToSlot,
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg,
|
||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, LoadConstant,
|
||||
OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, IsZero,
|
||||
LoadConstant, SlotToReg, RegToSlot, Branch, Label]
|
||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction,
|
||||
IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
|
||||
SlotToReg, RegToSlot, Branch, Label]
|
||||
end
|
||||
|
||||
def test_while_instructions
|
||||
@ -26,33 +26,33 @@ module Risc
|
||||
end
|
||||
def test_int_load_5
|
||||
produced = produce_body
|
||||
load = produced.next(16)
|
||||
load = produced.next(15)
|
||||
assert_equal Risc::LoadConstant , load.class
|
||||
assert_equal Parfait::Integer , load.constant.class
|
||||
assert_equal 5 , load.constant.value
|
||||
end
|
||||
def test_int_load_0
|
||||
produced = produce_body
|
||||
load = produced.next(19)
|
||||
load = produced.next(18)
|
||||
assert_equal Risc::LoadConstant , load.class
|
||||
assert_equal Parfait::Integer , load.constant.class
|
||||
assert_equal 0 , load.constant.value
|
||||
end
|
||||
def test_false_check
|
||||
produced = produce_body
|
||||
assert_equal Risc::IsZero , produced.next(36).class
|
||||
assert produced.next(36).label.name.start_with?("merge_label") , produced.next(36).label.name
|
||||
assert_equal Risc::IsZero , produced.next(35).class
|
||||
assert produced.next(35).label.name.start_with?("merge_label") , produced.next(35).label.name
|
||||
end
|
||||
def test_nil_load
|
||||
produced = produce_body
|
||||
assert_equal Risc::LoadConstant , produced.next(37).class
|
||||
assert_equal Parfait::NilClass , produced.next(37).constant.class
|
||||
assert_equal Risc::LoadConstant , produced.next(36).class
|
||||
assert_equal Parfait::NilClass , produced.next(36).constant.class
|
||||
end
|
||||
|
||||
def test_back_jump # should jump back to condition label
|
||||
produced = produce_body
|
||||
assert_equal Risc::Branch , produced.next(43).class
|
||||
assert_equal produced , produced.next(43).label
|
||||
assert_equal Risc::Branch , produced.next(42).class
|
||||
assert_equal produced , produced.next(42).label
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user