move wip tests
This commit is contained in:
parent
5c89884df9
commit
168c2e862f
@ -23,8 +23,7 @@ module Risc
|
|||||||
compiler.add_slot_to_reg( source + "2" , me , Parfait::Integer.integer_index , me)
|
compiler.add_slot_to_reg( source + "2" , me , Parfait::Integer.integer_index , me)
|
||||||
compiler.add_slot_to_reg( source + "3", other , Parfait::Integer.integer_index , other)
|
compiler.add_slot_to_reg( source + "3", other , Parfait::Integer.integer_index , other)
|
||||||
compiler.add_code Risc.op( source + "4", :+ , me , other)
|
compiler.add_code Risc.op( source + "4", :+ , me , other)
|
||||||
compiler.add_new_int(other)
|
compiler.add_new_int(me , other)
|
||||||
compiler.add_reg_to_slot( source + "5" , me , other , Parfait::Integer.integer_index)
|
|
||||||
compiler.add_reg_to_slot( source + "5" , other , :message , :return_value)
|
compiler.add_reg_to_slot( source + "5" , other , :message , :return_value)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
|
|
||||||
@ -80,6 +79,10 @@ module Risc
|
|||||||
compiler.add_code Risc.op( s , :>> , tmp , const )
|
compiler.add_code Risc.op( s , :>> , tmp , const )
|
||||||
# return q + tmp
|
# return q + tmp
|
||||||
compiler.add_code Risc.op( s , :+ , q , tmp )
|
compiler.add_code Risc.op( s , :+ , q , tmp )
|
||||||
|
|
||||||
|
compiler.add_new_int(me , other)
|
||||||
|
compiler.add_reg_to_slot( source + "5" , other , :message , :return_value)
|
||||||
|
|
||||||
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)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
|
@ -132,17 +132,18 @@ module Risc
|
|||||||
@regs.clear
|
@regs.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
# grab an integer from space and stick it in the register.
|
# move a machine int from register "from" to a Parfait::Integer in register "to"
|
||||||
def add_new_int( register )
|
# have to grab an integer from space and stick it in the "to" register first.
|
||||||
|
def add_new_int( from, to )
|
||||||
source = "add_new_int "
|
source = "add_new_int "
|
||||||
space = use_reg(:Space)
|
space = use_reg(:Space)
|
||||||
int = use_reg(:Integer)
|
int = use_reg(:Integer)
|
||||||
space_i = Risc.resolve_to_index(:Space, :next_integer)
|
space_i = Risc.resolve_to_index(:Space, :next_integer)
|
||||||
add_load_constant( source + "space" , Parfait.object_space , space )
|
add_load_constant( source + "space" , Parfait.object_space , space )
|
||||||
add_slot_to_reg( source + "next_i1" , space , space_i , register)
|
add_slot_to_reg( source + "next_i1" , space , space_i , register)
|
||||||
add_slot_to_reg( source + "next_i2" , register , Risc.resolve_to_index(:Integer, :next_integer) , int)
|
add_slot_to_reg( source + "next_i2" , to , Risc.resolve_to_index(:Integer, :next_integer) , int)
|
||||||
add_reg_to_slot( source + "store link" , int , space , space_i )
|
add_reg_to_slot( source + "store link" , int , space , space_i )
|
||||||
# store 2nd next_i to spce next_i
|
add_reg_to_slot( source + "store value" , from , to , Parfait::Integer.integer_index)
|
||||||
end
|
end
|
||||||
def add_constant(const)
|
def add_constant(const)
|
||||||
Risc.machine.add_constant(const)
|
Risc.machine.add_constant(const)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class InterpreterReturnCall < MiniTest::Test
|
class InterpreterDiv10 < MiniTest::Test
|
||||||
include Ticker
|
include Ticker
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -33,7 +33,8 @@ module Risc
|
|||||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
||||||
SlotToReg, SlotToReg, FunctionReturn, Transfer, Syscall,
|
SlotToReg, SlotToReg, FunctionReturn, Transfer, Syscall,
|
||||||
NilClass]
|
NilClass]
|
||||||
#assert_equal 1 , get_return
|
assert_equal Parfait::Integer , get_return.class
|
||||||
|
#assert_equal 1 , get_return
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_call_main
|
def test_call_main
|
@ -5,7 +5,7 @@ module Risc
|
|||||||
include Ticker
|
include Ticker
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@string_input = as_main("a = 5 + 5;return a")
|
@string_input = as_main("return 5 + 5")
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestInterpretRegToByte < MiniTest::Test
|
class TestInterpretRegToByte < MiniTest::Test
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class IfCalledTest < MiniTest::Test
|
class IfCalledTest < MiniTest::Test
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class AddChange < MiniTest::Test
|
class AddChange < MiniTest::Test
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class MultTest < MiniTest::Test
|
class MultTest < MiniTest::Test
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestPuts < MiniTest::Test
|
class TestPuts < MiniTest::Test
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestInterpretByteToReg < MiniTest::Test
|
class TestInterpretByteToReg < MiniTest::Test
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class IfSimpleTest < MiniTest::Test
|
class IfSimpleTest < MiniTest::Test
|
Loading…
Reference in New Issue
Block a user