make binary code indexed (not derive from word)
still some work to be done there, as we should really have a byte buffer
This commit is contained in:
parent
96f43dcfda
commit
1a236aa50e
@ -9,18 +9,17 @@
|
||||
module Parfait
|
||||
# obviously not a "Word" but a ByteArray , but no such class yet
|
||||
# As on the other hand has no encoding (yet) it is close enough
|
||||
class BinaryCode < Word
|
||||
def initialize name
|
||||
super(0)
|
||||
self.name = name
|
||||
end
|
||||
class BinaryCode < Object
|
||||
attribute :name
|
||||
|
||||
# this is a sof check if there are instance variables or "structure"
|
||||
# have to override false, as word answers true
|
||||
def is_value?
|
||||
false
|
||||
include Indexed
|
||||
self.offset(2)
|
||||
|
||||
def initialize name
|
||||
super()
|
||||
self.name = name
|
||||
end
|
||||
|
||||
def to_s
|
||||
"BinaryCode #{self.name}"
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ module Register
|
||||
@machine.objects.each do |id , objekt|
|
||||
next unless objekt.is_a? Parfait::Method
|
||||
# should be fill_to_length (with zeros)
|
||||
objekt.binary.set_length(objekt.source.total_byte_length , 0)
|
||||
objekt.binary.set_length(objekt.source.total_byte_length )
|
||||
end
|
||||
#need the initial jump at 0 and then functions
|
||||
@machine.init.set_position(at)
|
||||
@ -112,14 +112,13 @@ module Register
|
||||
puts "Assembly error #{method.name}\n#{Sof.write(method.source.instructions).to_s[0...2000]}"
|
||||
raise e
|
||||
end
|
||||
method.binary.fill_with 0
|
||||
index = 1
|
||||
stream.rewind
|
||||
#puts "Assembled #{method.name} with length #{stream.length}"
|
||||
raise "length error #{method.binary.length} != #{method.source.total_byte_length}" if method.binary.length != method.source.total_byte_length
|
||||
raise "length error #{method.binary.length} != #{method.source.total_byte_length}" if method.binary.get_length != method.source.total_byte_length
|
||||
raise "length error #{stream.length} != #{method.source.total_byte_length}" if method.source.total_byte_length != stream.length
|
||||
stream.each_byte do |b|
|
||||
method.binary.set_char(index , b )
|
||||
method.binary.set(index , b )
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user