move wip tests

This commit is contained in:
Torsten Ruger
2018-04-01 14:01:17 +03:00
parent 5c89884df9
commit 168c2e862f
11 changed files with 21 additions and 16 deletions

View File

@ -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 + "3", other , Parfait::Integer.integer_index , other)
compiler.add_code Risc.op( source + "4", :+ , me , other)
compiler.add_new_int(other)
compiler.add_reg_to_slot( source + "5" , me , other , Parfait::Integer.integer_index)
compiler.add_new_int(me , other)
compiler.add_reg_to_slot( source + "5" , other , :message , :return_value)
return compiler.method
@ -80,6 +79,10 @@ module Risc
compiler.add_code Risc.op( s , :>> , tmp , const )
# return 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_mom( Mom::ReturnSequence.new)
return compiler.method

View File

@ -132,17 +132,18 @@ module Risc
@regs.clear
end
# grab an integer from space and stick it in the register.
def add_new_int( register )
# move a machine int from register "from" to a Parfait::Integer in register "to"
# 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 "
space = use_reg(:Space)
int = use_reg(:Integer)
space_i = Risc.resolve_to_index(:Space, :next_integer)
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_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 )
# store 2nd next_i to spce next_i
add_reg_to_slot( source + "store value" , from , to , Parfait::Integer.integer_index)
end
def add_constant(const)
Risc.machine.add_constant(const)