private void generateIf(IfNode node)
            throws IRException {

        try {
            scopes.enterBlock();

            Operand condition = generate(node.condition);

            Label trueL = new Label();
            Label falseL = new Label();

            code.addStatement(
                    new IfGoToStatement(condition, trueL, falseL)
            );

            trueL.setIndex(code.nextIndex());

            generate(node.block);

            if(node.elseNode != null) {
                Label endOfBlock = new Label();
                code.addStatement(new GoToStatement(endOfBlock));
                falseL.setIndex(code.nextIndex());

                generate(node.elseNode);
                endOfBlock.setIndex(code.nextIndex());
            } else {
                falseL.setIndex(code.nextIndex());
            }

            scopes.leaveBlock();
    //        code.addStatement(new ReturnStatement());
        } catch(IRException ex) {
            throw ex;
        } catch(Exception ex) {
            throw (NonGenerationException)new NonGenerationException(ex)
                    .Log("ru.bmstu.iu9.compiler.ir");
        }
    }