diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 6b54c6d6..c2ff6fd8 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -90,7 +90,7 @@ module Parfait end def word_length - padded_words( get_layout().get_length() + 2 ) + padded_words( get_layout().get_length() ) end # Object diff --git a/lib/parfait/word.rb b/lib/parfait/word.rb index 38fc6904..0c1f026d 100644 --- a/lib/parfait/word.rb +++ b/lib/parfait/word.rb @@ -129,7 +129,7 @@ module Parfait class_for(MoveInstruction).new(value , self , :opcode => :mov) end def word_length - (string.length+1) / 4 + padded self.length + 1 end end end diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index 711331bf..01b8d6fc 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -84,7 +84,7 @@ module Register # knowing that we fix the problem, we hope to get away with retry. retry end - puts "Assembled 0x#{@stream.length.to_s(16)}/#{@stream.length} bytes" + puts "Assembled 0x#{@stream.length.to_s(16)}/#{@stream.length.to_s(16)} bytes" return @stream.string end @@ -116,7 +116,7 @@ module Register end def assemble_any obj - puts "Assemble #{obj.class}(#{obj.object_id.to_s(16)}) at stream #{(@stream.length).to_s(16)} pos:#{obj.position.to_s(16)} , len:#{obj.word_length}" + puts "Assemble #{obj.class}(#{obj.object_id.to_s(16)}) at stream #{@stream.length.to_s(16)} pos:#{obj.position.to_s(16)} , len:#{obj.word_length.to_s(16)}" if @stream.length != obj.position raise "Assemble #{obj.class} #{obj.object_id.to_s(16)} at #{@stream.length.to_s(16)} not #{obj.position.to_s(16)}" end @@ -154,8 +154,9 @@ module Register puts "Nil for #{object.class}.#{var}" unless inst write_ref_for(inst) end - puts "layout leng=#{layout.get_length.to_s(16)} mem_len=#{layout.word_length.to_s(16)}" - pad_after( layout.word_length ) + puts "layout length=#{layout.get_length.to_s(16)} mem_len=#{layout.word_length.to_s(16)}" + l = layout.get_length + pad_after( l * 4) object.position end @@ -220,7 +221,7 @@ module Register # first line is integers, convention is that following lines are the same TYPE_LENGTH.times { word = ((word << TYPE_BITS) + TYPE_INT) } @stream.write_uint32( word ) - puts "String is #{string} at #{string.position} length #{string.length}" + puts "String is #{string} at #{string.position.to_s(16)} length #{string.length.to_s(16)}" write_ref_for( string.get_layout ) #ref @stream.write str pad_after(str.length) @@ -245,10 +246,13 @@ module Register # pad_after is always in bytes and pads (writes 0's) up to the next 8 word boundary def pad_after length + before = @stream.length.to_s(16) pad = padding_for(length) pad.times do @stream.write_uint8(0) end + after = @stream.length.to_s(16) + puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream #{before}/#{after}" end end diff --git a/lib/virtual/padding.rb b/lib/virtual/padding.rb index 8beb7d89..4fb62776 100644 --- a/lib/virtual/padding.rb +++ b/lib/virtual/padding.rb @@ -16,7 +16,6 @@ module Padding def padding_for length pad = padded(length) - length - 8 # for header, type and layout - puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream pos #{@stream.length.to_s(16)}" pad end end diff --git a/lib/virtual/parfait_adapter.rb b/lib/virtual/parfait_adapter.rb index e4a7378e..d4d81e7d 100644 --- a/lib/virtual/parfait_adapter.rb +++ b/lib/virtual/parfait_adapter.rb @@ -99,7 +99,7 @@ module Parfait class Object include FakeMem include Padding - + # these internal functions are _really_ internal # they respresent the smallest code needed to build larger functionality # but should _never_ be used outside parfait. in fact that should be impossible @@ -174,9 +174,6 @@ module Parfait end class Word - def word_length - padded(1 + length()) - end def == other return false unless other.is_a?(String) or other.is_a?(Word)