Sha256: 20f4556fc0c1e74a24ae07fdce070cc206f966bcc0b457eb2581ca3ba2b7dbcf

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

# frozen_string_literal: true

module Tataru
  module Instructions
    # pushes the callstack and branches
    class CallInstruction < ImmediateModeInstruction
      def run
        labels = memory.hash[:labels]
        unless labels.key? @param
          memory.error = 'Label not found'
          return
        end

        memory.call_stack.push(memory.program_counter)
        memory.program_counter = labels[@param] - 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 lib/tataru/instructions/call_instruction.rb