2014-08-23 20:49:09 +02:00
|
|
|
module Register
|
2014-08-23 22:37:33 +02:00
|
|
|
# This implements setting of the various slot variables the vm defines.
|
|
|
|
# Basic mem moves, but have to shuffle the type nibbles
|
|
|
|
|
2014-08-23 12:57:14 +02:00
|
|
|
class SetImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Virtual::Set
|
2014-09-11 20:26:22 +02:00
|
|
|
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
|
2014-08-23 20:49:09 +02:00
|
|
|
if( code.to.is_a? Virtual::NewMessageSlot)
|
2014-09-11 20:26:22 +02:00
|
|
|
to = Virtual::Message::NEW_MESSAGE_REG
|
|
|
|
move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
|
|
|
|
block.replace(code , move )
|
|
|
|
elsif( code.to.is_a? Virtual::Self)
|
|
|
|
to = RegisterReference.new(Virtual::Message::SELF_REG)
|
2014-08-23 20:49:09 +02:00
|
|
|
move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
|
2014-08-30 15:57:56 +02:00
|
|
|
block.replace(code , move )
|
2014-08-23 19:25:19 +02:00
|
|
|
else
|
|
|
|
raise "Start coding #{code.inspect}"
|
|
|
|
end
|
2014-08-23 12:57:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-09-09 17:03:13 +02:00
|
|
|
Virtual::BootSpace.space.add_pass_after SetImplementation , Virtual::GetImplementation
|
2014-08-23 12:57:14 +02:00
|
|
|
end
|