diff src/luan/interp/IndexExpr.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 64ecb7a3aad7
line wrap: on
line diff
--- a/src/luan/interp/IndexExpr.java	Thu Dec 20 02:54:06 2012 +0000
+++ b/src/luan/interp/IndexExpr.java	Fri Dec 21 10:45:54 2012 +0000
@@ -4,19 +4,20 @@
 import luan.LuaException;
 import luan.LuaTable;
 import luan.LuaFunction;
+import luan.LuaSource;
 
 
 final class IndexExpr extends BinaryOpExpr {
 
-	IndexExpr(Expr op1,Expr op2) {
-		super(op1,op2);
+	IndexExpr(LuaSource.Element se,Expr op1,Expr op2) {
+		super(se,op1,op2);
 	}
 
 	@Override public Object eval(LuaStateImpl lua) throws LuaException {
 		return index(lua,op1.eval(lua),op2.eval(lua));
 	}
 
-	private static Object index(LuaStateImpl lua,Object t,Object key) throws LuaException {
+	private Object index(LuaStateImpl lua,Object t,Object key) throws LuaException {
 		Object h;
 		if( t instanceof LuaTable ) {
 			LuaTable tbl = (LuaTable)t;
@@ -29,11 +30,11 @@
 		} else {
 			h = lua.getHandler("__index",t);
 			if( h==null )
-				throw new LuaException( "attempt to index a " + Lua.type(t) + " value" );
+				throw new LuaException( lua, se, "attempt to index a " + Lua.type(t) + " value" );
 		}
 		if( h instanceof LuaFunction ) {
 			LuaFunction fn = (LuaFunction)h;
-			return Utils.first(fn.call(lua,t,key));
+			return Lua.first(lua.call(fn,se,"__index",t,key));
 		}
 		return index(lua,h,key);
 	}