Mercurial Hosting > luan
comparison core/src/luan/modules/BasicLuan.java @ 589:97c8ae330efe
add varargs to Luan.try;
add Io.output_to and Io.output_of;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 26 Aug 2015 04:38:37 -0600 |
parents | 0742ac78fa69 |
children | 53a50c70c5e2 |
comparison
equal
deleted
inserted
replaced
588:5fdbefa80146 | 589:97c8ae330efe |
---|---|
188 | 188 |
189 private LuanFunction fn(Object obj) { | 189 private LuanFunction fn(Object obj) { |
190 return obj instanceof LuanFunction ? (LuanFunction)obj : null; | 190 return obj instanceof LuanFunction ? (LuanFunction)obj : null; |
191 } | 191 } |
192 | 192 |
193 public static Object try_(LuanState luan,LuanTable blocks) throws LuanException { | 193 public static Object try_(LuanState luan,LuanTable blocks,Object... args) throws LuanException { |
194 Utils.checkNotNull(luan,blocks); | 194 Utils.checkNotNull(luan,blocks); |
195 Object obj = blocks.get(luan,1); | 195 Object obj = blocks.get(luan,1); |
196 if( obj == null ) | 196 if( obj == null ) |
197 throw new LuanException(luan,"missing 'try' value"); | 197 throw new LuanException(luan,"missing 'try' value"); |
198 if( !(obj instanceof LuanFunction) ) | 198 if( !(obj instanceof LuanFunction) ) |
211 if( !(obj instanceof LuanFunction) ) | 211 if( !(obj instanceof LuanFunction) ) |
212 throw new LuanException(luan,"bad 'finally' value (function expected, got "+Luan.type(obj)+")"); | 212 throw new LuanException(luan,"bad 'finally' value (function expected, got "+Luan.type(obj)+")"); |
213 finallyFn = (LuanFunction)obj; | 213 finallyFn = (LuanFunction)obj; |
214 } | 214 } |
215 try { | 215 try { |
216 return tryFn.call(luan); | 216 return tryFn.call(luan,args); |
217 } catch(LuanException e) { | 217 } catch(LuanException e) { |
218 if( catchFn == null ) | 218 if( catchFn == null ) |
219 throw e; | 219 throw e; |
220 return catchFn.call(luan,new Object[]{e.table()}); | 220 return catchFn.call(luan,new Object[]{e.table()}); |
221 } finally { | 221 } finally { |