get plus (+) working

alas, new integer is not created yet
This commit is contained in:
Torsten Ruger
2018-03-31 19:37:24 +03:00
parent a2173645b3
commit 5b92b6b785
3 changed files with 48 additions and 29 deletions

View File

@ -5,12 +5,12 @@ module Risc
include Ticker
def setup
@string_input = as_main("a = 5 + 5")
@string_input = as_main("a = 5 + 5;return a")
super
end
def est_add
show_ticks # get output of what is
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
@ -20,40 +20,54 @@ module Risc
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, SlotToReg]
#assert_equal 10 , get_return
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
Label, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, OperatorInstruction, RegToSlot, Label, NilClass]
assert_equal 10 , get_return
end
def est_slot3
sl = ticks( 49 )
assert_equal SlotToReg , sl.class
assert_equal :r2 , sl.array.symbol #load from message
assert_equal 9 , sl.index
assert_equal :r3 , sl.register.symbol
def test_load_5
lod = ticks( 46 )
assert_equal LoadConstant , lod.class
assert_equal Parfait::Integer , lod.constant.class
assert_equal 5 , lod.constant.value
end
def est_slot2 #load arg from args
sl = ticks( 48 )
assert_equal SlotToReg , sl.class
assert_equal :r2 , sl.array.symbol #load from message
assert_equal 9 , sl.index
assert_equal :r3 , sl.register.symbol
end
def est_slot1 #load args from message
sl = ticks( 47 )
def test_slot_receiver #load receiver from message
sl = ticks( 57 )
assert_equal SlotToReg , sl.class
assert_equal :r0 , sl.array.symbol #load from message
assert_equal 3 , sl.index
assert_equal :r1 , sl.register.symbol
end
def test_slot_args #load args from message
sl = ticks( 58 )
assert_equal SlotToReg , sl.class
assert_equal :r0 , sl.array.symbol #load from message
assert_equal 9 , sl.index
assert_equal :r2 , sl.register.symbol
end
def test_slot_arg #load arg 1, destructively from args
sl = ticks( 59 )
assert_equal SlotToReg , sl.class
assert_equal :r2 , sl.array.symbol #load from message
assert_equal 2 , sl.index
assert_equal :r2 , sl.register.symbol
end
def est_load_2
lod = ticks( 46 )
assert_equal LoadConstant , lod.class
assert_equal 5 , lod.constant.value
def test_slot_int1 #load int from object
sl = ticks( 60 )
assert_equal SlotToReg , sl.class
assert_equal :r1 , sl.array.symbol #load from message
assert_equal 3 , sl.index
assert_equal :r1 , sl.register.symbol
end
def pest_zero
ticks( 12 )
assert @interpreter.flags[:zero]
def test_op
op = ticks(62)
assert_equal OperatorInstruction , op.class
assert_equal :r1 , op.left.symbol
assert_equal :r2 , op.right.symbol
assert_equal 5 , @interpreter.get_register(:r2)
assert_equal 10 , @interpreter.get_register(:r1)
end
end
end