diff core/src/luan/impl/WhileStmt.java @ 171:3dcb0f9bee82

add core component git-svn-id: https://luan-java.googlecode.com/svn/trunk@172 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 22 Jun 2014 05:41:22 +0000
parents src/luan/impl/WhileStmt.java@4eaee12f6c65
children b48cfa14ba60
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/luan/impl/WhileStmt.java	Sun Jun 22 05:41:22 2014 +0000
@@ -0,0 +1,25 @@
+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) {}
+	}
+}