view core/src/luan/impl/ConcatExpr.java @ 576:4723d22062ce

remove LuanBit
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Jul 2015 20:38:26 -0600
parents f1601a4ce1aa
children 859c0dedc8b6
line wrap: on
line source

package luan.impl;

import luan.Luan;
import luan.LuanFunction;
import luan.LuanException;
import luan.LuanElement;


final class ConcatExpr extends BinaryOpExpr {

	ConcatExpr(LuanElement el,Expr op1,Expr op2) {
		super(el,op1,op2);
	}

	@Override public Object eval(LuanStateImpl luan) throws LuanException {
		Object o1 = op1.eval(luan);
		Object o2 = op2.eval(luan);
		luan.push(el,null);
		try {
			LuanFunction fn = luan.getBinHandler("__concat",o1,o2);
			if( fn != null )
				return Luan.first(fn.call(luan,new Object[]{o1,o2}));
		} finally {
			luan.pop();
		}
		String s1 = luan.toString(o1,op1.el());
		String s2 = luan.toString(o2,op2.el());
		return s1 + s2;
	}
}