comparison src/luan/LuanBit.java @ 151:c9100f29fae0

conditions must be type boolean git-svn-id: https://luan-java.googlecode.com/svn/trunk@152 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 16 Jun 2014 10:37:06 +0000
parents 14281d5bd36f
children
comparison
equal deleted inserted replaced
150:f35c50027985 151:c9100f29fae0
59 if( obj instanceof LuanFunction ) 59 if( obj instanceof LuanFunction )
60 return (LuanFunction)obj; 60 return (LuanFunction)obj;
61 throw exception( "attempt to call a " + Luan.type(obj) + " value" ); 61 throw exception( "attempt to call a " + Luan.type(obj) + " value" );
62 } 62 }
63 63
64 public Boolean checkBoolean(Object obj) throws LuanException {
65 if( obj instanceof Boolean )
66 return (Boolean)obj;
67 throw exception( "attempt to use a " + Luan.type(obj) + " as a boolean" );
68 }
69
64 public String toString(Object obj) throws LuanException { 70 public String toString(Object obj) throws LuanException {
65 LuanFunction fn = getHandlerFunction("__tostring",obj); 71 LuanFunction fn = getHandlerFunction("__tostring",obj);
66 if( fn != null ) 72 if( fn != null )
67 return checkString( Luan.first( call(fn,"__tostring",new Object[]{obj}) ) ); 73 return checkString( Luan.first( call(fn,"__tostring",new Object[]{obj}) ) );
68 return Luan.toString(obj); 74 return Luan.toString(obj);