diff core/src/luan/impl/FnCall.java @ 576:4723d22062ce

remove LuanBit
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Jul 2015 20:38:26 -0600
parents b48cfa14ba60
children d7a85fbe15f1
line wrap: on
line diff
--- a/core/src/luan/impl/FnCall.java	Mon Jul 13 18:34:31 2015 -0600
+++ b/core/src/luan/impl/FnCall.java	Mon Jul 13 20:38:26 2015 -0600
@@ -24,17 +24,22 @@
 	}
 
 	private Object call(LuanStateImpl luan,Object o) throws LuanException {
-		if( o instanceof LuanFunction ) {
-			LuanFunction fn = (LuanFunction)o;
-			return luan.bit(el).call( fn, fnName, Luan.array(args.eval(luan)) );
+		luan.push(el,fnName);
+		try {
+			if( o instanceof LuanFunction ) {
+				LuanFunction fn = (LuanFunction)o;
+				return fn.call( luan, Luan.array(args.eval(luan)) );
+			}
+			if( o instanceof LuanTable ) {
+				LuanTable t = (LuanTable)o;
+				Object h = t.getHandler("__call");
+				if( h != null )
+					return call(luan,h);
+			}
+			throw luan.exception( "attempt to call '"+fnName+"' (a " + Luan.type(o) + " value)" );
+		} finally {
+			luan.pop();
 		}
-		if( o instanceof LuanTable ) {
-			LuanTable t = (LuanTable)o;
-			Object h = t.getHandler("__call");
-			if( h != null )
-				return call(luan,h);
-		}
-		throw luan.bit(fnExpr.el()).exception( "attempt to call '"+fnExpr.el().text()+"' (a " + Luan.type(o) + " value)" );
 	}
 
 	@Override public String toString() {