comparison src/luan/interp/ConcatExpr.java @ 58:d6c454b7f58c

make concat work with any type; improve JavaLib.getMembers(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@59 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 07 Jan 2013 00:18:35 +0000
parents 8ede219cd111
children 6ca02b188dba
comparison
equal deleted inserted replaced
57:19ca9c4c6c7f 58:d6c454b7f58c
13 } 13 }
14 14
15 @Override public Object eval(LuanStateImpl luan) throws LuanException { 15 @Override public Object eval(LuanStateImpl luan) throws LuanException {
16 Object o1 = op1.eval(luan); 16 Object o1 = op1.eval(luan);
17 Object o2 = op2.eval(luan); 17 Object o2 = op2.eval(luan);
18 String s1 = Luan.asString(o1); 18 String s1 = luan.toString(op1.se(),o1);
19 String s2 = Luan.asString(o2); 19 String s2 = luan.toString(op2.se(),o2);
20 /*
20 if( s1 != null && s2 != null ) 21 if( s1 != null && s2 != null )
21 return s1 + s2; 22 return s1 + s2;
22 LuanFunction fn = luan.getBinHandler(se,"__concat",o1,o2); 23 LuanFunction fn = luan.getBinHandler(se,"__concat",o1,o2);
23 if( fn != null ) 24 if( fn != null )
24 return Luan.first(luan.call(fn,se,"__concat",o1,o2)); 25 return Luan.first(luan.call(fn,se,"__concat",o1,o2));
25 String type = s1==null ? Luan.type(o1) : Luan.type(o2); 26 String type = s1==null ? Luan.type(o1) : Luan.type(o2);
26 throw new LuanException( luan, se, "attempt to concatenate a " + type + " value" ); 27 throw new LuanException( luan, se, "attempt to concatenate a " + type + " value" );
28 */
29 return s1 + s2;
27 } 30 }
28 } 31 }