package railo.transformer.bytecode.statement;

import org.objectweb.asm.Type;
import org.objectweb.asm.commons.GeneratorAdapter;

import railo.transformer.bytecode.BytecodeContext;
import railo.transformer.bytecode.BytecodeException;
import railo.transformer.bytecode.Literal;
import railo.transformer.bytecode.expression.Expression;
import railo.transformer.bytecode.util.ASMUtil;

public final class ExpressionStatement extends StatementBase {

	private Expression expr;

	/**
	 * Constructor of the class
	 * @param expr
	 */
	public ExpressionStatement(Expression expr) {
		super(expr.getLine());
		this.expr=expr;
	}

	/**
	 *
	 * @see railo.transformer.bytecode.statement.StatementBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter)
	 */
	public void _writeOut(BytecodeContext bc) throws BytecodeException {
		GeneratorAdapter adapter = bc.getAdapter();
		if(!(expr instanceof Literal)) {
			Type type = expr.writeOut(bc, Expression.MODE_VALUE);
			ASMUtil.pop(adapter, type);
			//if(type.equals(Types.DOUBLE_VALUE))adapter.pop2();
			//else adapter.pop();
		}
	}
}

@@ -374,16 +374,62 @@
 ASMUtil;
+%0Aimport railo.transformer.bytecode.util.Types;
 %0A%0Apublic
@@ -1001,16 +1001,44 @@
 UE);%0A%09%09%09
+if(!type.equals(Types.VOID))
 ASMUtil.

add support for ExpressionStatment handing Expression returning void