view src/luan/interp/WhileStmt.java @ 48:64ecb7a3aad7

rename Lua to Luan git-svn-id: https://luan-java.googlecode.com/svn/trunk@49 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 28 Dec 2012 03:29:12 +0000
parents 5cf15507d77e
children 8ede219cd111
line wrap: on
line source

package luan.interp;

import luan.Luan;
import luan.LuanException;


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

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

	@Override public void eval(LuanStateImpl lua) throws LuanException {
		try {
			while( Luan.toBoolean( cnd.eval(lua) ) ) {
				doStmt.eval(lua);
			}
		} catch(BreakException e) {}
	}
}