Mercurial Hosting > luan
comparison core/src/luan/impl/IfStmt.java @ 645:859c0dedc8b6
remove LuanSource
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2016 18:09:51 -0600 |
parents | 4723d22062ce |
children | 8e8c30b72e9b |
comparison
equal
deleted
inserted
replaced
644:ba1e318377c5 | 645:859c0dedc8b6 |
---|---|
1 package luan.impl; | 1 package luan.impl; |
2 | 2 |
3 import luan.Luan; | 3 import luan.Luan; |
4 import luan.LuanException; | 4 import luan.LuanException; |
5 import luan.LuanElement; | |
6 | 5 |
7 | 6 |
8 final class IfStmt extends CodeImpl implements Stmt { | 7 final class IfStmt extends CodeImpl implements Stmt { |
9 private final Expr cnd; | 8 private final Expr cnd; |
10 final Stmt thenStmt; | 9 final Stmt thenStmt; |
11 final Stmt elseStmt; | 10 final Stmt elseStmt; |
12 | 11 |
13 IfStmt(LuanElement el,Expr cnd,Stmt thenStmt,Stmt elseStmt) { | 12 IfStmt(Expr cnd,Stmt thenStmt,Stmt elseStmt) { |
14 super(el); | |
15 this.cnd = cnd; | 13 this.cnd = cnd; |
16 this.thenStmt = thenStmt; | 14 this.thenStmt = thenStmt; |
17 this.elseStmt = elseStmt; | 15 this.elseStmt = elseStmt; |
18 } | 16 } |
19 | 17 |
20 @Override public void eval(LuanStateImpl luan) throws LuanException { | 18 @Override public void eval(LuanStateImpl luan) throws LuanException { |
21 if( luan.checkBoolean( cnd.eval(luan), cnd.el() ) ) { | 19 if( luan.checkBoolean( cnd.eval(luan) ) ) { |
22 thenStmt.eval(luan); | 20 thenStmt.eval(luan); |
23 } else { | 21 } else { |
24 elseStmt.eval(luan); | 22 elseStmt.eval(luan); |
25 } | 23 } |
26 } | 24 } |