view core/src/luan/impl/PowExpr.java @ 446:bbad2d06f728

remove automatic conversion from string to number
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 04 May 2015 16:21:17 -0600
parents 3dcb0f9bee82
children b48cfa14ba60
line wrap: on
line source

package luan.impl;

import luan.LuanException;
import luan.LuanSource;


final class PowExpr extends BinaryOpExpr {

	PowExpr(LuanSource.Element 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 Math.pow( ((Number)o1).doubleValue(), ((Number)o2).doubleValue() );
		return arithmetic(luan,"__pow",o1,o2);
	}
}