comparison src/luan/interp/IfStmt.java @ 14:2ddf85634d20

whitespace handling; comments; if/while/repeat statements; git-svn-id: https://luan-java.googlecode.com/svn/trunk@15 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 26 Nov 2012 10:18:46 +0000
parents
children 2446c1755d9b
comparison
equal deleted inserted replaced
13:3b22ffbdb83a 14:2ddf85634d20
1 package luan.interp;
2
3 import luan.Lua;
4 import luan.LuaState;
5 import luan.LuaException;
6
7
8 final class IfStmt implements Stmt {
9 private final Expr cnd;
10 private final Stmt thenStmt;
11 private final Stmt elseStmt;
12
13 IfStmt(Expr cnd,Stmt thenStmt,Stmt elseStmt) {
14 this.cnd = cnd;
15 this.thenStmt = thenStmt;
16 this.elseStmt = elseStmt;
17 }
18
19 @Override public void eval(LuaState lua) throws LuaException {
20 if( Lua.toBoolean( cnd.eval(lua) ) ) {
21 thenStmt.eval(lua);
22 } else {
23 elseStmt.eval(lua);
24 }
25 }
26 }