comparison core/src/luan/modules/BasicLuan.java @ 574:6cc2f047019b

remove LuanState.call()
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Jul 2015 12:31:53 -0600
parents f1601a4ce1aa
children 7c3ad6db8ac3
comparison
equal deleted inserted replaced
573:894f991baac5 574:6cc2f047019b
202 if( !(obj instanceof LuanFunction) ) 202 if( !(obj instanceof LuanFunction) )
203 throw luan.exception("bad 'finally' value (function expected, got "+Luan.type(obj)+")"); 203 throw luan.exception("bad 'finally' value (function expected, got "+Luan.type(obj)+")");
204 finallyFn = (LuanFunction)obj; 204 finallyFn = (LuanFunction)obj;
205 } 205 }
206 try { 206 try {
207 return luan.call(tryFn); 207 return tryFn.call(luan);
208 } catch(LuanException e) { 208 } catch(LuanException e) {
209 if( catchFn == null ) 209 if( catchFn == null )
210 throw e; 210 throw e;
211 return luan.call(catchFn,new Object[]{e.table()}); 211 return catchFn.call(luan,new Object[]{e.table()});
212 } finally { 212 } finally {
213 if( finallyFn != null ) 213 if( finallyFn != null )
214 luan.call(finallyFn); 214 finallyFn.call(luan);
215 } 215 }
216 } 216 }
217 217
218 @LuanMethod public static Object[] pcall(LuanState luan,LuanFunction f,Object... args) { 218 @LuanMethod public static Object[] pcall(LuanState luan,LuanFunction f,Object... args) {
219 try { 219 try {
220 Object[] r = Luan.array(luan.call(f,args)); 220 Object[] r = Luan.array(f.call(luan,args));
221 Object[] rtn = new Object[r.length+1]; 221 Object[] rtn = new Object[r.length+1];
222 rtn[0] = true; 222 rtn[0] = true;
223 for( int i=0; i<r.length; i++ ) { 223 for( int i=0; i<r.length; i++ ) {
224 rtn[i+1] = r[i]; 224 rtn[i+1] = r[i];
225 } 225 }