Mercurial Hosting > luan
comparison src/luan/interp/IfStmt.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 IfStmt implements Stmt { | 8 final class IfStmt extends CodeImpl implements Stmt { |
8 private final Expr cnd; | 9 private final Expr cnd; |
9 final Stmt thenStmt; | 10 final Stmt thenStmt; |
10 final Stmt elseStmt; | 11 final Stmt elseStmt; |
11 | 12 |
12 IfStmt(Expr cnd,Stmt thenStmt,Stmt elseStmt) { | 13 IfStmt(LuanSource.Element se,Expr cnd,Stmt thenStmt,Stmt elseStmt) { |
14 super(se); | |
13 this.cnd = cnd; | 15 this.cnd = cnd; |
14 this.thenStmt = thenStmt; | 16 this.thenStmt = thenStmt; |
15 this.elseStmt = elseStmt; | 17 this.elseStmt = elseStmt; |
16 } | 18 } |
17 | 19 |
18 @Override public void eval(LuanStateImpl luan) throws LuanException { | 20 @Override public void eval(LuanStateImpl luan) throws LuanException { |
19 if( Luan.toBoolean( cnd.eval(luan) ) ) { | 21 if( luan.bit(se).checkBoolean( cnd.eval(luan) ) ) { |
20 thenStmt.eval(luan); | 22 thenStmt.eval(luan); |
21 } else { | 23 } else { |
22 elseStmt.eval(luan); | 24 elseStmt.eval(luan); |
23 } | 25 } |
24 } | 26 } |