derive binary code form word

long ago hacked the binary code to use integers (thus forsaking correct
arm binaries)
Finally fix by deriving from Word which now has correct binary access
Dumped binary.name in the process, that is available from the method
This commit is contained in:
Torsten Ruger
2015-11-14 15:04:04 +02:00
parent 8fa92515b5
commit 278eccbed5
8 changed files with 33 additions and 35 deletions

View File

@ -3,29 +3,15 @@
# But the code that the method represents, the binary, is held as an array
# in one of these.
#
# The BinaryCode is really just a name to make sure that when we call a method
# it is really the code we call.
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 < Object
attribute :name
include Indexed
self.offset(2)
def initialize name
super()
self.name = name
end
class BinaryCode < Word
def to_s
"BinaryCode #{self.name}"
"BinaryCode #{self.char_length}"
end
def == other
self.object_id == other.object_id
end
end
end

View File

@ -23,7 +23,7 @@ module Parfait
raise "No class #{name}" unless clazz
self.for_class = clazz
self.name = name
self.binary = BinaryCode.new name
self.binary = BinaryCode.new 0
raise "Wrong type, expect List not #{arguments.class}" unless arguments.is_a? List
arguments.each do |var|
raise "Must be variable argument, not #{var}" unless var.is_a? Variable

View File

@ -152,9 +152,13 @@ module Parfait
"'" + to_s + "'"
end
def padded_length
padded( 4 * get_layout().instance_length + self.char_length )
end
private
def check_length
raise "Length out of bounds #{self.char_length}" if self.char_length > 32
raise "Length out of bounds #{self.char_length}" if self.char_length > 108
end
end
end