implement simple_calls to_risc

This commit is contained in:
Torsten Ruger
2018-03-21 18:54:42 +05:30
parent 71c59e5bc0
commit a9196e9cd6
4 changed files with 25 additions and 20 deletions

View File

@ -9,21 +9,16 @@ module Risc
@input = "r = 5.mod4"
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
SlotToReg, RegToSlot, Label, SlotToReg, SlotToReg, RegToSlot]
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, FunctionCall ,
Label, SlotToReg, SlotToReg, RegToSlot]
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg
end
def ttest_constant_load
def test_constant_load
produced = produce_body
assert_equal 5 , produced.constant.known_object.value
assert_equal 5 , produced.next(11).constant.known_object.value
end
def ttest_slot_move
produced = produce_body
assert_equal produced.next.register , produced.register
end
end
end

View File

@ -12,19 +12,18 @@ module Vool
end
def test_condition
assert_equal TruthCheck , @ins.next(11).class
assert_equal TruthCheck , @ins.next(4).class
end
def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(11).condition.class , @ins
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
end
def test_hoisted_dynamic_call
assert_equal DynamicCall , @ins.next(9).class
assert_equal SimpleCall , @ins.next(2).class
assert_equal :mod4 , @ins.next(2).method.name
end
def test_array
check_array [NotSameCheck, SlotLoad, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
Label, MessageSetup, ArgumentTransfer, DynamicCall, SlotLoad, TruthCheck ,
Label, MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label ,
MessageSetup, ArgumentTransfer, SimpleCall, Label] , @ins
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label ,
SlotLoad, Jump, Label, SlotLoad, Label] , @ins
end
end