mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose_build_anchored: clean up remapping
Note that there are no EOD reports in the anchored matcher raw_dfas.
This commit is contained in:
parent
210246af01
commit
a427a2843b
@ -173,45 +173,34 @@ void mergeAnchoredDfas(vector<unique_ptr<raw_dfa>> &dfas,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void translateReportSet(flat_set<ReportID> *rset, const RoseBuildImpl &tbi) {
|
void remapAnchoredReports(raw_dfa &rdfa, const RoseBuildImpl &build) {
|
||||||
flat_set<ReportID> old;
|
for (dstate &ds : rdfa.states) {
|
||||||
old.swap(*rset);
|
assert(ds.reports_eod.empty()); // Not used in anchored matcher.
|
||||||
for (auto report_id : old) {
|
if (ds.reports.empty()) {
|
||||||
DEBUG_PRINTF("updating %u -> %u\n", report_id,
|
continue;
|
||||||
tbi.literal_info[report_id].final_id);
|
|
||||||
rset->insert(tbi.literal_info[report_id].final_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
void remapAnchoredReports(raw_dfa &dfa, const RoseBuildImpl &tbi) {
|
|
||||||
for (dstate &ds : dfa.states) {
|
|
||||||
translateReportSet(&ds.reports, tbi);
|
|
||||||
translateReportSet(&ds.reports_eod, tbi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Replaces the report ids currently in the dfas (rose graph literal ids) with
|
|
||||||
* the final id used by the runtime. */
|
|
||||||
static
|
|
||||||
void remapAnchoredReports(RoseBuildImpl &tbi) {
|
|
||||||
for (auto it = tbi.anchored_nfas.begin(); it != tbi.anchored_nfas.end();
|
|
||||||
++it) {
|
|
||||||
for (auto &rdfa : it->second) {
|
|
||||||
assert(rdfa);
|
|
||||||
remapAnchoredReports(*rdfa, tbi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void remapIds(flat_set<ReportID> &reports, const vector<u32> &litPrograms) {
|
|
||||||
flat_set<ReportID> new_reports;
|
flat_set<ReportID> new_reports;
|
||||||
for (auto id : reports) {
|
for (auto id : ds.reports) {
|
||||||
assert(id < litPrograms.size());
|
assert(id < build.literal_info.size());
|
||||||
new_reports.insert(litPrograms.at(id));
|
new_reports.insert(build.literal_info.at(id).final_id);
|
||||||
|
}
|
||||||
|
ds.reports = move(new_reports);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Replaces the report ids currently in the dfas (rose graph literal
|
||||||
|
* ids) with the final id for each literal.
|
||||||
|
*/
|
||||||
|
static
|
||||||
|
void remapAnchoredReports(RoseBuildImpl &build) {
|
||||||
|
for (auto &m : build.anchored_nfas) {
|
||||||
|
for (auto &rdfa : m.second) {
|
||||||
|
assert(rdfa);
|
||||||
|
remapAnchoredReports(*rdfa, build);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reports = move(new_reports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,8 +210,17 @@ void remapIds(flat_set<ReportID> &reports, const vector<u32> &litPrograms) {
|
|||||||
static
|
static
|
||||||
void remapIdsToPrograms(raw_dfa &rdfa, const vector<u32> &litPrograms) {
|
void remapIdsToPrograms(raw_dfa &rdfa, const vector<u32> &litPrograms) {
|
||||||
for (dstate &ds : rdfa.states) {
|
for (dstate &ds : rdfa.states) {
|
||||||
remapIds(ds.reports, litPrograms);
|
assert(ds.reports_eod.empty()); // Not used in anchored matcher.
|
||||||
remapIds(ds.reports_eod, litPrograms);
|
if (ds.reports.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
flat_set<ReportID> new_reports;
|
||||||
|
for (auto id : ds.reports) {
|
||||||
|
assert(id < litPrograms.size());
|
||||||
|
new_reports.insert(litPrograms.at(id));
|
||||||
|
}
|
||||||
|
ds.reports = move(new_reports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user