comparison core/src/luan/LuanState.java @ 199:8960c81eb4bc

minor git-svn-id: https://luan-java.googlecode.com/svn/trunk@200 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 03 Jul 2014 21:37:47 +0000
parents 24ede40ee0aa
children 9fb218211763
comparison
equal deleted inserted replaced
198:390210409719 199:8960c81eb4bc
10 import luan.modules.BasicLuan; 10 import luan.modules.BasicLuan;
11 import luan.modules.PackageLuan; 11 import luan.modules.PackageLuan;
12 12
13 13
14 public abstract class LuanState implements DeepCloneable<LuanState> { 14 public abstract class LuanState implements DeepCloneable<LuanState> {
15 private final LuanBit JAVA = bit(LuanElement.JAVA);
16 15
17 public LuanException exception(Object msg) { 16 final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>();
18 return JAVA.exception(msg);
19 }
20
21 public Object call(LuanFunction fn) throws LuanException {
22 return call(fn,null,LuanFunction.NOTHING);
23 }
24
25 public Object call(LuanFunction fn,String fnName) throws LuanException {
26 return call(fn,fnName,LuanFunction.NOTHING);
27 }
28
29 public Object call(LuanFunction fn,Object[] args) throws LuanException {
30 return call(fn,null,args);
31 }
32
33 public Object call(LuanFunction fn,String fnName,Object[] args) throws LuanException {
34 return JAVA.call(fn,fnName,args);
35 }
36
37 public LuanFunction checkFunction(Object obj) throws LuanException {
38 return JAVA.checkFunction(obj);
39 }
40
41 public String toString(Object obj) throws LuanException {
42 return JAVA.toString(obj);
43 }
44
45 public String repr(Object obj) throws LuanException {
46 return JAVA.repr(obj);
47 }
48
49 public boolean isLessThan(Object o1,Object o2) throws LuanException {
50 return JAVA.isLessThan(o1,o2);
51 }
52
53
54 17
55 private LuanTable global; 18 private LuanTable global;
56 private LuanTable loaded; 19 private LuanTable loaded;
57 private LuanTable preload; 20 private LuanTable preload;
58 private LuanTable searchers; 21 private LuanTable searchers;
59
60 final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>();
61 22
62 protected LuanState() { 23 protected LuanState() {
63 global = new LuanTable(); 24 global = new LuanTable();
64 global.put("_G",global); 25 global.put("_G",global);
65 loaded = new LuanTable(); 26 loaded = new LuanTable();
154 public final Object getHandler(String op,Object obj) { 115 public final Object getHandler(String op,Object obj) {
155 LuanTable t = getMetatable(obj); 116 LuanTable t = getMetatable(obj);
156 return t==null ? null : t.get(op); 117 return t==null ? null : t.get(op);
157 } 118 }
158 119
120
121 // convenience methods
122
123 private final LuanBit JAVA = bit(LuanElement.JAVA);
124
125 public LuanException exception(Object msg) {
126 return JAVA.exception(msg);
127 }
128
129 public Object call(LuanFunction fn) throws LuanException {
130 return call(fn,null,LuanFunction.NOTHING);
131 }
132
133 public Object call(LuanFunction fn,String fnName) throws LuanException {
134 return call(fn,fnName,LuanFunction.NOTHING);
135 }
136
137 public Object call(LuanFunction fn,Object[] args) throws LuanException {
138 return call(fn,null,args);
139 }
140
141 public Object call(LuanFunction fn,String fnName,Object[] args) throws LuanException {
142 return JAVA.call(fn,fnName,args);
143 }
144
145 public LuanFunction checkFunction(Object obj) throws LuanException {
146 return JAVA.checkFunction(obj);
147 }
148
149 public String toString(Object obj) throws LuanException {
150 return JAVA.toString(obj);
151 }
152
153 public String repr(Object obj) throws LuanException {
154 return JAVA.repr(obj);
155 }
156
157 public boolean isLessThan(Object o1,Object o2) throws LuanException {
158 return JAVA.isLessThan(o1,o2);
159 }
159 } 160 }