diff --git a/lib/arm/move_instruction.rb b/lib/arm/move_instruction.rb index edd2b9fe..7539c98f 100644 --- a/lib/arm/move_instruction.rb +++ b/lib/arm/move_instruction.rb @@ -69,7 +69,7 @@ module Arm operand = reg_code(right) immediate = 0 # ie not immediate is register else - raise "invalid operand argument #{right.inspect} , #{inspect}" + raise "invalid operand argument #{right.class} , #{self.class}" end op = shift_handling instuction_class = 0b00 # OPC_DATA_PROCESSING @@ -86,7 +86,7 @@ module Arm # by now we have the extra add so assemble that if(@extra) @extra.assemble(io) - puts "Assemble extra at #{self.position.to_s(16)}" + #puts "Assemble extra at #{self.position.to_s(16)}" end end def shift val , by diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index 21800397..469c5bf3 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -117,6 +117,13 @@ module Register assemble_self( clazz , [clazz.name , clazz.super_class_name, clazz.instance_methods] ) end + def assemble_Message me + assemble_self(me , []) + end + def assemble_Frame me + assemble_self(me , []) + end + def assemble_CompiledMethod(method) count = method.blocks.inject(0) { |c , block| c += block.mem_length } word = (count+7) / 32 # all object are multiple of 8 words (7 for header) diff --git a/lib/virtual/boot_space.rb b/lib/virtual/boot_space.rb index 6a2bc287..1a6cb6b8 100644 --- a/lib/virtual/boot_space.rb +++ b/lib/virtual/boot_space.rb @@ -12,7 +12,7 @@ module Virtual # While data ususally would live in a .data section, we may also "inline" it into the code # in an oo system all data is represented as objects - class BootSpace < Virtual::Object + class BootSpace < Virtual::ObjectConstant def initialize super() diff --git a/lib/virtual/frame_implementation.rb b/lib/virtual/frame_implementation.rb index b7d1f2b7..345408dc 100644 --- a/lib/virtual/frame_implementation.rb +++ b/lib/virtual/frame_implementation.rb @@ -16,11 +16,24 @@ module Virtual class FrameImplementation def run block block.codes.dup.each do |code| - next unless code.is_a?(NewFrame) or code.is_a?(NewMessage) - new_codes = [ ] - + if code.is_a?(NewFrame) + kind = :next_frame + elsif code.is_a?(NewMessage) + kind = :next_message + else + next + end + space = BootSpace.space + machine = Register::RegisterMachine.instance + slot = Virtual::Slot + space_tmp = Register::RegisterReference.new(Virtual::Message::TMP_REG) + frame_tmp = space_tmp.next_reg_use + new_codes = [ machine.mov( frame_tmp , space )] + ind = space.layout[:names].index(kind) + new_codes << machine.ldr( frame_tmp , frame_tmp , ind) block.replace(code , new_codes ) end end end + Virtual::BootSpace.space.add_pass_after FrameImplementation , GetImplementation end diff --git a/lib/virtual/machine.rb b/lib/virtual/machine.rb index 410b02e3..1afa78e1 100644 --- a/lib/virtual/machine.rb +++ b/lib/virtual/machine.rb @@ -86,3 +86,4 @@ require_relative "constants" require_relative "boot_space" require_relative "send_implementation" require_relative "get_implementation" +require_relative "frame_implementation"