Class: EleetScript::WhileNode

Inherits:
Object
  • Object
show all
Includes:
Returnable
Defined in:
lib/lang/nodes.rb,
lib/lang/interpreter.rb

Instance Method Summary collapse

Methods included from Returnable

#reset_returned, #returned, #returned?

Instance Method Details

#eval(context) ⇒ Object



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/lang/interpreter.rb', line 427

def eval(context)
  val = condition.eval(context)
  ret = nil
  while val.ruby_value
    ret = body.eval(context)
    if body.returnable? && body.returned?
      body.reset_returned
      returned
      return ret
    elsif body.nextable? && body.nexted?
      body.reset_nexted
      next
    end
    val = condition.eval(context)
  end
  ret || context.es_nil
end