Class: Whitespace::ISA::Ujmp

Inherits:
Instruction show all
Defined in:
lib/whitespace/instructions/flow_control/ujmp.rb

Instance Attribute Summary collapse

Attributes inherited from Instruction

#vm

Instance Method Summary collapse

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

#nameObject (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

#executeObject



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