Sha256: e1b511ac6c90c2c1ace1229b8bab58ac9c9884c12222b13eb96531c5dd55bc39

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

module Whitespace::ISA
  class Njmp < Instruction
    attr_reader :name

    def initialize(vm, name)
      unless Whitespace::Util.is_label?(name)
        raise ArgumentError, "must be a label: #{name}"
      end
      super(vm)
      @name = name
    end

    def execute
      if vm.vstack.pop < 0
        index = Whitespace::Util.find_label(vm.instructions, name)
        vm.pc.change_to index + 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whitespace-ruby-1.0.0 lib/whitespace/instructions/flow_control/njmp.rb