diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index e2d56c07..be617179 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -27,7 +27,11 @@ module Elf type.each_method do |f| f.cpu_instructions.each do |label| next unless label.is_a?(Risc::Label) - add_symbol "#{type.name}::#{f.name}:#{label.name}" , Risc::Position.get(label).at + add_symbol "#{type.name}@#{f.name}:#{label.name}" , Risc::Position.get(label).at + end + f.binary.each do |code| + label = "BinaryCode@#{Risc::Position.get(code).method.name}" + add_symbol label , Risc::Position.get(code).at end end end @@ -41,9 +45,6 @@ module Elf end label += "=#{slot}" if slot.is_a?(Symbol) or slot.is_a?(String) add_symbol label , Risc::Position.get(slot).at - if slot.is_a?(Parfait::TypedMethod) - add_symbol slot.name.to_s , Risc::Position.get(slot.binary).at - end end end diff --git a/lib/parfait/binary_code.rb b/lib/parfait/binary_code.rb index 94e94234..e0b1d0de 100644 --- a/lib/parfait/binary_code.rb +++ b/lib/parfait/binary_code.rb @@ -27,6 +27,11 @@ module Parfait Risc::Position.reset(self) if Risc::Position.set?(self) end + def each( &block ) + block.call( self ) + @next.each( &block ) if @next + end + def to_s "BinaryCode #{Risc::Position.set?(self) ? Risc::Position.get(self): self.object_id.to_s(16)}" end diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index a521f3b9..6fdd653e 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -35,7 +35,7 @@ module Parfait @classes = classes @types = Dictionary.new message = Message.new(nil) - 100.times { @next_integer = Integer.new(0,@next_integer) } + 101.times { @next_integer = Integer.new(0,@next_integer) } 50.times do @first_message = Message.new message #puts "INIT caller #{message.object_id} to #{@first_message.object_id}" diff --git a/test/parfait/test_binary_code.rb b/test/parfait/test_binary_code.rb index 082ed0bc..cd055046 100644 --- a/test/parfait/test_binary_code.rb +++ b/test/parfait/test_binary_code.rb @@ -103,5 +103,10 @@ module Parfait @code.set_word(1 , 1) assert_equal 1, @code.get_internal_word(@code.data_start + 1) end + def test_has_each + sum = 0 + @code.each{ sum += 1} + assert_equal sum , 1 + end end end