changeset 577:d7a85fbe15f1

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Jul 2015 20:53:02 -0600
parents 4723d22062ce
children 60c549d43988
files core/src/luan/impl/FnCall.java core/src/luan/impl/ForStmt.java
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
diff -r 4723d22062ce -r d7a85fbe15f1 core/src/luan/impl/FnCall.java
--- a/core/src/luan/impl/FnCall.java	Mon Jul 13 20:38:26 2015 -0600
+++ b/core/src/luan/impl/FnCall.java	Mon Jul 13 20:53:02 2015 -0600
@@ -20,21 +20,21 @@
 	}
 
 	@Override public Object eval(LuanStateImpl luan) throws LuanException {
-		return call( luan, fnExpr.eval(luan) );
+		return call( luan, fnExpr.eval(luan), Luan.array(args.eval(luan)) );
 	}
 
-	private Object call(LuanStateImpl luan,Object o) throws LuanException {
+	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, Luan.array(args.eval(luan)) );
+				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);
+					return call(luan,h,argVals);
 			}
 			throw luan.exception( "attempt to call '"+fnName+"' (a " + Luan.type(o) + " value)" );
 		} finally {
diff -r 4723d22062ce -r d7a85fbe15f1 core/src/luan/impl/ForStmt.java
--- a/core/src/luan/impl/ForStmt.java	Mon Jul 13 20:38:26 2015 -0600
+++ b/core/src/luan/impl/ForStmt.java	Mon Jul 13 20:53:02 2015 -0600
@@ -21,9 +21,10 @@
 	}
 
 	@Override public void eval(LuanStateImpl luan) throws LuanException {
+		Object fnObj = iterExpr.eval(luan);
 		luan.push( iterExpr.el(), iterExpr.el().text() );
 		try {
-			LuanFunction iter = luan.checkFunction( iterExpr.eval(luan) );
+			LuanFunction iter = luan.checkFunction(fnObj);
 			String name = iterExpr.el().text();
 			while(true) {
 				Object vals = iter.call(luan);