Mercurial Hosting > luan
comparison core/src/luan/impl/LuanStateImpl.java @ 645:859c0dedc8b6
remove LuanSource
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2016 18:09:51 -0600 |
parents | f22a09e98b04 |
children | cdc70de628b5 |
comparison
equal
deleted
inserted
replaced
644:ba1e318377c5 | 645:859c0dedc8b6 |
---|---|
7 import luan.Luan; | 7 import luan.Luan; |
8 import luan.LuanState; | 8 import luan.LuanState; |
9 import luan.LuanTable; | 9 import luan.LuanTable; |
10 import luan.LuanFunction; | 10 import luan.LuanFunction; |
11 import luan.LuanException; | 11 import luan.LuanException; |
12 import luan.LuanElement; | |
13 import luan.LuanSource; | |
14 import luan.DeepCloner; | 12 import luan.DeepCloner; |
15 import luan.StackTraceElement; | |
16 | 13 |
17 | 14 |
18 final class LuanStateImpl extends LuanState { | 15 final class LuanStateImpl extends LuanState { |
19 | 16 |
20 private static class Frame { | 17 private static class Frame { |
117 | 114 |
118 @Override public void setJava() { | 115 @Override public void setJava() { |
119 ((LuanTable)frame.closure.upValues()[0].get()).hasJava = true; | 116 ((LuanTable)frame.closure.upValues()[0].get()).hasJava = true; |
120 } | 117 } |
121 | 118 |
122 @Override public LuanSource currentSource(){ | |
123 if( frame==null ) | |
124 return null; | |
125 return frame.closure.fnDef.el().source; | |
126 } | |
127 | |
128 | 119 |
129 | 120 |
130 @Override public boolean isLessThan(Object o1,Object o2) throws LuanException { | 121 @Override public boolean isLessThan(Object o1,Object o2) throws LuanException { |
131 if( o1 instanceof Number && o2 instanceof Number ) { | 122 if( o1 instanceof Number && o2 instanceof Number ) { |
132 Number n1 = (Number)o1; | 123 Number n1 = (Number)o1; |
158 if( f == null ) | 149 if( f == null ) |
159 return null; | 150 return null; |
160 return checkFunction(f); | 151 return checkFunction(f); |
161 } | 152 } |
162 | 153 |
163 Boolean checkBoolean(Object obj,LuanElement el) throws LuanException { | |
164 push(el,null); | |
165 try { | |
166 return checkBoolean(obj); | |
167 } finally { | |
168 pop(); | |
169 } | |
170 } | |
171 | |
172 String toString(Object obj,LuanElement el) throws LuanException { | |
173 push(el,null); | |
174 try { | |
175 return toString(obj); | |
176 } finally { | |
177 pop(); | |
178 } | |
179 } | |
180 | |
181 void push(LuanElement el,String fnName) { | |
182 if( el == null ) throw new RuntimeException(); | |
183 stackTrace.add( new StackTraceElement(el,fnName) ); | |
184 } | |
185 | |
186 void pop() { | |
187 stackTrace.remove(stackTrace.size()-1); | |
188 } | |
189 | |
190 } | 154 } |