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



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/lang/interpreter.rb', line 410

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