@Override
    public List<AssemblyLine> generate(Context context)
    {
        final List<AssemblyLine> lines = Lists.newLinkedList();
        
        if (Compiler.debug)
        {
            lines.add(new Comment("Start if"));
        }
        String blockStart = context.getUniqueId("start_if_block");
        String blockEnd = context.getUniqueId("end_if_block");
        String elseBlockStart = null;
        if (children.size() > 2)
        {
            elseBlockStart = context.getUniqueId("start_else_block");
        }
        
        Condition cond = (Condition) children.get(0);
        Block block = (Block) children.get(1);
        
        context.setValue("condInstruction",
                new Instruction(Opcode.SET).first(new RegisterAccess("PC"))
                        .second(new LabelCall(blockStart)));
        lines.addAll(cond.generate(context));
        if (children.size() > 2)
        {
            lines.add(new Instruction(Opcode.SET, new RegisterAccess("PC"),
                    new LabelCall(elseBlockStart)));
        }
        else
        {
            lines.add(new Instruction(Opcode.SET, new RegisterAccess("PC"),
                    new LabelCall(blockEnd)));
        }
        lines.add(new Label(blockStart));
        lines.addAll(block.generate(context));
        if (children.size() > 2)
        {
            AbstractSyntaxNode elseBlock = children.get(2);
            
            lines.add(new Instruction(Opcode.SET).first(
                    new RegisterAccess("PC")).second(new LabelCall(blockEnd)));
            lines.add(new Label(elseBlockStart));
            lines.addAll(elseBlock.generate(context));
            
        }
        lines.add(new Label(blockEnd));
        
        return lines;
    }