<commit_before>/*
 * This file is part of the x0 web server project and is released under AGPL-3.
 * http://www.xzero.io/
 *
 * (c) 2009-2014 <NAME> <<EMAIL>>
 */

#include <x0/flow/ir/IRHandler.h>
#include <x0/flow/ir/BasicBlock.h>
#include <algorithm>
#include <assert.h>

namespace x0 {

using namespace FlowVM;

IRHandler::IRHandler(const std::string& name) :
    Constant(FlowType::Handler, name),
    parent_(nullptr),
    blocks_()
{
}

IRHandler::~IRHandler()
{
    for (BasicBlock* bb: blocks_) {
        delete bb;
    }
}

void IRHandler::dump()<commit_msg>[flow] fixes IR handler's BB destruction procedure<commit_after>/*
 * This file is part of the x0 web server project and is released under AGPL-3.
 * http://www.xzero.io/
 *
 * (c) 2009-2014 <NAME> <<EMAIL>>
 */

#include <x0/flow/ir/IRHandler.h>
#include <x0/flow/ir/BasicBlock.h>
#include <algorithm>
#include <assert.h>

namespace x0 {

using namespace FlowVM;

IRHandler::IRHandler(const std::string& name) :
    Constant(FlowType::Handler, name),
    parent_(nullptr),
    blocks_()
{
}

IRHandler::~IRHandler()
{
    while (!blocks_.empty()) {
        auto i = blocks_.begin();
        auto e = blocks_.end();

        while (i != e) {
            BasicBlock* bb = *i;

            if (bb->predecessors().empty()) {
                delete bb;
                auto k = i;
                ++i;
                blocks_.erase(k);
            } else {
                // skip BBs that other BBs still point to (we never point to ourself).
                ++i;
            }
        }
    }
}

void IRHandler::dump()
{'fraction_non_alphanumeric': 0.14835858585858586, 'fraction_numerical': 0.016414141414141416, 'mean_word_length': 2.372340425531915, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4593635', 'n_tokens_mistral': 548, 'n_tokens_neox': 523, 'n_words': 137}