fixing all the indexes
with the type word and layout but the list starting at 1, indexes still need 1 added and for arm x 4. Tried to get all that into one function, resolve_index
This commit is contained in:
@ -56,21 +56,23 @@ module Register
|
||||
# TODO : fix this to use global (later per thread) variable
|
||||
def save_message(function)
|
||||
space_tmp = Register.tmp_reg
|
||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||
raise "index not found for :syscall_message" unless ind
|
||||
ind = Register.resolve_index( :space , :syscall_message )
|
||||
function.info.add_code LoadConstant.new( Parfait::Space.object_space , space_tmp)
|
||||
function.info.add_code SetSlot.new( Register.message_reg , space_tmp , ind)
|
||||
end
|
||||
|
||||
def restore_message(function)
|
||||
# get the sys return out of the way
|
||||
return_tmp = Register.tmp_reg
|
||||
function.info.add_code RegisterTransfer.new( Register.message_reg , return_tmp )
|
||||
# load the space into the base register
|
||||
function.info.add_code RegisterTransfer.new( return_tmp , Register.message_reg )
|
||||
function.info.add_code LoadConstant.new(Parfait::Space.object_space ,Register.message_reg)
|
||||
# find the stored message
|
||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||
raise "index not found for #{kind}.#{kind.class}" unless ind
|
||||
ind = Register.resolve_index( :space , :syscall_message )
|
||||
# and load it into the base RegisterMachine
|
||||
function.info.add_code Register.get_slot :message , ind , :message
|
||||
# save the return value into the message
|
||||
function.info.add_code Register.set_slot( return_tmp , :message , :return_value )
|
||||
# and "unroll" self and frame
|
||||
function.info.add_code Register.get_slot(:message , :receiver, :self )
|
||||
function.info.add_code Register.get_slot(:message , :frame , :frame)
|
||||
|
@ -42,9 +42,9 @@ module Register
|
||||
frame_tmp = space_tmp.next_reg_use
|
||||
# get the next_frame
|
||||
from = Parfait::Space.object_space.send( kind )
|
||||
kind_index = from.get_layout().index_of( kind )
|
||||
kind_index = from.get_layout().index_of( kind ) + 1 # should be resolve_index to hide the +1
|
||||
raise "index not found for #{kind}.#{kind.class}" unless kind_index
|
||||
new_codes << GetSlot.new( Register.frame_reg , kind_index , frame_tmp) # 2 index of next_frame
|
||||
new_codes << GetSlot.new( Register.frame_reg , kind_index , frame_tmp)
|
||||
# save next frame into space
|
||||
new_codes << SetSlot.new( frame_tmp , space_tmp , space_index)
|
||||
block.replace(code , new_codes )
|
||||
|
@ -28,7 +28,7 @@ module Register
|
||||
return Register.resolve_index( :message , :name)
|
||||
when Virtual::NewArgSlot
|
||||
puts "from: #{from.index}"
|
||||
return Register.resolve_index( :message , :name) + 1 + from.index
|
||||
return Register.resolve_index( :message , :name) + from.index
|
||||
else
|
||||
raise "not implemented for #{from.class}"
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ module Register
|
||||
raise "Class name not given #{real_name}" unless clazz
|
||||
index = clazz.object_layout.index_of( instance_name )
|
||||
raise "Instance name=#{instance_name} not found on #{real_name}" unless index.is_a?(Numeric)
|
||||
return index
|
||||
return index + 1 # one for the type word that is at index 0
|
||||
end
|
||||
|
||||
# if a symbol is given, it may be one of the four objects that the vm knows.
|
||||
|
Reference in New Issue
Block a user