package de.dhbwstuttgart.bytecode;

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

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

public class IfStatement extends AStatement{
	
	private Statement then_block;
    private Statement else_block;
    
	public IfStatement(Expression expr, Statement then_block, Statement else_block) {
		super(expr);
		this.then_block = then_block;
		this.else_block = else_block;
	}
	
	@Override
	public void genBCForRelOp(MethodVisitor mv,Label branchLabel, Label endLabel, BytecodeGenMethod bytecodeGenMethod) {
		bytecodeGenMethod.isBinary(false);
		this.then_block.accept(bytecodeGenMethod);
		
		mv.visitLabel(branchLabel);
		this.else_block.accept(bytecodeGenMethod);
	}
}
