mem_length to word/byte length
be more specific, and don’t include padding
This commit is contained in:
@ -62,13 +62,13 @@ module Virtual
|
||||
puts "BLOCK #{self.to_s[0..5000]}"
|
||||
raise e
|
||||
end
|
||||
raise code.inspect unless code.mem_length
|
||||
at += code.mem_length
|
||||
raise code.inspect unless code.byte_length
|
||||
at += code.byte_length
|
||||
end
|
||||
end
|
||||
|
||||
def mem_length
|
||||
@codes.inject(0){|count , instruction| count += instruction.mem_length }
|
||||
def byte_length
|
||||
@codes.inject(0){|count , instruction| count += instruction.byte_length }
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
@ -135,9 +135,8 @@ module Virtual
|
||||
add_code ::Arm::ArmMachine.send(meth , *arg_names)
|
||||
end
|
||||
|
||||
def mem_length
|
||||
l = @blocks.inject(0) { |c , block| c += block.mem_length }
|
||||
padded(l)
|
||||
def byte_length
|
||||
@blocks.inject(0) { |c , block| c += block.byte_length }
|
||||
end
|
||||
|
||||
# position of the function is the position of the entry block, is where we call
|
||||
@ -145,7 +144,7 @@ module Virtual
|
||||
at += 8 #for the 2 header words
|
||||
@blocks.each do |block|
|
||||
block.set_position at
|
||||
at = at + block.mem_length
|
||||
at = at + block.byte_length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ module FakeMem
|
||||
def position
|
||||
if @position.nil?
|
||||
str = "IN machine #{Virtual.machine.objects.include?(self)}\n"
|
||||
raise str + "position not set for #{self.class} at #{mem_length} for #{self.inspect[0...100]}"
|
||||
raise str + "position not set for #{self.class} at #{word_length} for #{self.inspect[0...100]}"
|
||||
end
|
||||
@position
|
||||
end
|
||||
@ -61,7 +61,7 @@ class Symbol
|
||||
def get_layout
|
||||
Virtual.machine.class_mappings[:Word].object_layout
|
||||
end
|
||||
def mem_length
|
||||
def word_length
|
||||
to_s.length
|
||||
end
|
||||
# not the prettiest addition to the game, but it wasn't me who decided symbols are frozen in 2.x
|
||||
@ -147,7 +147,7 @@ module Parfait
|
||||
end
|
||||
end
|
||||
class List
|
||||
def mem_length
|
||||
def word_length
|
||||
padded_words(get_length())
|
||||
end
|
||||
def to_sof_node(writer , level , ref )
|
||||
@ -174,7 +174,7 @@ module Parfait
|
||||
end
|
||||
|
||||
class Word
|
||||
def mem_length
|
||||
def word_length
|
||||
padded(1 + length())
|
||||
end
|
||||
|
||||
|
@ -41,9 +41,9 @@ module Virtual
|
||||
# Code interface follows. Note position is inheitted as is from Code
|
||||
|
||||
# length of the Plock is the length of the block, plus the branch, plus data.
|
||||
def mem_length
|
||||
len = @data.inject(super) {| sum , item | sum + item.mem_length}
|
||||
len + @branch_code.mem_length
|
||||
def byte_length
|
||||
len = @data.inject(super) {| sum , item | sum + item.word_length}
|
||||
len + @branch_code.word_length
|
||||
end
|
||||
|
||||
# again, super + branch plus data
|
||||
@ -52,7 +52,7 @@ module Virtual
|
||||
@branch_code.link_at pos , context
|
||||
@data.each do |code|
|
||||
code.link_at(pos , context)
|
||||
pos += code.mem_length
|
||||
pos += code.word_length
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@ require_relative "type"
|
||||
module Positioned
|
||||
def position
|
||||
if @position == nil
|
||||
raise "position accessed but not set at #{mem_length} for #{self.inspect[0...500]}"
|
||||
raise "position accessed but not set at #{word_length} for #{self.inspect[0...500]}"
|
||||
end
|
||||
@position
|
||||
end
|
||||
|
Reference in New Issue
Block a user