diff core/src/luan/impl/ConcatExpr.java @ 171:3dcb0f9bee82

add core component git-svn-id: https://luan-java.googlecode.com/svn/trunk@172 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 22 Jun 2014 05:41:22 +0000
parents src/luan/impl/ConcatExpr.java@4eaee12f6c65
children 0d6098a29b3e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/luan/impl/ConcatExpr.java	Sun Jun 22 05:41:22 2014 +0000
@@ -0,0 +1,31 @@
+package luan.impl;
+
+import luan.Luan;
+import luan.LuanFunction;
+import luan.LuanException;
+import luan.LuanSource;
+
+
+final class ConcatExpr extends BinaryOpExpr {
+
+	ConcatExpr(LuanSource.Element se,Expr op1,Expr op2) {
+		super(se,op1,op2);
+	}
+
+	@Override public Object eval(LuanStateImpl luan) throws LuanException {
+		Object o1 = op1.eval(luan);
+		Object o2 = op2.eval(luan);
+		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;
+	}
+}