view core/src/luan/impl/WhileStmt.java @ 333:2b72947d421a

README.md edited online with Bitbucket
author Hugo Teixeira <hugo.tech@gmail.com>
date Wed, 25 Mar 2015 04:27:56 +0000
parents 3dcb0f9bee82
children b48cfa14ba60
line wrap: on
line source

package luan.impl;

import luan.Luan;
import luan.LuanException;
import luan.LuanSource;


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

	WhileStmt(LuanSource.Element se,Expr cnd,Stmt doStmt) {
		super(se);
		this.cnd = cnd;
		this.doStmt = doStmt;
	}

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