Exemple #1
0
/** \brief Replace the graph's reports with new reports that specify bounds. */
static
void updateReportBounds(ReportManager &rm, NGWrapper &g, NFAVertex accept,
                        set<NFAVertex> &done) {
    for (auto v : inv_adjacent_vertices_range(accept, g)) {
        // Don't operate on g.accept itself.
        if (v == g.accept) {
            assert(accept == g.acceptEod);
            continue;
        }

        // Don't operate on a vertex we've already done.
        if (contains(done, v)) {
            continue;
        }
        done.insert(v);

        flat_set<ReportID> new_reports;
        auto &reports = g[v].reports;

        for (auto id : reports) {
            Report ir = rm.getReport(id); // make a copy
            assert(!ir.hasBounds());

            // Note that we need to cope with offset adjustment here.

            ir.minOffset = g.min_offset - ir.offsetAdjust;
            if (g.max_offset == MAX_OFFSET) {
                ir.maxOffset = MAX_OFFSET;
            } else {
                ir.maxOffset = g.max_offset - ir.offsetAdjust;
            }
            assert(ir.maxOffset >= ir.minOffset);

            ir.minLength = g.min_length;
            if (g.min_length && !g.som) {
                ir.quashSom = true;
            }

            DEBUG_PRINTF("id %u -> min_offset=%llu, max_offset=%llu, "
                         "min_length=%llu\n",
                         id, ir.minOffset, ir.maxOffset, ir.minLength);
            new_reports.insert(rm.getInternalId(ir));
        }

        DEBUG_PRINTF("swapping reports on vertex %u\n",
                     g[v].index);
        reports.swap(new_reports);
    }
}