class Gobstones::Lang::Commands::While

Constants

STACK_LIMIT

Public Instance Methods

evaluate(context, stack_size = 0) click to toggle source
# File lib/gobstones/lang/commands/while.rb, line 10
def evaluate(context, stack_size = 0)
  raise Runner::GobstonesRuntimeError, 'stack overflow' if stack_size == STACK_LIMIT
  return unless evaluate_condition(context).true?

  then_block.evaluate(context)
  evaluate(context, stack_size + 1)
end