view core/src/luan/impl/WhileStmt.java @ 460:b48cfa14ba60

improve stack trace
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 06 May 2015 14:32:29 -0600
parents 3dcb0f9bee82
children 4723d22062ce
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.bit(el).checkBoolean( cnd.eval(luan) ) ) {
				doStmt.eval(luan);
			}
		} catch(BreakException e) {}
	}
}