comparison core/src/luan/impl/LuanCompiler.java @ 221:ec016471c6eb

make LuanTable an interface git-svn-id: https://luan-java.googlecode.com/svn/trunk@222 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 17 Jul 2014 07:49:26 +0000
parents b2304de4579b
children fed1893821bf
comparison
equal deleted inserted replaced
220:61afe2a1ce96 221:ec016471c6eb
4 import luan.LuanState; 4 import luan.LuanState;
5 import luan.LuanException; 5 import luan.LuanException;
6 import luan.LuanSource; 6 import luan.LuanSource;
7 import luan.LuanElement; 7 import luan.LuanElement;
8 import luan.LuanTable; 8 import luan.LuanTable;
9 import luan.Luan;
9 import java.util.Map; 10 import java.util.Map;
10 11
11 12
12 public final class LuanCompiler { 13 public final class LuanCompiler {
13 private LuanCompiler() {} // never 14 private LuanCompiler() {} // never
14 15
15 public static LuanFunction compile(LuanState luan,LuanSource src,LuanTable env,boolean allowExpr) throws LuanException { 16 public static LuanFunction compile(LuanState luan,LuanSource src,LuanTable env,boolean allowExpr) throws LuanException {
16 boolean passedEnv = env != null; 17 boolean passedEnv = env != null;
17 if( !passedEnv ) 18 if( !passedEnv )
18 env = new LuanTable(); 19 env = Luan.newTable();
19 UpValue.Getter envGetter = new UpValue.ValueGetter(env); 20 UpValue.Getter envGetter = new UpValue.ValueGetter(env);
20 LuanParser parser = new LuanParser(src,envGetter); 21 LuanParser parser = new LuanParser(src,envGetter);
21 for( Map.Entry<Object,Object> entry : luan.global() ) { 22 for( Map.Entry<Object,Object> entry : luan.global() ) {
22 Object key = entry.getKey(); 23 Object key = entry.getKey();
23 if( key instanceof String ) 24 if( key instanceof String )