view core/src/luan/impl/WhileStmt.java @ 614:9ecf5673fb6d

start version 0.15
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 14 Dec 2015 23:55:36 -0700
parents 4723d22062ce
children 859c0dedc8b6
line wrap: on
line source

package luan.impl;

import luan.Luan;
import luan.LuanException;
import luan.LuanElement;


final class WhileStmt extends CodeImpl implements Stmt {
	private final Expr cnd;
	private final Stmt doStmt;

	WhileStmt(LuanElement el,Expr cnd,Stmt doStmt) {
		super(el);
		this.cnd = cnd;
		this.doStmt = doStmt;
	}

	@Override public void eval(LuanStateImpl luan) throws LuanException {
		try {
			while( luan.checkBoolean( cnd.eval(luan), el ) ) {
				doStmt.eval(luan);
			}
		} catch(BreakException e) {}
	}
}