2015-07-17 13:21:57 +03:00
|
|
|
module Register
|
|
|
|
|
|
|
|
|
|
|
|
# a branch must branch to a block.
|
|
|
|
class Branch < Instruction
|
2015-07-18 11:21:49 +03:00
|
|
|
def initialize source , to
|
|
|
|
super(source)
|
2015-07-17 13:21:57 +03:00
|
|
|
raise "No block" unless to
|
|
|
|
@block = to
|
|
|
|
end
|
2015-07-24 13:23:56 +03:00
|
|
|
attr_reader :block
|
2015-07-18 11:21:49 +03:00
|
|
|
|
|
|
|
def to_s
|
2015-10-19 14:46:12 +03:00
|
|
|
"#{self.class.name}: #{block.name}"
|
2015-07-18 11:21:49 +03:00
|
|
|
end
|
2015-10-19 14:46:12 +03:00
|
|
|
alias :inspect :to_s
|
2015-10-07 10:02:51 +03:00
|
|
|
end
|
|
|
|
|
2015-10-19 16:08:00 +03:00
|
|
|
class IsZero < Branch
|
2015-10-07 10:02:51 +03:00
|
|
|
end
|
|
|
|
|
2015-10-19 16:08:00 +03:00
|
|
|
class IsNotzero < Branch
|
2015-10-07 10:02:51 +03:00
|
|
|
end
|
|
|
|
|
2015-10-19 16:08:00 +03:00
|
|
|
class IsMinus < Branch
|
2015-10-07 10:02:51 +03:00
|
|
|
end
|
2015-07-18 11:21:49 +03:00
|
|
|
|
2015-10-19 16:08:00 +03:00
|
|
|
class IsPlus < Branch
|
2015-07-17 13:21:57 +03:00
|
|
|
end
|
2015-07-18 11:21:49 +03:00
|
|
|
|
2015-07-17 13:21:57 +03:00
|
|
|
end
|