view core/src/luan/impl/IfStmt.java @ 254:e0fb8a49e031

add Time.luan git-svn-id: https://luan-java.googlecode.com/svn/trunk@255 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 27 Oct 2014 20:45:05 +0000
parents 2456ef7ada02
children b48cfa14ba60
line wrap: on
line source

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(cnd.se()).checkBoolean( cnd.eval(luan) ) ) {
			thenStmt.eval(luan);
		} else {
			elseStmt.eval(luan);
		}
	}
}