view core/src/luan/impl/IfStmt.java @ 634:3dde072c3420

allow "." in theme function name
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 28 Feb 2016 04:21:08 -0700
parents 4723d22062ce
children 859c0dedc8b6
line wrap: on
line source

package luan.impl;

import luan.Luan;
import luan.LuanException;
import luan.LuanElement;


final class IfStmt extends CodeImpl implements Stmt {
	private final Expr cnd;
	final Stmt thenStmt;
	final Stmt elseStmt;

	IfStmt(LuanElement el,Expr cnd,Stmt thenStmt,Stmt elseStmt) {
		super(el);
		this.cnd = cnd;
		this.thenStmt = thenStmt;
		this.elseStmt = elseStmt;
	}

	@Override public void eval(LuanStateImpl luan) throws LuanException {
		if( luan.checkBoolean( cnd.eval(luan), cnd.el() ) ) {
			thenStmt.eval(luan);
		} else {
			elseStmt.eval(luan);
		}
	}
}