view src/luan/interp/RepeatStmt.java @ 40:e3624b7cd603

implement stack trace git-svn-id: https://luan-java.googlecode.com/svn/trunk@41 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 21 Dec 2012 10:45:54 +0000
parents 5cf15507d77e
children 64ecb7a3aad7
line wrap: on
line source

package luan.interp;

import luan.Lua;
import luan.LuaException;


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

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

	@Override public void eval(LuaStateImpl lua) throws LuaException {
		try {
			do {
				doStmt.eval(lua);
			} while( !Lua.toBoolean( cnd.eval(lua) ) );
		} catch(BreakException e) {}
	}
}