comparison core/src/luan/impl/LuanImpl.java @ 670:58ebfec6178b

all luan now compiles
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Apr 2016 01:05:57 -0600
parents 71f8f5075df8
children d3e5414bdf4c
comparison
equal deleted inserted replaced
669:e320488819b6 670:58ebfec6178b
12 12
13 13
14 public final class LuanImpl { 14 public final class LuanImpl {
15 private LuanImpl() {} // never 15 private LuanImpl() {} // never
16 16
17 17 /*
18 private static List list = new ArrayList(); 18 private static List list = new ArrayList();
19 19
20 static int addObj(Object obj) { 20 static int addObj(Object obj) {
21 int i = list.size(); 21 int i = list.size();
22 list.add(obj); 22 list.add(obj);
24 } 24 }
25 25
26 public static Object getObj(int i) { 26 public static Object getObj(int i) {
27 return list.get(i); 27 return list.get(i);
28 } 28 }
29 29 */
30 30
31 public static int len(LuanState luan,Object o) throws LuanException { 31 public static int len(LuanState luan,Object o) throws LuanException {
32 if( o instanceof String ) { 32 if( o instanceof String ) {
33 String s = (String)o; 33 String s = (String)o;
34 return s.length(); 34 return s.length();
168 return !(o == null || Boolean.FALSE.equals(o)); 168 return !(o == null || Boolean.FALSE.equals(o));
169 } 169 }
170 170
171 public static void nop(Object o) {} 171 public static void nop(Object o) {}
172 172
173 173 /*
174 public static void set(LuanStateImpl luan,Settable[] vars,Object obj) throws LuanException { 174 public static void set(LuanStateImpl luan,Settable[] vars,Object obj) throws LuanException {
175 if( obj instanceof Object[] ) { 175 if( obj instanceof Object[] ) {
176 Object[] vals = (Object[])obj; 176 Object[] vals = (Object[])obj;
177 for( int i=0; i<vars.length; i++ ) { 177 for( int i=0; i<vars.length; i++ ) {
178 Object val = i < vals.length ? vals[i] : null; 178 Object val = i < vals.length ? vals[i] : null;
183 for( int i=1; i<vars.length; i++ ) { 183 for( int i=1; i<vars.length; i++ ) {
184 vars[i].set(luan,null); 184 vars[i].set(luan,null);
185 } 185 }
186 } 186 }
187 } 187 }
188 188 */
189 public static void put(LuanState luan,Object t,Object key,Object value) throws LuanException { 189 public static void put(LuanState luan,Object t,Object key,Object value) throws LuanException {
190 if( t instanceof LuanTable ) { 190 if( t instanceof LuanTable ) {
191 LuanTable tbl = (LuanTable)t; 191 LuanTable tbl = (LuanTable)t;
192 tbl.put(luan,key,value); 192 tbl.put(luan,key,value);
193 return; 193 return;
203 throw new RuntimeException(); 203 throw new RuntimeException();
204 if( !(o instanceof Object[]) ) 204 if( !(o instanceof Object[]) )
205 return null; 205 return null;
206 Object[] a = (Object[])o; 206 Object[] a = (Object[])o;
207 return i<a.length ? a[i] : null; 207 return i<a.length ? a[i] : null;
208 }
209
210 public static Object[] varArgs(Object o,int i) {
211 if( !(o instanceof Object[]) )
212 return i==0 ? new Object[]{o} : LuanFunction.NOTHING;
213 Object[] a = (Object[])o;
214 if( i >= a.length )
215 return LuanFunction.NOTHING;
216 Object[] rtn = new Object[a.length - i];
217 System.arraycopy(a,i,rtn,0,rtn.length);
218 return rtn;
208 } 219 }
209 220
210 public static Object[] concatArgs(Object o1,Object o2) { 221 public static Object[] concatArgs(Object o1,Object o2) {
211 if( o1 instanceof Object[] ) { 222 if( o1 instanceof Object[] ) {
212 Object[] a1 = (Object[])o1; 223 Object[] a1 = (Object[])o1;