fix div10 return sequence
did not return at all before
This commit is contained in:
parent
267237b776
commit
3ceb2c2f69
@ -16,7 +16,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def div10 context
|
def div10( context )
|
||||||
s = "div_10"
|
s = "div_10"
|
||||||
compiler = compiler_for(:Integer,:div10 ,{})
|
compiler = compiler_for(:Integer,:div10 ,{})
|
||||||
me = compiler.add_known( :receiver )
|
me = compiler.add_known( :receiver )
|
||||||
@ -68,6 +68,7 @@ module Risc
|
|||||||
# return q + tmp
|
# return q + tmp
|
||||||
compiler.add_code Risc.op( s , "+" , q , tmp )
|
compiler.add_code Risc.op( s , "+" , q , tmp )
|
||||||
compiler.add_reg_to_slot( s , q , :message , :return_value)
|
compiler.add_reg_to_slot( s , q , :message , :return_value)
|
||||||
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,44 +11,49 @@ module Risc
|
|||||||
|
|
||||||
def test_chain
|
def test_chain
|
||||||
#show_ticks # get output of what is
|
#show_ticks # get output of what is
|
||||||
check_chain [Branch, Label, LoadConstant, SlotToReg, SlotToReg,
|
check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant,
|
||||||
RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label,
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||||
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||||
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
||||||
|
SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall,
|
||||||
|
Label, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
||||||
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
||||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
|
RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg,
|
||||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||||
Label, SlotToReg, SlotToReg, SlotToReg, LoadConstant,
|
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant,
|
||||||
OperatorInstruction, LoadConstant, OperatorInstruction, OperatorInstruction, LoadConstant,
|
FunctionCall, Label, SlotToReg, SlotToReg, SlotToReg,
|
||||||
|
LoadConstant, OperatorInstruction, LoadConstant, OperatorInstruction, OperatorInstruction,
|
||||||
|
LoadConstant, Transfer, OperatorInstruction, OperatorInstruction, LoadConstant,
|
||||||
Transfer, OperatorInstruction, OperatorInstruction, LoadConstant, Transfer,
|
Transfer, OperatorInstruction, OperatorInstruction, LoadConstant, Transfer,
|
||||||
OperatorInstruction, OperatorInstruction, LoadConstant, Transfer, OperatorInstruction,
|
OperatorInstruction, OperatorInstruction, LoadConstant, OperatorInstruction, LoadConstant,
|
||||||
OperatorInstruction, LoadConstant, OperatorInstruction, LoadConstant, Transfer,
|
Transfer, OperatorInstruction, OperatorInstruction, Transfer, LoadConstant,
|
||||||
OperatorInstruction, OperatorInstruction, Transfer, LoadConstant, OperatorInstruction,
|
OperatorInstruction, LoadConstant, OperatorInstruction, OperatorInstruction, RegToSlot,
|
||||||
LoadConstant, OperatorInstruction, OperatorInstruction, RegToSlot, Label,
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||||
|
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
||||||
|
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
||||||
|
SlotToReg, SlotToReg, FunctionReturn, Transfer, Syscall,
|
||||||
NilClass]
|
NilClass]
|
||||||
assert_equal 1 , get_return
|
assert_equal 1 , get_return
|
||||||
end
|
end
|
||||||
|
|
||||||
def ttest_call_main
|
def test_call_main
|
||||||
call_ins = ticks(9)
|
call_ins = ticks(25)
|
||||||
assert_equal FunctionCall , call_ins.class
|
assert_equal FunctionCall , call_ins.class
|
||||||
assert :main , call_ins.method.name
|
assert :main , call_ins.method.name
|
||||||
end
|
end
|
||||||
def ttest_load_5
|
def test_load_15
|
||||||
load_ins = ticks 11
|
load_ins = ticks 43
|
||||||
assert_equal LoadConstant , load_ins.class
|
assert_equal LoadConstant , load_ins.class
|
||||||
assert_equal 5 , @interpreter.get_register(load_ins.register).value
|
assert_equal 15 , @interpreter.get_register(load_ins.register)
|
||||||
end
|
end
|
||||||
def ttest_transfer
|
def test_sys
|
||||||
transfer = ticks(19)
|
sys = ticks(105)
|
||||||
assert_equal Transfer , transfer.class
|
|
||||||
end
|
|
||||||
def ttest_sys
|
|
||||||
sys = ticks(20)
|
|
||||||
assert_equal Syscall , sys.class
|
assert_equal Syscall , sys.class
|
||||||
|
assert_equal :exit , sys.name
|
||||||
end
|
end
|
||||||
def ttest_return
|
|
||||||
ret = ticks(18)
|
def test_return
|
||||||
|
ret = ticks(91)
|
||||||
assert_equal FunctionReturn , ret.class
|
assert_equal FunctionReturn , ret.class
|
||||||
link = @interpreter.get_register( ret.register )
|
link = @interpreter.get_register( ret.register )
|
||||||
assert_equal Label , link.class
|
assert_equal Label , link.class
|
||||||
|
Loading…
Reference in New Issue
Block a user