Mercurial Hosting > luan
comparison core/src/luan/impl/LuanCompiler.java @ 215:b2304de4579b
minor
git-svn-id: https://luan-java.googlecode.com/svn/trunk@216 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 11 Jul 2014 23:13:15 +0000 |
parents | 5ba136769034 |
children | ec016471c6eb |
comparison
equal
deleted
inserted
replaced
214:8e4ef9134362 | 215:b2304de4579b |
---|---|
26 FnDef fnDef = parse(luan,parser,allowExpr); | 26 FnDef fnDef = parse(luan,parser,allowExpr); |
27 final LuanStateImpl luanImpl = (LuanStateImpl)luan; | 27 final LuanStateImpl luanImpl = (LuanStateImpl)luan; |
28 final Closure c = new Closure(luanImpl,fnDef); | 28 final Closure c = new Closure(luanImpl,fnDef); |
29 if( passedEnv ) | 29 if( passedEnv ) |
30 return c; | 30 return c; |
31 final LuanTable ENV = env; | |
32 return new LuanFunction() { | 31 return new LuanFunction() { |
33 @Override public Object call(LuanState luan,Object[] args) throws LuanException { | 32 @Override public Object call(LuanState luan,Object[] args) throws LuanException { |
34 Object rtn = c.call(luan,args); | 33 Object rtn = c.call(luan,args); |
35 if( rtn instanceof Object[] && ((Object[])rtn).length==0 ) | 34 if( rtn instanceof Object[] && ((Object[])rtn).length==0 ) |
36 rtn = ENV; | 35 rtn = c.upValues()[0].get(); |
37 return rtn; | 36 return rtn; |
38 } | 37 } |
39 }; | 38 }; |
40 } | 39 } |
41 | 40 |