diff core/src/luan/impl/FnCall.java @ 645:859c0dedc8b6

remove LuanSource
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Mar 2016 18:09:51 -0600
parents 60c549d43988
children cdc70de628b5
line wrap: on
line diff
--- a/core/src/luan/impl/FnCall.java	Tue Mar 29 13:53:01 2016 -0600
+++ b/core/src/luan/impl/FnCall.java	Tue Mar 29 18:09:51 2016 -0600
@@ -3,20 +3,16 @@
 import luan.Luan;
 import luan.LuanFunction;
 import luan.LuanException;
-import luan.LuanElement;
 import luan.LuanTable;
 
 
 final class FnCall extends CodeImpl implements Expressions {
 	final Expr fnExpr;
 	final Expressions args;
-	final String fnName;
 
-	FnCall(LuanElement el,Expr fnExpr,Expressions args) {
-		super(el);
+	FnCall(Expr fnExpr,Expressions args) {
 		this.fnExpr = fnExpr;
 		this.args = args;
-		this.fnName = fnExpr.el().text();
 	}
 
 	@Override public Object eval(LuanStateImpl luan) throws LuanException {
@@ -24,25 +20,20 @@
 	}
 
 	private Object call(LuanStateImpl luan,Object o,Object[] argVals) throws LuanException {
-		luan.push(el,fnName);
-		try {
-			if( o instanceof LuanFunction ) {
-				LuanFunction fn = (LuanFunction)o;
-				return fn.call( luan, argVals );
-			}
-			if( o instanceof LuanTable ) {
-				LuanTable t = (LuanTable)o;
-				Object h = t.getHandler("__call");
-				if( h != null )
-					return call(luan,h,argVals);
-			}
-			throw new LuanException(luan, "attempt to call '"+fnName+"' (a " + Luan.type(o) + " value)" );
-		} finally {
-			luan.pop();
+		if( o instanceof LuanFunction ) {
+			LuanFunction fn = (LuanFunction)o;
+			return fn.call( luan, argVals );
 		}
+		if( o instanceof LuanTable ) {
+			LuanTable t = (LuanTable)o;
+			Object h = t.getHandler("__call");
+			if( h != null )
+				return call(luan,h,argVals);
+		}
+		throw new LuanException(luan, "attempt to call a " + Luan.type(o) + " value" );
 	}
 
 	@Override public String toString() {
-		return "(FnCall "+fnName+" "+fnExpr+" "+args+")";
+		return "(FnCall "+fnExpr+" "+args+")";
 	}
 }