Mercurial Hosting > luan
diff core/src/luan/impl/LuanCompiler.java @ 208:5ba136769034
remove MetatableGetter and use a generic metatable instead
git-svn-id: https://luan-java.googlecode.com/svn/trunk@209 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 08 Jul 2014 07:04:47 +0000 |
parents | 24ede40ee0aa |
children | b2304de4579b |
line wrap: on
line diff
--- a/core/src/luan/impl/LuanCompiler.java Tue Jul 08 02:04:24 2014 +0000 +++ b/core/src/luan/impl/LuanCompiler.java Tue Jul 08 07:04:47 2014 +0000 @@ -25,27 +25,18 @@ } FnDef fnDef = parse(luan,parser,allowExpr); final LuanStateImpl luanImpl = (LuanStateImpl)luan; - MtGetterLink mtGetterLink = (MtGetterLink)env.get("_MTG"); - final Closure c = new Closure(luanImpl,fnDef,mtGetterLink); + final Closure c = new Closure(luanImpl,fnDef); + if( passedEnv ) + return c; final LuanTable ENV = env; - if( passedEnv ) { - return new LuanFunction() { - @Override public Object call(LuanState luan,Object[] args) throws LuanException { - Object rtn = c.call(luan,args); - ENV.put("_MTG",luanImpl.mtGetterLink); - return rtn; - } - }; - } else { - return new LuanFunction() { - @Override public Object call(LuanState luan,Object[] args) throws LuanException { - Object rtn = c.call(luan,args); - if( rtn instanceof Object[] && ((Object[])rtn).length==0 ) - rtn = ENV; - return rtn; - } - }; - } + return new LuanFunction() { + @Override public Object call(LuanState luan,Object[] args) throws LuanException { + Object rtn = c.call(luan,args); + if( rtn instanceof Object[] && ((Object[])rtn).length==0 ) + rtn = ENV; + return rtn; + } + }; } private static FnDef parse(LuanState luan,LuanParser parser,boolean allowExpr) throws LuanException {