rename set_slot

set_slot was clear about the target, but not the source.
Better with reg_to_slot (and soon it’s inverse slot_to_reg)
This commit is contained in:
Torsten Ruger
2016-12-25 18:02:39 +02:00
parent 1b8d6149dd
commit 35adf9a5e6
31 changed files with 126 additions and 115 deletions

View File

@ -20,7 +20,7 @@ module Register
return_label = Label.new("_return_label" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
ret_tmp = compiler.use_reg(:Label)
compiler.add_code Register::LoadConstant.new(source, return_label , ret_tmp)
compiler.add_code Register.set_slot(source, ret_tmp , :new_message , :return_address)
compiler.add_code Register.reg_to_slot(source, ret_tmp , :new_message , :return_address)
# move the current new_message to message
compiler.add_code RegisterTransfer.new(source, Register.new_message_reg , Register.message_reg )
# do the register call

View File

@ -1,7 +1,7 @@
module Register
# GetSlot moves data into a register from memory.
# SetSlot moves data into memory from a register.
# RegToSlot moves data into memory from a register.
# Both use a base memory (a register)
# This is because that is what cpu's can do. In programming terms this would be accessing

View File

@ -1,19 +1,19 @@
module Register
# SetSlot moves data into memory from a register.
# RegToSlot moves data into memory from a register.
# GetSlot moves data into a register from memory.
# Both use a base memory (a register)
# This is because that is what cpu's can do. In programming terms this would be accessing
# an element in an array, in the case of SetSlot setting the register in the array.
# an element in an array, in the case of RegToSlot setting the register in the array.
# btw: to move data between registers, use RegisterTransfer
class SetSlot < Setter
class RegToSlot < Setter
# If you had a c array and index offset
# the instruction would do array[index] = register
# So SetSlot means the register (first argument) moves to the slot (array and index)
# So RegToSlot means the register (first argument) moves to the slot (array and index)
# def initialize source , register , array , index
# super
@ -22,14 +22,14 @@ module Register
end
# Produce a SetSlot instruction.
# Produce a RegToSlot instruction.
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
# index resolves with resolve_index.
def self.set_slot source , from , to , index
def self.reg_to_slot source , from , to , index
from = resolve_to_register from
index = resolve_index( to , index)
to = resolve_to_register to
SetSlot.new( source, from , to , index)
RegToSlot.new( source, from , to , index)
end
end

View File

@ -3,7 +3,7 @@ module Register
# transfer the constents of one register to another.
# possibly called move in some cpus
# There are other instructions to move data from / to memory, namely GetSlot and SetSlot
# There are other instructions to move data from / to memory, namely GetSlot and RegToSlot
# Get/Set Slot move data around in vm objects, but transfer moves the objects (in the machine)
#

View File

@ -1,5 +1,5 @@
module Register
# Setter is a base class for set instructions (SetSlot and SetByte , possibly more coming)
# Setter is a base class for set instructions (RegToSlot and SetByte , possibly more coming)
#
# The instruction that is modelled is loading data from a register into an array
#