From 435fefd3100522a6e382b8c6aba8d65e60393a25 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 23 Aug 2014 21:49:09 +0300 Subject: [PATCH] implementation passes involving assembly go to register directory --- lib/{virtual => register}/get_implementation.rb | 6 +++--- lib/{virtual => register}/set_implementation.rb | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) rename lib/{virtual => register}/get_implementation.rb (69%) rename lib/{virtual => register}/set_implementation.rb (67%) diff --git a/lib/virtual/get_implementation.rb b/lib/register/get_implementation.rb similarity index 69% rename from lib/virtual/get_implementation.rb rename to lib/register/get_implementation.rb index 26a2f01a..66454b73 100644 --- a/lib/virtual/get_implementation.rb +++ b/lib/register/get_implementation.rb @@ -1,14 +1,14 @@ -module Virtual +module Register # This implements the send logic # Send is so complicated that we actually code it in ruby and stick it in # That off course opens up an endless loop possibility that we stop by reducing to Class and Module methods class GetImplementation def run block block.codes.dup.each do |code| - next unless code.is_a? InstanceGet + next unless code.is_a? Virtual::InstanceGet raise "Start coding" end end end - Object.space.add_pass_after GetImplementation, SendImplementation + Virtual::Object.space.add_pass_after GetImplementation, Virtual::SendImplementation end diff --git a/lib/virtual/set_implementation.rb b/lib/register/set_implementation.rb similarity index 67% rename from lib/virtual/set_implementation.rb rename to lib/register/set_implementation.rb index 797c6473..241c5752 100644 --- a/lib/virtual/set_implementation.rb +++ b/lib/register/set_implementation.rb @@ -1,4 +1,4 @@ -module Virtual +module Register # This implements the send logic # Send is so complicated that we actually code it in ruby and stick it in # That off course opens up an endless loop possibility that we stop by reducing to Class and Module methods @@ -6,15 +6,16 @@ module Virtual def run block block.codes.dup.each do |code| next unless code.is_a? Virtual::Set - if( code.to.is_a? NewMessageSlot) + if( code.to.is_a? Virtual::NewMessageSlot) to = RegisterReference.new(:r0) tmp = RegisterReference.new(:r5) - move = RegisterMachine.mov( to , tmp , code.index ) + move = RegisterMachine.instance.ldr( to , tmp , code.to.index ) + block.replace(code , [move] ) else raise "Start coding #{code.inspect}" end end end end - Object.space.add_pass_after SetImplementation , GetImplementation + Virtual::Object.space.add_pass_after SetImplementation , GetImplementation end