Mercurial Hosting > luan
comparison src/luan/Luan.java @ 1434:56fb5cd8228d
cache compiled code in temp files
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 29 Dec 2019 15:25:07 -0700 |
parents | d7644b21b128 |
children | bbc41b305935 |
comparison
equal
deleted
inserted
replaced
1433:5f038be65271 | 1434:56fb5cd8228d |
---|---|
65 public Map registry() { | 65 public Map registry() { |
66 return registry; | 66 return registry; |
67 } | 67 } |
68 | 68 |
69 public Object eval(String cmd,Object... args) throws LuanException { | 69 public Object eval(String cmd,Object... args) throws LuanException { |
70 return load(cmd,"eval").call(args); | 70 return load(cmd,"eval",false).call(args); |
71 } | 71 } |
72 | 72 |
73 public Object require(String modName) throws LuanException { | 73 public Object require(String modName) throws LuanException { |
74 return PackageLuan.require(this,modName); | 74 return PackageLuan.require(this,modName); |
75 } | 75 } |
180 public static LuanFunction loadClasspath(Luan luan,String classpath) | 180 public static LuanFunction loadClasspath(Luan luan,String classpath) |
181 throws LuanException | 181 throws LuanException |
182 { | 182 { |
183 try { | 183 try { |
184 String src = IoLuan.classpath(luan,classpath).read_text(); | 184 String src = IoLuan.classpath(luan,classpath).read_text(); |
185 return luan.load(src,"classpath:"+classpath); | 185 return luan.load(src,"classpath:"+classpath,true); |
186 } catch(IOException e) { | 186 } catch(IOException e) { |
187 throw new RuntimeException(e); | 187 throw new RuntimeException(e); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
278 if( obj instanceof LuanFunction ) | 278 if( obj instanceof LuanFunction ) |
279 return (LuanFunction)obj; | 279 return (LuanFunction)obj; |
280 throw new LuanException("attempt to call a " + Luan.type(obj) + " value" ); | 280 throw new LuanException("attempt to call a " + Luan.type(obj) + " value" ); |
281 } | 281 } |
282 | 282 |
283 public LuanFunction load(String text,String sourceName,LuanTable env) | 283 public LuanFunction load(String text,String sourceName,boolean persist,LuanTable env) |
284 throws LuanException | 284 throws LuanException |
285 { | 285 { |
286 return LuanCompiler.compile(this,text,sourceName,env); | 286 return LuanCompiler.compile(this,text,sourceName,persist,env); |
287 } | 287 } |
288 | 288 |
289 public LuanFunction load(String text,String sourceName) | 289 public LuanFunction load(String text,String sourceName,boolean persist) |
290 throws LuanException | 290 throws LuanException |
291 { | 291 { |
292 return load(text,sourceName,null); | 292 return load(text,sourceName,persist,null); |
293 } | 293 } |
294 | 294 |
295 public static Object toJava(Object obj) throws LuanException { | 295 public static Object toJava(Object obj) throws LuanException { |
296 if( !(obj instanceof LuanTable) ) | 296 if( !(obj instanceof LuanTable) ) |
297 return obj; | 297 return obj; |