diff src/luan/interp/SetTableEntry.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/SetTableEntry.java	Thu Dec 20 02:54:06 2012 +0000
+++ b/src/luan/interp/SetTableEntry.java	Fri Dec 21 10:45:54 2012 +0000
@@ -4,13 +4,15 @@
 import luan.LuaTable;
 import luan.Lua;
 import luan.LuaFunction;
+import luan.LuaSource;
 
 
-final class SetTableEntry implements Settable {
+final class SetTableEntry extends CodeImpl implements Settable {
 	private final Expr tableExpr;
 	private final Expr keyExpr;
 
-	SetTableEntry(Expr tableExpr,Expr keyExpr) {
+	SetTableEntry(LuaSource.Element se,Expr tableExpr,Expr keyExpr) {
+		super(se);
 		this.tableExpr = tableExpr;
 		this.keyExpr = keyExpr;
 	}
@@ -19,7 +21,7 @@
 		newindex( lua, tableExpr.eval(lua), keyExpr.eval(lua), value );
 	}
 
-	private static void newindex(LuaStateImpl lua,Object t,Object key,Object value) throws LuaException {
+	private void newindex(LuaStateImpl lua,Object t,Object key,Object value) throws LuaException {
 		Object h;
 		if( t instanceof LuaTable ) {
 			LuaTable table = (LuaTable)t;
@@ -33,11 +35,11 @@
 		} else {
 			h = lua.getHandler("__newindex",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;
-			fn.call(lua,t,key,value);
+			lua.call(fn,se,"__newindex",t,key,value);
 		}
 		newindex(lua,h,key,value);
 	}