From c9ec6e2f398d7ea0509e5f57aec8b48ae3fb4c63 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 9 Jun 2015 11:38:03 +0200 Subject: [PATCH] fix debug --- lib/elf/object_writer.rb | 12 ++++++------ lib/register/assembler.rb | 5 +++-- lib/virtual/block.rb | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index 66b6ac52..17ee30b4 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -29,14 +29,14 @@ module Elf end end end - space.main.blocks.each do |b| - add_symbol "main@#{b.name}" , b.position - end - add_symbol "#register@#{space.init.name}" , space.init.position - assembler.objects.values.each do |slot| +# @object_machine.space.main.blocks.each do |b| +# add_symbol "main@#{b.name}" , b.position +# end +# add_symbol "#register@#{@object_machine.space.init.name}" , @object_machine.space.init.position + @object_machine.objects.each do |slot| label = "#{slot.class.name}::#{slot.position.to_s(16)}" label += "=#{slot}" if slot.is_a?(Symbol) or slot.is_a?(String) - label += "=#{slot.string}" if slot.is_a?(Parfait::Word) + label += "=#{slot.name}" if slot.is_a?(Parfait::BinaryCode) add_symbol label , slot.position end end diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index ee5db139..f7156326 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -2,9 +2,9 @@ module Register class LinkException < Exception end # Assemble the object machine into a binary. - # Link first to get positions, then assemble + # Assemble first to get positions, then write - # The link function determines the length of an object and the assemble actually + # The assemble function determines the length of an object and then actually # writes the bytes they are pretty much dependant. In an earlier version they were # functions on the objects, but now it has gone to a visitor pattern. @@ -25,6 +25,7 @@ module Register # binary code (array) to right length @machine.objects.each do |objekt| next unless objekt.is_a? Parfait::Method + # should be fill_to_length (with zeros) objekt.code.set_length(objekt.info.byte_length , 0) end at = 0 diff --git a/lib/virtual/block.rb b/lib/virtual/block.rb index 03033cf6..b0400200 100644 --- a/lib/virtual/block.rb +++ b/lib/virtual/block.rb @@ -17,7 +17,7 @@ module Virtual @codes = [] end - attr_reader :name , :codes , :method + attr_reader :name , :codes , :method , :position attr_accessor :branch def reachable ret = []