Class: Tataru::Instructions::ReturnInstruction

Inherits:
Tataru::Instruction show all
Defined in:
lib/tataru/instructions/return_instruction.rb

Overview

pops the callstack and goes back

Instance Attribute Summary

Attributes inherited from Tataru::Instruction

#memory

Instance Method Summary collapse

Methods inherited from Tataru::Instruction

#execute, expects

Instance Method Details

#runObject



7
8
9
10
11
12
13
# File 'lib/tataru/instructions/return_instruction.rb', line 7

def run
  if memory.call_stack.count.zero?
    return memory.error = 'At bottom of stack'
  end

  memory.program_counter = memory.call_stack.pop
end