diff src/luan/interp/UnmExpr.java @ 40:e3624b7cd603

implement stack trace git-svn-id: https://luan-java.googlecode.com/svn/trunk@41 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 21 Dec 2012 10:45:54 +0000
parents 8a57ebfdfd78
children 57054fa43189
line wrap: on
line diff
--- a/src/luan/interp/UnmExpr.java	Thu Dec 20 02:54:06 2012 +0000
+++ b/src/luan/interp/UnmExpr.java	Fri Dec 21 10:45:54 2012 +0000
@@ -4,13 +4,14 @@
 import luan.LuaNumber;
 import luan.LuaFunction;
 import luan.LuaException;
+import luan.LuaSource;
 
 
 // unary minus
 final class UnmExpr extends UnaryOpExpr {
 
-	UnmExpr(Expr op) {
-		super(op);
+	UnmExpr(LuaSource.Element se,Expr op) {
+		super(se,op);
 	}
 
 	@Override public Object eval(LuaStateImpl lua) throws LuaException {
@@ -18,9 +19,10 @@
 		LuaNumber n = Lua.toNumber(o);
 		if( n != null )
 			return new LuaNumber( -n.value() );
-		LuaFunction fn = lua.getHandlerFunction("__unm",o);
-		if( fn != null )
-			return Utils.first(fn.call(lua,o));
-		throw new LuaException("attempt to perform arithmetic on a "+Lua.type(o)+" value");
+		LuaFunction fn = lua.getHandlerFunction(se,"__unm",o);
+		if( fn != null ) {
+			return Lua.first(lua.call(fn,se,"__unm",o));
+		}
+		throw new LuaException(lua,se,"attempt to perform arithmetic on a "+Lua.type(o)+" value");
 	}
 }