Mercurial Hosting > luan
comparison core/src/luan/modules/BasicLuan.java @ 694:b620b8e1010f
remove Luan.load() allow_expression param and add Luan.eval()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 20 Apr 2016 20:56:08 -0600 |
parents | ca169567ce07 |
children | b21d82ee5756 |
comparison
equal
deleted
inserted
replaced
693:ca169567ce07 | 694:b620b8e1010f |
---|---|
13 import luan.LuanFunction; | 13 import luan.LuanFunction; |
14 import luan.LuanJavaFunction; | 14 import luan.LuanJavaFunction; |
15 import luan.LuanException; | 15 import luan.LuanException; |
16 import luan.LuanMethod; | 16 import luan.LuanMethod; |
17 import luan.LuanMeta; | 17 import luan.LuanMeta; |
18 import luan.impl.LuanCompiler; | |
19 | 18 |
20 | 19 |
21 public final class BasicLuan { | 20 public final class BasicLuan { |
22 | 21 |
23 public static String type(Object obj) { | 22 public static String type(Object obj) { |
24 return Luan.type(obj); | 23 return Luan.type(obj); |
25 } | 24 } |
26 | 25 |
27 public static LuanFunction load(LuanState luan,String text,String sourceName,LuanTable env,Boolean allowExpr) | 26 public static LuanFunction load(String text,String sourceName,LuanTable env) |
28 throws LuanException | 27 throws LuanException |
29 { | 28 { |
30 if( allowExpr==null ) | 29 Utils.checkNotNull(text); |
31 allowExpr = false; | 30 Utils.checkNotNull(sourceName,1); |
32 return LuanCompiler.compile(sourceName,text,env,allowExpr); | 31 return Luan.load(text,sourceName,env); |
33 } | 32 } |
34 | 33 |
35 public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { | 34 public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { |
36 if( fileName == null ) { | 35 if( fileName == null ) { |
37 fileName = "stdin:"; | 36 fileName = "stdin:"; |
39 fileName = "file:" + fileName; | 38 fileName = "file:" + fileName; |
40 } | 39 } |
41 String src = PackageLuan.read(luan,fileName); | 40 String src = PackageLuan.read(luan,fileName); |
42 if( src == null ) | 41 if( src == null ) |
43 throw new LuanException("file '"+fileName+"' not found" ); | 42 throw new LuanException("file '"+fileName+"' not found" ); |
44 return load(luan,src,fileName,null,false); | 43 return load(src,fileName,null); |
45 } | 44 } |
46 | 45 |
47 public static LuanFunction pairs(final LuanState luan,final LuanTable t) throws LuanException { | 46 public static LuanFunction pairs(final LuanState luan,final LuanTable t) throws LuanException { |
48 Utils.checkNotNull(t); | 47 Utils.checkNotNull(t); |
49 return t.pairs(luan); | 48 return t.pairs(luan); |