Mercurial Hosting > luan
diff src/luan/interp/LenExpr.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/LenExpr.java Thu Dec 20 02:54:06 2012 +0000 +++ b/src/luan/interp/LenExpr.java Fri Dec 21 10:45:54 2012 +0000 @@ -5,12 +5,13 @@ import luan.LuaTable; import luan.LuaFunction; import luan.LuaException; +import luan.LuaSource; final class LenExpr extends UnaryOpExpr { - LenExpr(Expr op) { - super(op); + LenExpr(LuaSource.Element se,Expr op) { + super(se,op); } @Override public Object eval(LuaStateImpl lua) throws LuaException { @@ -19,13 +20,13 @@ String s = (String)o; return new LuaNumber( s.length() ); } - LuaFunction fn = lua.getHandlerFunction("__len",o); + LuaFunction fn = lua.getHandlerFunction(se,"__len",o); if( fn != null ) - return Utils.first(fn.call(lua,o)); + return Lua.first(lua.call(fn,se,"__len",o)); if( o instanceof LuaTable ) { LuaTable t = (LuaTable)o; return t.length(); } - throw new LuaException( "attempt to get length of a " + Lua.type(o) + " value" ); + throw new LuaException( lua, se, "attempt to get length of a " + Lua.type(o) + " value" ); } }