remove class_eval on slots to map registers
Use their class names (or for now called object names) these are the same that Register helper functions accept already anyway
This commit is contained in:
@ -1,27 +1,4 @@
|
||||
|
||||
#TODO: get rid of this. along the Register.* functions
|
||||
|
||||
Virtual::MessageSlot.class_eval do
|
||||
def reg
|
||||
Register.message_reg
|
||||
end
|
||||
end
|
||||
Virtual::FrameSlot.class_eval do
|
||||
def reg
|
||||
Register.frame_reg
|
||||
end
|
||||
end
|
||||
Virtual::SelfSlot.class_eval do
|
||||
def reg
|
||||
Register.self_reg
|
||||
end
|
||||
end
|
||||
Virtual::NewMessageSlot.class_eval do
|
||||
def reg
|
||||
Register.new_message_reg
|
||||
end
|
||||
end
|
||||
|
||||
module Register
|
||||
# This implements setting of the various slot variables the vm defines.
|
||||
# Basic mem moves, but have to shuffle the type nibbles (TODO!)
|
||||
@ -30,17 +7,15 @@ module Register
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? Virtual::Set
|
||||
# resolve the register and offset that we need to move to
|
||||
to = code.to.reg
|
||||
# need a temporay place because of indexed load/store
|
||||
tmp = Register.tmp_reg
|
||||
# for constants we have to "move" the constants value
|
||||
if( code.from.is_a?(Parfait::Value) or code.from.is_a?(Symbol))
|
||||
move1 = LoadConstant.new( code.from , tmp )
|
||||
else # while otherwise we "load"
|
||||
move1 = GetSlot.new( code.from.reg , get_index(code.from) , tmp )
|
||||
move1 = Register.get_slot( code.from.object_name , get_index(code.from) , tmp )
|
||||
end
|
||||
move2 = SetSlot.new( tmp , to , get_index(code.to) )
|
||||
move2 = Register.set_slot( tmp , code.to.object_name , get_index(code.to) )
|
||||
block.replace(code , [move1,move2] )
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user