comparison core/src/luan/impl/LenExpr.java @ 432:d9df6d6cb927

finish fixing LuanTable to use metatables
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 02 May 2015 23:41:59 -0600
parents d55e873e1f0d
children b48cfa14ba60
comparison
equal deleted inserted replaced
431:3ffe8ba5b297 432:d9df6d6cb927
26 } 26 }
27 LuanBit bit = luan.bit(se); 27 LuanBit bit = luan.bit(se);
28 if( !(o instanceof LuanTable) ) 28 if( !(o instanceof LuanTable) )
29 throw bit.exception( "attempt to get length of a " + Luan.type(o) + " value" ); 29 throw bit.exception( "attempt to get length of a " + Luan.type(o) + " value" );
30 LuanTable t = (LuanTable)o; 30 LuanTable t = (LuanTable)o;
31 LuanFunction fn = bit.getHandlerFunction("__len",t); 31 return t.length(luan);
32 if( fn != null )
33 return Luan.first(bit.call(fn,"__len",new Object[]{o}));
34 return t.length();
35 } 32 }
36 } 33 }