405a6935d4
and remove the blocks more position stuff coming, but the list part should be ok
56 lines
1003 B
Ruby
56 lines
1003 B
Ruby
module Register
|
|
|
|
|
|
# a branch must branch to a block.
|
|
class Branch < Instruction
|
|
def initialize source , to
|
|
super(source)
|
|
@label = to
|
|
end
|
|
attr_reader :label
|
|
|
|
def to_s
|
|
"#{self.class.name}: #{label.name}"
|
|
end
|
|
alias :inspect :to_s
|
|
|
|
def length labels = []
|
|
ret = super(labels)
|
|
ret += self.label.length(labels) if self.label
|
|
ret
|
|
end
|
|
|
|
def to_ac labels = []
|
|
ret = super(labels)
|
|
ret += self.label.to_ac(labels) if self.label
|
|
ret
|
|
end
|
|
|
|
def total_byte_length labels = []
|
|
ret = super
|
|
ret += label.total_byte_length(labels) if self.label
|
|
ret
|
|
end
|
|
|
|
# labels have the same position as their next
|
|
def set_position position , labels = []
|
|
position = self.label.set_position( position , labels ) if self.label
|
|
super(position,labels)
|
|
end
|
|
|
|
end
|
|
|
|
class IsZero < Branch
|
|
end
|
|
|
|
class IsNotzero < Branch
|
|
end
|
|
|
|
class IsMinus < Branch
|
|
end
|
|
|
|
class IsPlus < Branch
|
|
end
|
|
|
|
end
|