Mercurial Hosting > luan
comparison core/src/luan/modules/BasicLuan.java @ 419:8fbb961aabd5
improve repr() to check metamethod recursively
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 30 Apr 2015 23:15:40 -0600 |
parents | 8937263f59f6 |
children | af82b266fe89 |
comparison
equal
deleted
inserted
replaced
418:455784e2227d | 419:8fbb961aabd5 |
---|---|
48 return luan.call(fn); | 48 return luan.call(fn); |
49 } | 49 } |
50 | 50 |
51 public static LuanFunction pairs(LuanState luan,final LuanTable t) throws LuanException { | 51 public static LuanFunction pairs(LuanState luan,final LuanTable t) throws LuanException { |
52 Utils.checkNotNull(luan,t); | 52 Utils.checkNotNull(luan,t); |
53 Object obj = luan.getHandler("__pairs",t); | 53 Object obj = t.getHandler("__pairs"); |
54 if( obj != null ) { | 54 if( obj != null ) { |
55 if( obj instanceof LuanFunction ) { | 55 if( obj instanceof LuanFunction ) { |
56 obj = Luan.first(luan.call((LuanFunction)obj,"__pairs",new Object[]{t})); | 56 obj = Luan.first(luan.call((LuanFunction)obj,"__pairs",new Object[]{t})); |
57 if( !(obj instanceof LuanFunction) ) | 57 if( !(obj instanceof LuanFunction) ) |
58 throw luan.exception( "metamethod __pairs should return function but returned " + Luan.type(obj) ); | 58 throw luan.exception( "metamethod __pairs should return function but returned " + Luan.type(obj) ); |