changeset 410:0d6098a29b3e

fix ConcatExpr to use metamethod
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 29 Apr 2015 15:38:15 -0600
parents abce9b0041b0
children 23b99a5039b5
files core/src/luan/impl/ConcatExpr.java
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/impl/ConcatExpr.java	Wed Apr 29 15:26:54 2015 -0600
+++ b/core/src/luan/impl/ConcatExpr.java	Wed Apr 29 15:38:15 2015 -0600
@@ -4,6 +4,7 @@
 import luan.LuanFunction;
 import luan.LuanException;
 import luan.LuanSource;
+import luan.LuanBit;
 
 
 final class ConcatExpr extends BinaryOpExpr {
@@ -15,17 +16,12 @@
 	@Override public Object eval(LuanStateImpl luan) throws LuanException {
 		Object o1 = op1.eval(luan);
 		Object o2 = op2.eval(luan);
+		LuanBit bit = luan.bit(se);
+		LuanFunction fn = bit.getBinHandler("__concat",o1,o2);
+		if( fn != null )
+			return Luan.first(bit.call(fn,"__concat",new Object[]{o1,o2}));
 		String s1 = luan.bit(op1.se()).toString(o1);
 		String s2 = luan.bit(op2.se()).toString(o2);
-/*
-		if( s1 != null && s2 != null )
-			return s1 + s2;
-		LuanFunction fn = luan.getBinHandler(se,"__concat",o1,o2);
-		if( fn != null )
-			return Luan.first(luan.call(fn,se,"__concat",o1,o2));
-		String type = s1==null ? Luan.type(o1) : Luan.type(o2);
-		throw new LuanException( luan, se, "attempt to concatenate a " + type + " value" );
-*/
 		return s1 + s2;
 	}
 }