comparison core/src/luan/LuanState.java @ 572:f1601a4ce1aa

fix stack when calling meta-methods
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 12 Jul 2015 21:34:23 -0600
parents ef0336efe33c
children 6cc2f047019b
comparison
equal deleted inserted replaced
571:cd944b010f25 572:f1601a4ce1aa
61 public final Object eval(String cmd,LuanTable env) throws LuanException { 61 public final Object eval(String cmd,LuanTable env) throws LuanException {
62 LuanFunction fn = BasicLuan.load(this,cmd,"eval",env,true); 62 LuanFunction fn = BasicLuan.load(this,cmd,"eval",env,true);
63 return call(fn); 63 return call(fn);
64 } 64 }
65 65
66 public String toString(Object obj) throws LuanException {
67 if( obj instanceof LuanTable ) {
68 LuanTable tbl = (LuanTable)obj;
69 return tbl.toString(this);
70 }
71 if( obj == null )
72 return "nil";
73 if( obj instanceof Number )
74 return Luan.toString((Number)obj);
75 if( obj instanceof byte[] )
76 return "binary: " + Integer.toHexString(obj.hashCode());
77 return obj.toString();
78 }
79
80 public final LuanBit bit(LuanElement el) { 66 public final LuanBit bit(LuanElement el) {
81 return new LuanBit(this,el); 67 return new LuanBit(this,el);
82 } 68 }
83 69
84 // convenience methods 70 // convenience methods
85 71
86 final LuanBit JAVA = bit(null); 72 public final LuanBit JAVA = bit(null);
87 73
88 public LuanException exception(Object msg) throws LuanException { 74 public LuanException exception(Object msg) throws LuanException {
89 return JAVA.exception(msg); 75 return JAVA.exception(msg);
90 } 76 }
91 77