Mercurial Hosting > luan
diff src/luan/interp/LuanCompiler.java @ 149:f99fd64291b3
change load() to take env instead of using global
git-svn-id: https://luan-java.googlecode.com/svn/trunk@150 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 16 Jun 2014 05:47:54 +0000 |
parents | f0a4abe58593 |
children | f35c50027985 |
line wrap: on
line diff
--- a/src/luan/interp/LuanCompiler.java Mon Jun 16 04:29:33 2014 +0000 +++ b/src/luan/interp/LuanCompiler.java Mon Jun 16 05:47:54 2014 +0000 @@ -13,7 +13,7 @@ public final class LuanCompiler { private LuanCompiler() {} // never - public static LuanFunction compileModule(LuanState luan,LuanSource src,boolean allowExpr) throws LuanException { + private static LuanFunction compile(LuanState luan,LuanSource src,boolean allowExpr) throws LuanException { UpValue.Getter envGetter = new UpValue.EnvGetter(); LuanParser parser = new LuanParser(src,envGetter); for( Map.Entry<Object,Object> entry : luan.global() ) { @@ -33,8 +33,10 @@ }; } - public static LuanFunction compileGlobal(LuanState luan,LuanSource src,boolean allowExpr) throws LuanException { - UpValue.Getter envGetter = UpValue.globalGetter; + public static LuanFunction compile(LuanState luan,LuanSource src,LuanTable env,boolean allowExpr) throws LuanException { + if( env==null ) + return compile(luan,src,allowExpr); + UpValue.Getter envGetter = new UpValue.ValueGetter(env); LuanParser parser = new LuanParser(src,envGetter); FnDef fnDef = parse(luan,parser,allowExpr); return new Closure((LuanStateImpl)luan,fnDef);