Mercurial Hosting > luan
diff src/luan/impl/IfStmt.java @ 166:4eaee12f6c65
move luan/interp to impl
git-svn-id: https://luan-java.googlecode.com/svn/trunk@167 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 22 Jun 2014 04:17:38 +0000 |
parents | src/luan/interp/IfStmt.java@c9100f29fae0 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/luan/impl/IfStmt.java Sun Jun 22 04:17:38 2014 +0000 @@ -0,0 +1,27 @@ +package luan.impl; + +import luan.Luan; +import luan.LuanException; +import luan.LuanSource; + + +final class IfStmt extends CodeImpl implements Stmt { + private final Expr cnd; + final Stmt thenStmt; + final Stmt elseStmt; + + IfStmt(LuanSource.Element se,Expr cnd,Stmt thenStmt,Stmt elseStmt) { + super(se); + this.cnd = cnd; + this.thenStmt = thenStmt; + this.elseStmt = elseStmt; + } + + @Override public void eval(LuanStateImpl luan) throws LuanException { + if( luan.bit(se).checkBoolean( cnd.eval(luan) ) ) { + thenStmt.eval(luan); + } else { + elseStmt.eval(luan); + } + } +}