view src/luan/interp/UnmExpr.java @ 23:2446c1755d9b

minor git-svn-id: https://luan-java.googlecode.com/svn/trunk@24 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 06 Dec 2012 00:35:13 +0000
parents b7d7069fee58
children 5cf15507d77e
line wrap: on
line source

package luan.interp;

import luan.Lua;
import luan.LuaNumber;
import luan.LuaException;
import luan.LuaState;


// unary minus
final class UnmExpr extends UnaryOpExpr {

	UnmExpr(Expr op) {
		super(op);
	}

	@Override public Object eval(LuaState lua) throws LuaException {
		double n = Lua.checkNumber(op.eval(lua)).value();
		return new LuaNumber( -n );
	}
}