stash old vm

moving on to getting mom to work and can’t have both
interpreter and elf broke, about 100 tests  went
This commit is contained in:
Torsten Ruger
2018-03-11 17:02:42 +05:30
parent f7aac1d1a4
commit 5fe0ba06ab
56 changed files with 80 additions and 143 deletions

View File

@ -9,7 +9,7 @@ module Risc
def setup
Risc.machine.boot
do_clean_compile
Vm.compile_ast( @input )
#FIXME Vm.compile_ast( @input )
Collector.collect_space
@interpreter = Interpreter.new
@interpreter.start Risc.machine.init

View File

@ -16,7 +16,7 @@ HERE
super
end
def test_chain
def pest_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
@ -25,18 +25,18 @@ HERE
NilClass]
end
def test_get
def pest_get
assert_equal SlotToReg , ticks(4).class
assert @interpreter.get_register( :r2 )
assert Integer , @interpreter.get_register( :r2 ).class
end
def test_transfer
def pest_transfer
transfer = ticks 19
assert_equal RiscTransfer , transfer.class
assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from)
end
def test_call
def pest_call
ret = ticks(18)
assert_equal FunctionReturn , ret.class
@ -45,7 +45,7 @@ HERE
assert_equal Label , link.class
end
def test_adding
def pest_adding
done_op = ticks(12)
assert_equal OperatorInstruction , done_op.class
left = @interpreter.get_register(done_op.left)

View File

@ -19,7 +19,7 @@ HERE
super
end
def test_chain
def pest_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg,
@ -33,31 +33,31 @@ HERE
Label, FunctionReturn, RiscTransfer, Syscall, NilClass]
end
def test_branch
def pest_branch
was = @interpreter.instruction
assert_equal Branch , ticks(1).class
assert was != @interpreter.instruction
assert @interpreter.instruction , "should have gone to next instruction"
end
def test_load
def pest_load
assert_equal LoadConstant , ticks(3).class
assert_equal Parfait::Space , @interpreter.get_register(:r2).class
assert_equal :r2, @interpreter.instruction.array.symbol
end
def test_get
def pest_get
assert_equal SlotToReg , ticks(4).class
assert @interpreter.get_register( :r1 )
assert Integer , @interpreter.get_register( :r1 ).class
end
def test_call
def pest_call
assert_equal FunctionCall , ticks(8).class
end
def test_exit
def pest_exit
done = ticks(50)
assert_equal NilClass , done.class
end
def test_reg_to_byte
def pest_reg_to_byte
done = ticks(37)
assert_equal RegToByte , done.class
assert_equal "h".ord , @interpreter.get_register(done.register)

View File

@ -32,7 +32,7 @@ HERE
s(:true_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "then")))),
s(:false_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "else"))))))
end
def test_if
def pest_if
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg,

View File

@ -19,7 +19,7 @@ module Risc
@instruction_events << was
end
def test_state_change
def pest_state_change
@interpreter.register_event :state_changed , self
ticks 30
assert @state_events[:state_changed]
@ -28,14 +28,14 @@ module Risc
@interpreter.unregister_event :state_changed , self
end
def test_instruction_events
def pest_instruction_events
@interpreter.register_event :instruction_changed , self
ticks 30
assert_equal 20 , @instruction_events.length
@interpreter.unregister_event :instruction_changed , self
end
def test_chain
def pest_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,

View File

@ -17,7 +17,7 @@ HERE
super
end
def test_mult
def pest_mult
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
@ -26,12 +26,12 @@ HERE
NilClass]
check_return 0
end
def test_overflow
def pest_overflow
ticks( 12 )
assert @interpreter.flags[:overflow]
end
def test_zero
def pest_zero
ticks( 12 )
assert @interpreter.flags[:zero]
end

View File

@ -16,7 +16,7 @@ HERE
super
end
def test_add
def pest_add
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
@ -26,12 +26,12 @@ HERE
check_return 0
end
def test_overflow
def pest_overflow
ticks( 12 )
assert @interpreter.flags[:overflow]
end
def test_zero
def pest_zero
ticks( 12 )
assert @interpreter.flags[:zero]
end

View File

@ -16,7 +16,7 @@ HERE
super
end
def test_chain
def pest_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg,
@ -29,40 +29,40 @@ HERE
Label, FunctionReturn, RiscTransfer, Syscall, NilClass]
end
def test_branch
def pest_branch
was = @interpreter.instruction
assert_equal Branch , ticks(1).class
assert was != @interpreter.instruction
assert @interpreter.instruction , "should have gone to next instruction"
end
def test_load
def pest_load
assert_equal LoadConstant , ticks(3).class
assert_equal Parfait::Space , @interpreter.get_register(:r2).class
assert_equal :r2, @interpreter.instruction.array.symbol
end
def test_get
def pest_get
assert_equal SlotToReg , ticks(4).class
assert @interpreter.get_register( :r1 )
assert Integer , @interpreter.get_register( :r1 ).class
end
def test_call
def pest_call
assert_equal FunctionCall , ticks(8).class
end
def test_putstring
def pest_putstring
done = ticks(29)
assert_equal Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout
end
def test_return
def pest_return
done = ticks(34)
assert_equal FunctionReturn , done.class
assert Label , @interpreter.instruction.class
assert @interpreter.instruction.is_a?(Instruction) , "not instruction #{@interpreter.instruction}"
end
def test_exit
def pest_exit
done = ticks(45)
assert_equal NilClass , done.class
assert_equal "Hello again" , @interpreter.stdout

View File

@ -19,7 +19,7 @@ HERE
super
end
def test_chain
def pest_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg,
@ -33,31 +33,31 @@ HERE
NilClass]
end
def test_branch
def pest_branch
was = @interpreter.instruction
assert_equal Branch , ticks(1).class
assert was != @interpreter.instruction
assert @interpreter.instruction , "should have gone to next instruction"
end
def test_load
def pest_load
assert_equal LoadConstant , ticks(3).class
assert_equal Parfait::Space , @interpreter.get_register(:r2).class
assert_equal :r2, @interpreter.instruction.array.symbol
end
def test_get
def pest_get
assert_equal SlotToReg , ticks(4).class
assert @interpreter.get_register( :r1 )
assert Integer , @interpreter.get_register( :r1 ).class
end
def test_call
def pest_call
assert_equal FunctionCall , ticks(8).class
end
def test_exit
def pest_exit
done = ticks(46)
assert_equal NilClass , done.class
end
def test_byte_to_reg
def pest_byte_to_reg
done = ticks(32)
assert_equal ByteToReg , done.class
assert_equal "H".ord , @interpreter.get_register(done.register)

View File

@ -24,7 +24,7 @@ HERE
super
end
def test_if
def pest_if
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,