Mercurial Hosting > luan
comparison core/src/luan/modules/BasicLuan.java @ 296:7ea6dfdf81ba
add env param to load_file()
git-svn-id: https://luan-java.googlecode.com/svn/trunk@297 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 15 Dec 2014 08:03:32 +0000 |
parents | 9a0cc6d9b27b |
children | 899253043270 |
comparison
equal
deleted
inserted
replaced
295:1f4cc8505308 | 296:7ea6dfdf81ba |
---|---|
35 add( module, "do_file", LuanState.class, String.class ); | 35 add( module, "do_file", LuanState.class, String.class ); |
36 add( module, "error", LuanState.class, Object.class ); | 36 add( module, "error", LuanState.class, Object.class ); |
37 add( module, "get_metatable", LuanState.class, Object.class ); | 37 add( module, "get_metatable", LuanState.class, Object.class ); |
38 add( module, "ipairs", LuanState.class, LuanTable.class ); | 38 add( module, "ipairs", LuanState.class, LuanTable.class ); |
39 add( module, "load", LuanState.class, String.class, String.class, LuanTable.class, Boolean.class ); | 39 add( module, "load", LuanState.class, String.class, String.class, LuanTable.class, Boolean.class ); |
40 add( module, "load_file", LuanState.class, String.class ); | 40 add( module, "load_file", LuanState.class, String.class, LuanTable.class ); |
41 add( module, "pairs", LuanState.class, LuanTable.class ); | 41 add( module, "pairs", LuanState.class, LuanTable.class ); |
42 add( module, "range", LuanState.class, Double.TYPE, Double.TYPE, Double.class ); | 42 add( module, "range", LuanState.class, Double.TYPE, Double.TYPE, Double.class ); |
43 add( module, "raw_equal", Object.class, Object.class ); | 43 add( module, "raw_equal", Object.class, Object.class ); |
44 add( module, "raw_get", LuanTable.class, Object.class ); | 44 add( module, "raw_get", LuanTable.class, Object.class ); |
45 add( module, "raw_len", LuanState.class, Object.class ); | 45 add( module, "raw_len", LuanState.class, Object.class ); |
72 if( allowExpr==null ) | 72 if( allowExpr==null ) |
73 allowExpr = false; | 73 allowExpr = false; |
74 return LuanCompiler.compile(luan,new LuanSource(sourceName,text),env,allowExpr); | 74 return LuanCompiler.compile(luan,new LuanSource(sourceName,text),env,allowExpr); |
75 } | 75 } |
76 | 76 |
77 public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { | 77 public static LuanFunction load_file(LuanState luan,String fileName,LuanTable env) throws LuanException { |
78 if( fileName == null ) | 78 if( fileName == null ) |
79 fileName = "stdin:"; | 79 fileName = "stdin:"; |
80 LuanFunction fn = PackageLuan.loader(luan,fileName,false); | 80 LuanFunction fn = PackageLuan.loader(luan,fileName,false,env); |
81 if( fn == null ) | 81 if( fn == null ) |
82 throw luan.exception( "file '"+fileName+"' not found" ); | 82 throw luan.exception( "file '"+fileName+"' not found" ); |
83 return fn; | 83 return fn; |
84 } | 84 } |
85 | 85 |
86 public static Object do_file(LuanState luan,String fileName) throws LuanException { | 86 public static Object do_file(LuanState luan,String fileName) throws LuanException { |
87 LuanFunction fn = load_file(luan,fileName); | 87 LuanFunction fn = load_file(luan,fileName,null); |
88 return luan.call(fn); | 88 return luan.call(fn); |
89 } | 89 } |
90 | 90 |
91 public static LuanFunction pairs(LuanState luan,final LuanTable t) throws LuanException { | 91 public static LuanFunction pairs(LuanState luan,final LuanTable t) throws LuanException { |
92 Utils.checkNotNull(luan,t); | 92 Utils.checkNotNull(luan,t); |