Mercurial Hosting > luan
comparison core/src/luan/LuanBit.java @ 509:e3b0846dc2ef
throw exception for invalid indexes of string, binary, or java
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 22 May 2015 02:02:49 -0600 |
parents | 5d4a78c93383 |
children | f1601a4ce1aa |
comparison
equal
deleted
inserted
replaced
508:9218f9cf45d3 | 509:e3b0846dc2ef |
---|---|
82 } else { | 82 } else { |
83 throw exception( "attempt to use a " + Luan.type(obj) + " as a boolean" ); | 83 throw exception( "attempt to use a " + Luan.type(obj) + " as a boolean" ); |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 public String toString(Object obj) throws LuanException { | |
88 if( obj instanceof LuanTable ) { | |
89 LuanTable tbl = (LuanTable)obj; | |
90 return tbl.toString(luan); | |
91 } | |
92 if( obj == null ) | |
93 return "nil"; | |
94 if( obj instanceof Number ) | |
95 return Luan.toString((Number)obj); | |
96 if( obj instanceof byte[] ) | |
97 return "binary: " + Integer.toHexString(obj.hashCode()); | |
98 return obj.toString(); | |
99 } | |
100 | |
101 public LuanFunction getHandlerFunction(String op,LuanTable t) throws LuanException { | 87 public LuanFunction getHandlerFunction(String op,LuanTable t) throws LuanException { |
102 Object f = t.getHandler(op); | 88 Object f = t.getHandler(op); |
103 if( f == null ) | 89 if( f == null ) |
104 return null; | 90 return null; |
105 return checkFunction(f); | 91 return checkFunction(f); |