Mercurial Hosting > luan
comparison src/luan/LuanState.java @ 66:f7e17cfb35f9
minor toString() improvement
git-svn-id: https://luan-java.googlecode.com/svn/trunk@67 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 22 Jan 2013 00:00:27 +0000 |
parents | 5c9cadd0acce |
children | f86e4f77ef32 |
comparison
equal
deleted
inserted
replaced
65:1ff53a88579a | 66:f7e17cfb35f9 |
---|---|
93 | 93 |
94 public final String toString(LuanElement el,Object obj) throws LuanException { | 94 public final String toString(LuanElement el,Object obj) throws LuanException { |
95 LuanFunction fn = getHandlerFunction(el,"__tostring",obj); | 95 LuanFunction fn = getHandlerFunction(el,"__tostring",obj); |
96 if( fn != null ) | 96 if( fn != null ) |
97 return checkString( el, Luan.first( call(fn,el,"__tostring",obj) ) ); | 97 return checkString( el, Luan.first( call(fn,el,"__tostring",obj) ) ); |
98 if( obj == null ) | 98 return Luan.toString(obj); |
99 return "nil"; | |
100 if( obj instanceof Number ) | |
101 return Luan.toString((Number)obj); | |
102 if( obj instanceof LuanException ) { | |
103 LuanException le = (LuanException)obj; | |
104 return le.getMessage(); | |
105 } | |
106 return obj.toString(); | |
107 } | 99 } |
108 | 100 |
109 public final LuanFunction getHandlerFunction(LuanElement el,String op,Object obj) throws LuanException { | 101 public final LuanFunction getHandlerFunction(LuanElement el,String op,Object obj) throws LuanException { |
110 Object f = getHandler(op,obj); | 102 Object f = getHandler(op,obj); |
111 if( f == null ) | 103 if( f == null ) |