implementation passes involving assembly go to register directory

This commit is contained in:
Torsten Ruger 2014-08-23 21:49:09 +03:00
parent 495df14e19
commit 435fefd310
2 changed files with 8 additions and 7 deletions

View File

@ -1,14 +1,14 @@
module Virtual module Register
# This implements the send logic # This implements the send logic
# Send is so complicated that we actually code it in ruby and stick it in # 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 # That off course opens up an endless loop possibility that we stop by reducing to Class and Module methods
class GetImplementation class GetImplementation
def run block def run block
block.codes.dup.each do |code| block.codes.dup.each do |code|
next unless code.is_a? InstanceGet next unless code.is_a? Virtual::InstanceGet
raise "Start coding" raise "Start coding"
end end
end end
end end
Object.space.add_pass_after GetImplementation, SendImplementation Virtual::Object.space.add_pass_after GetImplementation, Virtual::SendImplementation
end end

View File

@ -1,4 +1,4 @@
module Virtual module Register
# This implements the send logic # This implements the send logic
# Send is so complicated that we actually code it in ruby and stick it in # 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 # 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 def run block
block.codes.dup.each do |code| block.codes.dup.each do |code|
next unless code.is_a? Virtual::Set next unless code.is_a? Virtual::Set
if( code.to.is_a? NewMessageSlot) if( code.to.is_a? Virtual::NewMessageSlot)
to = RegisterReference.new(:r0) to = RegisterReference.new(:r0)
tmp = RegisterReference.new(:r5) 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 else
raise "Start coding #{code.inspect}" raise "Start coding #{code.inspect}"
end end
end end
end end
end end
Object.space.add_pass_after SetImplementation , GetImplementation Virtual::Object.space.add_pass_after SetImplementation , GetImplementation
end end