view core/src/luan/impl/AndExpr.java @ 457:0ca5d1d6250b

handle StackOverflowError for circular references
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 05 May 2015 23:10:34 -0600
parents bf5e62a9090c
children b48cfa14ba60
line wrap: on
line source

package luan.impl;

import luan.Luan;
import luan.LuanException;
import luan.LuanSource;


final class AndExpr extends BinaryOpExpr {

	AndExpr(LuanSource.Element se,Expr op1,Expr op2) {
		super(se,op1,op2);
	}

	@Override public Object eval(LuanStateImpl luan) throws LuanException {
		Object v1 = op1.eval(luan);
		return v1 == null || Boolean.FALSE.equals(v1) ? v1 : op2.eval(luan);
	}
}