view core/src/luan/impl/DivExpr.java @ 532:9bf9ad733827

add logging/init so that logging can be used if initialized elsewhere
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 27 May 2015 22:19:46 -0600
parents b48cfa14ba60
children 859c0dedc8b6
line wrap: on
line source

package luan.impl;

import luan.LuanException;
import luan.LuanElement;


final class DivExpr extends BinaryOpExpr {

	DivExpr(LuanElement se,Expr op1,Expr op2) {
		super(se,op1,op2);
	}

	@Override public Object eval(LuanStateImpl luan) throws LuanException {
		Object o1 = op1.eval(luan);
		Object o2 = op2.eval(luan);
		if( o1 instanceof Number && o2 instanceof Number )
			return ((Number)o1).doubleValue() / ((Number)o2).doubleValue();
		return arithmetic(luan,"__div",o1,o2);
	}
}