comparison 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
comparison
equal deleted inserted replaced
575:7c3ad6db8ac3 576:4723d22062ce
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) );
24 } 24 }
25 25
26 private Object call(LuanStateImpl luan,Object o) throws LuanException { 26 private Object call(LuanStateImpl luan,Object o) throws LuanException {
27 if( o instanceof LuanFunction ) { 27 luan.push(el,fnName);
28 LuanFunction fn = (LuanFunction)o; 28 try {
29 return luan.bit(el).call( fn, fnName, Luan.array(args.eval(luan)) ); 29 if( o instanceof LuanFunction ) {
30 LuanFunction fn = (LuanFunction)o;
31 return fn.call( luan, Luan.array(args.eval(luan)) );
32 }
33 if( o instanceof LuanTable ) {
34 LuanTable t = (LuanTable)o;
35 Object h = t.getHandler("__call");
36 if( h != null )
37 return call(luan,h);
38 }
39 throw luan.exception( "attempt to call '"+fnName+"' (a " + Luan.type(o) + " value)" );
40 } finally {
41 luan.pop();
30 } 42 }
31 if( o instanceof LuanTable ) {
32 LuanTable t = (LuanTable)o;
33 Object h = t.getHandler("__call");
34 if( h != null )
35 return call(luan,h);
36 }
37 throw luan.bit(fnExpr.el()).exception( "attempt to call '"+fnExpr.el().text()+"' (a " + Luan.type(o) + " value)" );
38 } 43 }
39 44
40 @Override public String toString() { 45 @Override public String toString() {
41 return "(FnCall "+fnName+" "+fnExpr+" "+args+")"; 46 return "(FnCall "+fnName+" "+fnExpr+" "+args+")";
42 } 47 }