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 LoopStmt extends AStatement {
	
    private Statement loopBlock;
    
    public LoopStmt(Expression expr, Statement loopBlock) {
    		super(expr);
    		this.loopBlock = loopBlock;
    }

	@Override
	public void genBCForRelOp(MethodVisitor mv,Label branchLabel, Label endLabel, BytecodeGenMethod bytecodeGenMethod) {
		bytecodeGenMethod.isBinary(false);
		this.loopBlock.accept(bytecodeGenMethod);
		mv.visitJumpInsn(Opcodes.GOTO, endLabel);
		mv.visitLabel(branchLabel);
	}
}
