Class: Whitespace::ISA::Ujmp
- Inherits:
-
Instruction
- Object
- Instruction
- Whitespace::ISA::Ujmp
- Defined in:
- lib/whitespace/instructions/flow_control/ujmp.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Instruction
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(vm, name) ⇒ Ujmp
constructor
A new instance of Ujmp.
Constructor Details
#initialize(vm, name) ⇒ Ujmp
Returns a new instance of Ujmp.
5 6 7 8 9 10 11 |
# File 'lib/whitespace/instructions/flow_control/ujmp.rb', line 5 def initialize(vm, name) unless Whitespace::Util.is_label?(name) raise ArgumentError, "must be a label: #{name}" end super(vm) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/whitespace/instructions/flow_control/ujmp.rb', line 3 def name @name end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 |
# File 'lib/whitespace/instructions/flow_control/ujmp.rb', line 13 def execute index = Whitespace::Util.find_label(vm.instructions, name) vm.pc.change_to index + 1 end |