Torsten
3145547315
reducing and assuming the same register, buuh adds a transfer instruction that can hopefully be removed by analysis
47 lines
1.4 KiB
Ruby
47 lines
1.4 KiB
Ruby
require_relative "../helper"
|
|
|
|
module Risc
|
|
class InterpreterAssignLocal < MiniTest::Test
|
|
include Ticker
|
|
|
|
def setup
|
|
@string_input = as_main("a = 15 ; return a")
|
|
super
|
|
end
|
|
|
|
def test_chain
|
|
#show_main_ticks # get output of what is
|
|
check_main_chain [LoadConstant, RegToSlot, SlotToReg, RegToSlot, Branch, #5
|
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #10
|
|
FunctionReturn, Transfer, SlotToReg, SlotToReg, Transfer,
|
|
Syscall, NilClass,] #20
|
|
assert_equal ::Integer , get_return.class
|
|
assert_equal 15 , get_return
|
|
end
|
|
def test_call_main
|
|
call_ins = ticks(main_at)
|
|
assert_equal FunctionCall , call_ins.class
|
|
assert :main , call_ins.method.name
|
|
end
|
|
def test_load_15
|
|
assert_load 1 , Parfait::Integer , "id_integer_"
|
|
assert_equal 15 , @interpreter.get_register(@interpreter.instruction.register).value
|
|
end
|
|
def test_branch
|
|
assert_branch 5 , "return_label"
|
|
end
|
|
def test_return
|
|
ret = main_ticks(11)
|
|
assert_equal FunctionReturn , ret.class
|
|
link = @interpreter.get_register( ret.register )
|
|
assert_equal Parfait::ReturnAddress , link.class
|
|
end
|
|
def test_transfer
|
|
assert_transfer 12 , :message , :saved_message
|
|
end
|
|
def test_sys
|
|
assert_syscall 16 , :exit
|
|
end
|
|
end
|
|
end
|