rubyx/lib/register/set_implementation.rb
2014-09-11 21:26:22 +03:00

26 lines
963 B
Ruby

module Register
# This implements setting of the various slot variables the vm defines.
# Basic mem moves, but have to shuffle the type nibbles
class SetImplementation
def run block
block.codes.dup.each do |code|
next unless code.is_a? Virtual::Set
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
if( code.to.is_a? Virtual::NewMessageSlot)
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)
move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
block.replace(code , move )
else
raise "Start coding #{code.inspect}"
end
end
end
end
Virtual::BootSpace.space.add_pass_after SetImplementation , Virtual::GetImplementation
end