Mercurial Hosting > luan
comparison core/src/luan/impl/FnCall.java @ 404:d55e873e1f0d
metatables now only apply to tables
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 29 Apr 2015 07:04:40 -0600 |
parents | 3dcb0f9bee82 |
children | 8fbb961aabd5 |
comparison
equal
deleted
inserted
replaced
403:637f7ad85654 | 404:d55e873e1f0d |
---|---|
2 | 2 |
3 import luan.Luan; | 3 import luan.Luan; |
4 import luan.LuanFunction; | 4 import luan.LuanFunction; |
5 import luan.LuanException; | 5 import luan.LuanException; |
6 import luan.LuanSource; | 6 import luan.LuanSource; |
7 import luan.LuanTable; | |
7 | 8 |
8 | 9 |
9 final class FnCall extends CodeImpl implements Expressions { | 10 final class FnCall extends CodeImpl implements Expressions { |
10 final Expr fnExpr; | 11 final Expr fnExpr; |
11 final Expressions args; | 12 final Expressions args; |
25 private Object call(LuanStateImpl luan,Object o) throws LuanException { | 26 private Object call(LuanStateImpl luan,Object o) throws LuanException { |
26 if( o instanceof LuanFunction ) { | 27 if( o instanceof LuanFunction ) { |
27 LuanFunction fn = (LuanFunction)o; | 28 LuanFunction fn = (LuanFunction)o; |
28 return luan.bit(se).call( fn, fnName, Luan.array(args.eval(luan)) ); | 29 return luan.bit(se).call( fn, fnName, Luan.array(args.eval(luan)) ); |
29 } | 30 } |
30 Object h = luan.getHandler("__call",o); | 31 if( o instanceof LuanTable ) { |
31 if( h != null ) | 32 Object h = luan.getHandler("__call",(LuanTable)o); |
32 return call(luan,h); | 33 if( h != null ) |
34 return call(luan,h); | |
35 } | |
33 throw luan.bit(fnExpr.se()).exception( "attempt to call '"+fnExpr.se().text()+"' (a " + Luan.type(o) + " value)" ); | 36 throw luan.bit(fnExpr.se()).exception( "attempt to call '"+fnExpr.se().text()+"' (a " + Luan.type(o) + " value)" ); |
34 } | 37 } |
35 | 38 |
36 @Override public String toString() { | 39 @Override public String toString() { |
37 return "(FnCall "+fnName+" "+fnExpr+" "+args+")"; | 40 return "(FnCall "+fnName+" "+fnExpr+" "+args+")"; |