bdcd0f297d
whole branch logic wobbly better syntax needed, but working(ish) for now
32 lines
473 B
Ruby
32 lines
473 B
Ruby
module Register
|
|
|
|
|
|
# a branch must branch to a block.
|
|
class Branch < Instruction
|
|
def initialize source , to
|
|
super(source)
|
|
raise "No block" unless to
|
|
@block = to
|
|
end
|
|
attr_reader :block
|
|
|
|
def to_s
|
|
"#{self.class.name}: #{block.name}"
|
|
end
|
|
alias :inspect :to_s
|
|
end
|
|
|
|
class IsZeroBranch < Branch
|
|
end
|
|
|
|
class IsNegativeBranch < Branch
|
|
end
|
|
|
|
class IsPositiveBranch < Branch
|
|
end
|
|
|
|
class AlwaysBranch < Branch
|
|
end
|
|
|
|
end
|