comparison src/luan/interp/WhileStmt.java @ 151:c9100f29fae0

conditions must be type boolean git-svn-id: https://luan-java.googlecode.com/svn/trunk@152 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 16 Jun 2014 10:37:06 +0000
parents 8ede219cd111
children
comparison
equal deleted inserted replaced
150:f35c50027985 151:c9100f29fae0
1 package luan.interp; 1 package luan.interp;
2 2
3 import luan.Luan; 3 import luan.Luan;
4 import luan.LuanException; 4 import luan.LuanException;
5 import luan.LuanSource;
5 6
6 7
7 final class WhileStmt implements Stmt { 8 final class WhileStmt extends CodeImpl implements Stmt {
8 private final Expr cnd; 9 private final Expr cnd;
9 private final Stmt doStmt; 10 private final Stmt doStmt;
10 11
11 WhileStmt(Expr cnd,Stmt doStmt) { 12 WhileStmt(LuanSource.Element se,Expr cnd,Stmt doStmt) {
13 super(se);
12 this.cnd = cnd; 14 this.cnd = cnd;
13 this.doStmt = doStmt; 15 this.doStmt = doStmt;
14 } 16 }
15 17
16 @Override public void eval(LuanStateImpl luan) throws LuanException { 18 @Override public void eval(LuanStateImpl luan) throws LuanException {
17 try { 19 try {
18 while( Luan.toBoolean( cnd.eval(luan) ) ) { 20 while( luan.bit(se).checkBoolean( cnd.eval(luan) ) ) {
19 doStmt.eval(luan); 21 doStmt.eval(luan);
20 } 22 }
21 } catch(BreakException e) {} 23 } catch(BreakException e) {}
22 } 24 }
23 } 25 }