From d8710de5900ee8f94ae5e89686fe6431e8b4e801 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 28 Sep 2014 11:18:24 +0300 Subject: [PATCH] fix frame more --- lib/virtual/boot_space.rb | 2 +- lib/virtual/frame_implementation.rb | 16 ++++++++++++++-- lib/virtual/object.rb | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/virtual/boot_space.rb b/lib/virtual/boot_space.rb index 1a6cb6b8..16f41a77 100644 --- a/lib/virtual/boot_space.rb +++ b/lib/virtual/boot_space.rb @@ -94,7 +94,7 @@ module Virtual end end - @@SPACE = { :names => [:classes,:objects,:symbols,:messages,:frames] , + @@SPACE = { :names => [:classes,:objects,:symbols,:messages, :next_message , :next_frame] , :types => [Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference]} def layout @@SPACE diff --git a/lib/virtual/frame_implementation.rb b/lib/virtual/frame_implementation.rb index 345408dc..86a0d0cc 100644 --- a/lib/virtual/frame_implementation.rb +++ b/lib/virtual/frame_implementation.rb @@ -26,11 +26,23 @@ module Virtual space = BootSpace.space machine = Register::RegisterMachine.instance slot = Virtual::Slot + # a place to store a reference to the space, we grab the next_frame from the space space_tmp = Register::RegisterReference.new(Virtual::Message::TMP_REG) + # a temporary place to store the new frame frame_tmp = space_tmp.next_reg_use - new_codes = [ machine.mov( frame_tmp , space )] + # move the spave to it's register (mov instruction gets the address of the object) + new_codes = [ machine.mov( space_tmp , space )] + # find index in the space wehre to grab frame/message ind = space.layout[:names].index(kind) - new_codes << machine.ldr( frame_tmp , frame_tmp , ind) + raise "index not found for :#{kind}" unless ind + # load the frame/message from space by index + new_codes << machine.ldr( frame_tmp , space_tmp , 5 ) + # save the frame in real frame register + new_codes << machine.mov( Virtual::Message::FRAME_REG , frame_tmp ) + # get the next_frame + new_codes << machine.ldr( frame_tmp , frame_tmp , 2 ) # 2 index of next_frame + # save next frame into space + new_codes << machine.str( frame_tmp , space_tmp , ind) block.replace(code , new_codes ) end end diff --git a/lib/virtual/object.rb b/lib/virtual/object.rb index 43b2766a..7d8509e1 100644 --- a/lib/virtual/object.rb +++ b/lib/virtual/object.rb @@ -8,7 +8,7 @@ module Positioned end def set_position pos # resetting of position used to be error, but since relink and dynamic instruction size it is ok. in measures - if @position != nil and ((@position - pos).abs > 15) + if @position != nil and ((@position - pos).abs > 32) raise "position set again #{pos}!=#{@position} for #{self}" end @position = pos