Mercurial Hosting > luan
comparison core/src/luan/LuanState.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 | 92c3d22745b8 |
children | 8dcf9e12446b |
comparison
equal
deleted
inserted
replaced
508:9218f9cf45d3 | 509:e3b0846dc2ef |
---|---|
43 public final Object eval(String cmd,LuanTable env) throws LuanException { | 43 public final Object eval(String cmd,LuanTable env) throws LuanException { |
44 LuanFunction fn = BasicLuan.load(this,cmd,"eval",env,true); | 44 LuanFunction fn = BasicLuan.load(this,cmd,"eval",env,true); |
45 return call(fn); | 45 return call(fn); |
46 } | 46 } |
47 | 47 |
48 public String toString(Object obj) throws LuanException { | |
49 if( obj instanceof LuanTable ) { | |
50 LuanTable tbl = (LuanTable)obj; | |
51 return tbl.toString(this); | |
52 } | |
53 if( obj == null ) | |
54 return "nil"; | |
55 if( obj instanceof Number ) | |
56 return Luan.toString((Number)obj); | |
57 if( obj instanceof byte[] ) | |
58 return "binary: " + Integer.toHexString(obj.hashCode()); | |
59 return obj.toString(); | |
60 } | |
61 | |
48 public final LuanBit bit(LuanElement el) { | 62 public final LuanBit bit(LuanElement el) { |
49 return new LuanBit(this,el); | 63 return new LuanBit(this,el); |
50 } | 64 } |
51 | 65 |
52 // convenience methods | 66 // convenience methods |
83 | 97 |
84 public LuanFunction checkFunction(Object obj) throws LuanException { | 98 public LuanFunction checkFunction(Object obj) throws LuanException { |
85 return JAVA.checkFunction(obj); | 99 return JAVA.checkFunction(obj); |
86 } | 100 } |
87 | 101 |
88 public String toString(Object obj) throws LuanException { | |
89 return JAVA.toString(obj); | |
90 } | |
91 | |
92 public boolean isLessThan(Object o1,Object o2) throws LuanException { | 102 public boolean isLessThan(Object o1,Object o2) throws LuanException { |
93 return JAVA.isLessThan(o1,o2); | 103 return JAVA.isLessThan(o1,o2); |
94 } | 104 } |
95 } | 105 } |