most of the length and assembly stuff fixed

This commit is contained in:
Torsten Ruger
2015-10-25 10:54:19 +02:00
parent 405a6935d4
commit 471329917b
6 changed files with 45 additions and 25 deletions

View File

@ -27,8 +27,9 @@ module Register
end
def total_byte_length labels = []
ret = super
ret += label.total_byte_length(labels) if self.label
ret = super(labels)
ret += self.label.total_byte_length(labels) if self.label
#puts "#{self.class.name} return #{ret}"
ret
end
@ -38,6 +39,12 @@ module Register
super(position,labels)
end
def assemble_all io , labels = []
self.assemble(io)
self.label.assemble_all(io,labels) if self.label
self.next.assemble_all(io, labels) if self.next
end
end
class IsZero < Branch

View File

@ -32,14 +32,21 @@ module Register
ret
end
def byte_length
0
def assemble io
end
def assemble_all io , labels = []
return if labels.include?(self)
labels << self
self.next.assemble_all(io,labels)
end
def total_byte_length labels = []
return 0 if labels.include?(self)
labels << self
self.next.length(labels)
ret = self.next.total_byte_length(labels)
#puts "#{self.class.name} return #{ret}"
ret
end
# labels have the same position as their next