comparison core/src/luan/impl/FnCall.java @ 577:d7a85fbe15f1

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Jul 2015 20:53:02 -0600
parents 4723d22062ce
children 60c549d43988
comparison
equal deleted inserted replaced
576:4723d22062ce 577:d7a85fbe15f1
18 this.args = args; 18 this.args = args;
19 this.fnName = fnExpr.el().text(); 19 this.fnName = fnExpr.el().text();
20 } 20 }
21 21
22 @Override public Object eval(LuanStateImpl luan) throws LuanException { 22 @Override public Object eval(LuanStateImpl luan) throws LuanException {
23 return call( luan, fnExpr.eval(luan) ); 23 return call( luan, fnExpr.eval(luan), Luan.array(args.eval(luan)) );
24 } 24 }
25 25
26 private Object call(LuanStateImpl luan,Object o) throws LuanException { 26 private Object call(LuanStateImpl luan,Object o,Object[] argVals) throws LuanException {
27 luan.push(el,fnName); 27 luan.push(el,fnName);
28 try { 28 try {
29 if( o instanceof LuanFunction ) { 29 if( o instanceof LuanFunction ) {
30 LuanFunction fn = (LuanFunction)o; 30 LuanFunction fn = (LuanFunction)o;
31 return fn.call( luan, Luan.array(args.eval(luan)) ); 31 return fn.call( luan, argVals );
32 } 32 }
33 if( o instanceof LuanTable ) { 33 if( o instanceof LuanTable ) {
34 LuanTable t = (LuanTable)o; 34 LuanTable t = (LuanTable)o;
35 Object h = t.getHandler("__call"); 35 Object h = t.getHandler("__call");
36 if( h != null ) 36 if( h != null )
37 return call(luan,h); 37 return call(luan,h,argVals);
38 } 38 }
39 throw luan.exception( "attempt to call '"+fnName+"' (a " + Luan.type(o) + " value)" ); 39 throw luan.exception( "attempt to call '"+fnName+"' (a " + Luan.type(o) + " value)" );
40 } finally { 40 } finally {
41 luan.pop(); 41 luan.pop();
42 } 42 }