Mercurial Hosting > luan
diff src/luan/lib/BasicLib.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 | fcb81fa2df0d |
children | 3c95a2291d64 |
line wrap: on
line diff
--- a/src/luan/lib/BasicLib.java Mon Jun 16 04:29:33 2014 +0000 +++ b/src/luan/lib/BasicLib.java Mon Jun 16 05:47:54 2014 +0000 @@ -36,7 +36,7 @@ add( global, "error", LuanState.class, Object.class ); add( global, "get_metatable", LuanState.class, Object.class ); add( global, "ipairs", LuanState.class, LuanTable.class ); - add( global, "load", LuanState.class, String.class, String.class, Boolean.class, Boolean.class ); + add( global, "load", LuanState.class, String.class, String.class, LuanTable.class, Boolean.class ); add( global, "load_file", LuanState.class, String.class ); add( global, "pairs", LuanState.class, LuanTable.class ); add( global, "range", LuanState.class, Double.TYPE, Double.TYPE, Double.class ); @@ -66,21 +66,18 @@ return Luan.type(obj); } - public static LuanFunction load(LuanState luan,String text,String sourceName,Boolean useGlobal,Boolean allowExpr) + public static LuanFunction load(LuanState luan,String text,String sourceName,LuanTable env,Boolean allowExpr) throws LuanException { if( allowExpr==null ) allowExpr = false; - if( useGlobal!=null && useGlobal ) - return LuanCompiler.compileGlobal(luan,new LuanSource(sourceName,text),allowExpr); - else - return LuanCompiler.compileModule(luan,new LuanSource(sourceName,text),allowExpr); + return LuanCompiler.compile(luan,new LuanSource(sourceName,text),env,allowExpr); } public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { try { String src = fileName==null ? Utils.readAll(new InputStreamReader(System.in)) : IoLib.luanIo(luan,fileName).read_text(); - return load(luan,src,fileName,false,false); + return load(luan,src,fileName,null,false); } catch(IOException e) { throw luan.exception(e); }