Fix parfait bug for word_length

This commit is contained in:
Torsten Ruger 2015-06-24 16:08:06 +03:00
parent 59188105ba
commit cedc6e1b61
4 changed files with 15 additions and 8 deletions

View File

@ -4,8 +4,8 @@ module Arm
def initialize to , from , options = {}
super(options)
@to = to
@from = from
@to = to
raise "move must have from set #{inspect}" unless from
@attributes[:update_status] = 0 if @attributes[:update_status] == nil
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil

View File

@ -148,6 +148,15 @@ module Parfait
self.object_id == other.object_id
end
# word length (padded) is the amount of space taken by the object
# For your basic object this means the number of instance variables as determined by layout
# This is off course 0 for a list, unless someone squeezed an instance variable in
# but additionally, the amount of data comes on top.
# unfortuntely we can't just use super because of the Padding
def word_length
padded_words( get_layout().get_length() + get_length() )
end
#many basic List functions can not be defined in ruby, such as
# get/set/length/add/delete
# so they must be defined as CompiledMethods in Builtin::Kernel

View File

@ -30,7 +30,7 @@ module Register
end
#need the initial jump at 0 and then functions
@machine.init.set_position(0)
at = @machine.init.byte_length
at = 0x20 # @machine.init.byte_length
# then we make sure we really get the binary codes first
@machine.objects.each do |objekt|
@ -71,6 +71,7 @@ module Register
@machine.init.codes.each do |code|
code.assemble( @stream )
end
pad_after @machine.init.byte_length - 8 # no header (8)
# then write the methods to file
@machine.objects.each do |objekt|
@ -119,7 +120,7 @@ module Register
end
def write_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.to_s(16)}"
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
@ -160,7 +161,7 @@ module Register
puts "Nil for #{object.class}.#{var}" unless inst
write_ref_for(inst)
end
#puts "layout length=#{layout.get_length.to_s(16)} mem_len=#{layout.word_length.to_s(16)}"
puts "layout length=#{layout.get_length.to_s(16)} mem_len=#{layout.word_length.to_s(16)}"
l = layout.get_length
if( object.is_a? Parfait::List)
object.each do |inst|
@ -216,7 +217,7 @@ module Register
@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}"
puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream #{before}/#{after}"
end
end

View File

@ -137,9 +137,6 @@ module Parfait
end
end
class List
def word_length
padded_words(get_length())
end
def to_sof_node(writer , level , ref )
Sof.array_to_sof_node(self , writer , level , ref )
end