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