2014-09-14 21:26:30 +03:00
|
|
|
Virtual::MessageSlot.class_eval do
|
|
|
|
def reg
|
2015-05-24 15:31:30 +03:00
|
|
|
Register::RegisterReference.message_reg
|
2014-09-14 21:26:30 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
Virtual::FrameSlot.class_eval do
|
|
|
|
def reg
|
2015-05-24 15:31:30 +03:00
|
|
|
Register::RegisterReference.frame_reg
|
2014-09-14 21:26:30 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
Virtual::SelfSlot.class_eval do
|
|
|
|
def reg
|
2015-05-24 15:31:30 +03:00
|
|
|
Register::RegisterReference.self_reg
|
2014-09-14 21:26:30 +03:00
|
|
|
end
|
|
|
|
end
|
2015-06-21 00:21:42 +03:00
|
|
|
Virtual::NextMessageSlot.class_eval do
|
2014-09-14 21:26:30 +03:00
|
|
|
def reg
|
2015-05-24 15:31:30 +03:00
|
|
|
Register::RegisterReference.new_message_reg
|
2014-09-14 21:26:30 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-23 21:49:09 +03:00
|
|
|
module Register
|
2015-05-24 15:31:30 +03:00
|
|
|
# This implements setting of the various slot variables the vm defines.
|
2014-10-03 11:07:18 +03:00
|
|
|
# Basic mem moves, but have to shuffle the type nibbles (TODO!)
|
2015-05-24 15:31:30 +03:00
|
|
|
|
2014-08-23 13:57:14 +03:00
|
|
|
class SetImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Virtual::Set
|
2014-09-14 21:26:30 +03:00
|
|
|
# resolve the register and offset that we need to move to
|
|
|
|
to = code.to.reg
|
|
|
|
# need a temporay place because of indexed load/store
|
2015-05-24 15:31:30 +03:00
|
|
|
tmp = RegisterReference.tmp_reg
|
2014-09-14 21:26:30 +03:00
|
|
|
# for constants we have to "move" the constants value
|
2015-06-01 08:33:23 +03:00
|
|
|
if( code.from.is_a?(Parfait::Value) or code.from.is_a?(Symbol))
|
2015-06-25 16:31:09 +03:00
|
|
|
move1 = LoadConstant.new( code.from , tmp )
|
2014-09-14 21:26:30 +03:00
|
|
|
else # while otherwise we "load"
|
2015-06-21 21:00:16 +03:00
|
|
|
move1 = GetSlot.new( code.from.reg , code.from.index , tmp )
|
2014-08-23 20:25:19 +03:00
|
|
|
end
|
2014-10-03 11:07:18 +03:00
|
|
|
move2 = SetSlot.new( tmp , to , code.to.index )
|
2014-09-14 21:26:30 +03:00
|
|
|
block.replace(code , [move1,move2] )
|
2014-08-23 13:57:14 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-01 08:40:17 +03:00
|
|
|
Virtual.machine.add_pass "Register::SetImplementation"
|
2014-08-23 13:57:14 +03:00
|
|
|
end
|