comparison src/luan/interp/FnCall.java @ 48:64ecb7a3aad7

rename Lua to Luan git-svn-id: https://luan-java.googlecode.com/svn/trunk@49 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 28 Dec 2012 03:29:12 +0000
parents e3624b7cd603
children 8ede219cd111
comparison
equal deleted inserted replaced
47:659c7139e903 48:64ecb7a3aad7
1 package luan.interp; 1 package luan.interp;
2 2
3 import luan.Lua; 3 import luan.Luan;
4 import luan.LuaFunction; 4 import luan.LuanFunction;
5 import luan.LuaException; 5 import luan.LuanException;
6 import luan.LuaSource; 6 import luan.LuanSource;
7 7
8 8
9 final class FnCall extends CodeImpl implements Expressions { 9 final class FnCall extends CodeImpl implements Expressions {
10 final Expr fnExpr; 10 final Expr fnExpr;
11 final Expressions args; 11 final Expressions args;
12 final String fnName; 12 final String fnName;
13 13
14 FnCall(LuaSource.Element se,Expr fnExpr,Expressions args) { 14 FnCall(LuanSource.Element se,Expr fnExpr,Expressions args) {
15 super(se); 15 super(se);
16 this.fnExpr = fnExpr; 16 this.fnExpr = fnExpr;
17 this.args = args; 17 this.args = args;
18 this.fnName = fnExpr.se().text(); 18 this.fnName = fnExpr.se().text();
19 } 19 }
20 20
21 @Override public Object[] eval(LuaStateImpl lua) throws LuaException { 21 @Override public Object[] eval(LuanStateImpl lua) throws LuanException {
22 return call( lua, fnExpr.eval(lua) ); 22 return call( lua, fnExpr.eval(lua) );
23 } 23 }
24 24
25 private Object[] call(LuaStateImpl lua,Object o) throws LuaException { 25 private Object[] call(LuanStateImpl lua,Object o) throws LuanException {
26 if( o instanceof LuaFunction ) { 26 if( o instanceof LuanFunction ) {
27 LuaFunction fn = (LuaFunction)o; 27 LuanFunction fn = (LuanFunction)o;
28 return lua.call( fn, se, fnName, args.eval(lua) ); 28 return lua.call( fn, se, fnName, args.eval(lua) );
29 } 29 }
30 Object h = lua.getHandler("__call",o); 30 Object h = lua.getHandler("__call",o);
31 if( h != null ) 31 if( h != null )
32 return call(lua,h); 32 return call(lua,h);
33 throw new LuaException( lua, se, "attempt to call a " + Lua.type(o) + " value" ); 33 throw new LuanException( lua, se, "attempt to call a " + Luan.type(o) + " value" );
34 } 34 }
35 } 35 }