2019-10-03 20:07:55 +02:00
|
|
|
module SlotMachine
|
2017-08-30 16:21:13 +02:00
|
|
|
|
2018-04-02 18:30:34 +02:00
|
|
|
# Branch jump to the Label given
|
2018-03-20 17:35:09 +01:00
|
|
|
# Eg used at the end of while or end of if_true branch
|
|
|
|
#
|
2018-04-02 18:30:34 +02:00
|
|
|
# Risc equivalent is the same really, called Branch there.
|
2018-03-14 15:55:21 +01:00
|
|
|
#
|
2017-08-30 16:21:13 +02:00
|
|
|
class Jump < Instruction
|
2018-03-21 07:22:53 +01:00
|
|
|
attr_reader :label
|
2017-08-30 16:21:13 +02:00
|
|
|
|
2018-03-21 07:22:53 +01:00
|
|
|
def initialize(label)
|
|
|
|
@label = label
|
2017-08-30 16:21:13 +02:00
|
|
|
end
|
2018-03-20 17:35:09 +01:00
|
|
|
def to_risc(compiler)
|
2018-08-29 20:06:29 +02:00
|
|
|
compiler.add_code Risc::Branch.new(self , @label.risc_label(compiler))
|
2018-03-14 15:55:21 +01:00
|
|
|
end
|
2017-08-30 16:21:13 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|