2015-07-17 12:21:57 +02:00
|
|
|
module Register
|
|
|
|
|
|
|
|
|
|
|
|
# a branch must branch to a block.
|
|
|
|
class Branch < Instruction
|
2015-07-18 10:21:49 +02:00
|
|
|
def initialize source , to
|
|
|
|
super(source)
|
2015-07-17 12:21:57 +02:00
|
|
|
raise "No block" unless to
|
|
|
|
@block = to
|
|
|
|
end
|
2015-07-24 12:23:56 +02:00
|
|
|
attr_reader :block
|
2015-07-18 10:21:49 +02:00
|
|
|
|
|
|
|
def to_s
|
2015-07-25 08:30:58 +02:00
|
|
|
"Branch: #{block.name}"
|
2015-07-18 10:21:49 +02:00
|
|
|
end
|
2015-10-07 09:02:51 +02:00
|
|
|
alias :inspect :to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
class IsZeroBranch < Branch
|
|
|
|
end
|
|
|
|
|
|
|
|
class IsNegativeBranch < Branch
|
|
|
|
end
|
|
|
|
|
|
|
|
class IsPositiveBranch < Branch
|
|
|
|
end
|
2015-07-18 10:21:49 +02:00
|
|
|
|
2015-10-07 09:02:51 +02:00
|
|
|
class AlwaysBranch < Branch
|
2015-07-17 12:21:57 +02:00
|
|
|
end
|
2015-07-18 10:21:49 +02:00
|
|
|
|
2015-07-17 12:21:57 +02:00
|
|
|
end
|