comparison core/src/luan/LuanTable.java @ 646:cdc70de628b5

simplify LuanException
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Mar 2016 19:58:39 -0600
parents 60c549d43988
children 8e8c30b72e9b
comparison
equal deleted inserted replaced
645:859c0dedc8b6 646:cdc70de628b5
158 if( h instanceof LuanTable ) { 158 if( h instanceof LuanTable ) {
159 LuanTable tbl = (LuanTable)h; 159 LuanTable tbl = (LuanTable)h;
160 tbl.put(luan,key,value); 160 tbl.put(luan,key,value);
161 return; 161 return;
162 } 162 }
163 throw new LuanException(luan,"invalid type "+Luan.type(h)+" for metamethod __new_index"); 163 throw new LuanException("invalid type "+Luan.type(h)+" for metamethod __new_index");
164 } 164 }
165 165
166 public void rawPut(Object key,Object val) { 166 public void rawPut(Object key,Object val) {
167 Integer iT = Luan.asInteger(key); 167 Integer iT = Luan.asInteger(key);
168 if( iT != null ) { 168 if( iT != null ) {
317 if( h != null ) { 317 if( h != null ) {
318 if( h instanceof LuanFunction ) { 318 if( h instanceof LuanFunction ) {
319 LuanFunction fn = (LuanFunction)h; 319 LuanFunction fn = (LuanFunction)h;
320 Object obj = Luan.first(fn.call(luan,new Object[]{this})); 320 Object obj = Luan.first(fn.call(luan,new Object[]{this}));
321 if( !(obj instanceof LuanFunction) ) 321 if( !(obj instanceof LuanFunction) )
322 throw new LuanException(luan, "metamethod __pairs should return function but returned " + Luan.type(obj) ); 322 throw new LuanException( "metamethod __pairs should return function but returned " + Luan.type(obj) );
323 return (LuanFunction)obj; 323 return (LuanFunction)obj;
324 } 324 }
325 if( h instanceof LuanMeta ) { 325 if( h instanceof LuanMeta ) {
326 LuanMeta meta = (LuanMeta)h; 326 LuanMeta meta = (LuanMeta)h;
327 return meta.__pairs(luan,this); 327 return meta.__pairs(luan,this);
328 } 328 }
329 throw new LuanException(luan, "invalid type of metamethod __pairs: " + Luan.type(h) ); 329 throw new LuanException( "invalid type of metamethod __pairs: " + Luan.type(h) );
330 } 330 }
331 return rawPairs(); 331 return rawPairs();
332 } 332 }
333 333
334 private LuanFunction rawPairs() { 334 private LuanFunction rawPairs() {