package de.dhbwstuttgart.bytecode;

import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr;
import de.dhbwstuttgart.syntaxtree.statement.Expression;

public abstract class AStatement implements IStatement {
	protected Expression expr;
	
	public AStatement(Expression expr) {
		this.expr = expr;
	}
	
	@Override
	public boolean isExprBinary() {
		return (expr instanceof BinaryExpr);
	}
	
	@Override
	public void genBCForRelOp(MethodVisitor mv,Label branchLabel, Label endLabel, BytecodeGenMethod bytecodeGenMethod) {
		mv.visitInsn(Opcodes.ICONST_1);
		mv.visitJumpInsn(Opcodes.GOTO, endLabel);
		mv.visitLabel(branchLabel);
		mv.visitInsn(Opcodes.ICONST_0);
		mv.visitLabel(endLabel);
	}
}
