Mercurial Hosting > luan
comparison core/src/luan/LuanBit.java @ 575:7c3ad6db8ac3
make LuanState.JAVA private
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 13 Jul 2015 18:34:31 -0600 |
parents | 6cc2f047019b |
children |
comparison
equal
deleted
inserted
replaced
574:6cc2f047019b | 575:7c3ad6db8ac3 |
---|---|
39 } finally { | 39 } finally { |
40 pop(); | 40 pop(); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 public void push(String fnName) { | 44 private void push(String fnName) { |
45 if( el == null ) throw new RuntimeException(); | 45 if( el == null ) throw new RuntimeException(); |
46 List<StackTraceElement> stackTrace = luan.stackTrace; | 46 List<StackTraceElement> stackTrace = luan.stackTrace; |
47 stackTrace.add( new StackTraceElement(el,fnName) ); | 47 stackTrace.add( new StackTraceElement(el,fnName) ); |
48 } | 48 } |
49 | 49 |
50 public void pop() { | 50 private void pop() { |
51 List<StackTraceElement> stackTrace = luan.stackTrace; | 51 List<StackTraceElement> stackTrace = luan.stackTrace; |
52 stackTrace.remove(stackTrace.size()-1); | 52 stackTrace.remove(stackTrace.size()-1); |
53 } | |
54 | |
55 public String toString(Object obj) throws LuanException { | |
56 push(null); | |
57 try { | |
58 return luan.toString(obj); | |
59 } finally { | |
60 pop(); | |
61 } | |
62 } | |
63 | |
64 public Object index(Object obj,Object key) throws LuanException { | |
65 push(null); | |
66 try { | |
67 return luan.index(obj,key); | |
68 } finally { | |
69 pop(); | |
70 } | |
71 } | |
72 | |
73 public int length(LuanTable t) throws LuanException { | |
74 push(null); | |
75 try { | |
76 return t.length(luan); | |
77 } finally { | |
78 pop(); | |
79 } | |
80 } | |
81 | |
82 public void put(LuanTable t,Object key,Object value) throws LuanException { | |
83 push(null); | |
84 try { | |
85 t.put(luan,key,value); | |
86 } finally { | |
87 pop(); | |
88 } | |
53 } | 89 } |
54 | 90 |
55 public String checkString(Object obj) throws LuanException { | 91 public String checkString(Object obj) throws LuanException { |
56 if( obj instanceof String ) | 92 if( obj instanceof String ) |
57 return (String)obj; | 93 return (String)obj; |
131 return Luan.first(call(fn,op,new Object[]{o1,o2})); | 167 return Luan.first(call(fn,op,new Object[]{o1,o2})); |
132 String type = !(o1 instanceof Number) ? Luan.type(o1) : Luan.type(o2); | 168 String type = !(o1 instanceof Number) ? Luan.type(o1) : Luan.type(o2); |
133 throw exception("attempt to perform arithmetic on a "+type+" value"); | 169 throw exception("attempt to perform arithmetic on a "+type+" value"); |
134 } | 170 } |
135 | 171 |
136 public String toString(Object obj) throws LuanException { | |
137 if( obj instanceof LuanTable ) { | |
138 LuanTable tbl = (LuanTable)obj; | |
139 return tbl.toString(this); | |
140 } | |
141 if( obj == null ) | |
142 return "nil"; | |
143 if( obj instanceof Number ) | |
144 return Luan.toString((Number)obj); | |
145 if( obj instanceof byte[] ) | |
146 return "binary: " + Integer.toHexString(obj.hashCode()); | |
147 return obj.toString(); | |
148 } | |
149 | |
150 } | 172 } |