mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-12-31 13:49:07 +03:00
limex: rework accept handling
Rather that iterating over NFAAccept structures and testing individual bits in the state structure, iterate over the state vector and index into accept structures. Adds report list support to this path, unified with the report lists used for exception handling.
This commit is contained in:
committed by
Matthew Barr
parent
3dcfea19e0
commit
77fe1ef6e5
@@ -180,26 +180,40 @@ void dumpAccel(const limex_type *limex, FILE *f) {
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void dumpAcceptList(const char *limex_base, const struct NFAAccept *accepts,
|
||||
u32 acceptCount, FILE *f) {
|
||||
for (u32 i = 0; i < acceptCount; i++) {
|
||||
const NFAAccept &a = accepts[i];
|
||||
if (a.single_report) {
|
||||
fprintf(f, " idx %u fires single report %u\n", i, a.reports);
|
||||
continue;
|
||||
}
|
||||
fprintf(f, " idx %u fires report list %u:", i, a.reports);
|
||||
const ReportID *report = (const ReportID *)(limex_base + a.reports);
|
||||
for (; *report != MO_INVALID_IDX; report++) {
|
||||
fprintf(f, " %u", *report);
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename limex_type>
|
||||
static
|
||||
void dumpAccepts(const limex_type *limex, FILE *f) {
|
||||
u32 acceptCount = limex->acceptCount;
|
||||
u32 acceptEodCount = limex->acceptEodCount;
|
||||
const char *limex_base = (const char *)limex;
|
||||
|
||||
const u32 acceptCount = limex->acceptCount;
|
||||
const u32 acceptEodCount = limex->acceptEodCount;
|
||||
|
||||
fprintf(f, "\n%u accepts.\n", acceptCount);
|
||||
const struct NFAAccept *accepts
|
||||
= (const struct NFAAccept *)((const char *)limex + limex->acceptOffset);
|
||||
for (u32 i = 0; i < acceptCount; i++) {
|
||||
fprintf(f, " state %u fires report %u\n", accepts[i].state,
|
||||
accepts[i].externalId);
|
||||
}
|
||||
const auto *accepts =
|
||||
(const struct NFAAccept *)(limex_base + limex->acceptOffset);
|
||||
dumpAcceptList(limex_base, accepts, acceptCount, f);
|
||||
fprintf(f, "\n%u accepts at EOD.\n", acceptEodCount);
|
||||
accepts = (const struct NFAAccept *)((const char *)limex
|
||||
+ limex->acceptEodOffset);
|
||||
for (u32 i = 0; i < acceptEodCount; i++) {
|
||||
fprintf(f, " state %u fires report %u\n", accepts[i].state,
|
||||
accepts[i].externalId);
|
||||
}
|
||||
const auto *accepts_eod =
|
||||
(const struct NFAAccept *)(limex_base + limex->acceptEodOffset);
|
||||
dumpAcceptList(limex_base, accepts_eod, acceptEodCount, f);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
@@ -226,20 +240,15 @@ getExceptionTable(const limex_type *limex) {
|
||||
((const char *)limex + limex->exceptionOffset);
|
||||
}
|
||||
|
||||
template<typename limex_type>
|
||||
static
|
||||
const ReportID *getReportList(const limex_type *limex) {
|
||||
return (const ReportID *)((const char *)limex + limex->exReportOffset);
|
||||
}
|
||||
|
||||
template<typename limex_type>
|
||||
static
|
||||
void dumpLimexExceptions(const limex_type *limex, FILE *f) {
|
||||
const typename limex_traits<limex_type>::exception_type *e =
|
||||
getExceptionTable(limex);
|
||||
const ReportID *reports = getReportList(limex);
|
||||
const u32 size = limex_traits<limex_type>::size;
|
||||
|
||||
const char *limex_base = (const char *)limex;
|
||||
|
||||
fprintf(f, "\n");
|
||||
for (u32 i = 0; i < limex->exceptionCount; i++) {
|
||||
fprintf(f, "exception %u: hasSquash=%u, reports offset=%u\n",
|
||||
@@ -255,7 +264,7 @@ void dumpLimexExceptions(const limex_type *limex, FILE *f) {
|
||||
if (e[i].reports == MO_INVALID_IDX) {
|
||||
fprintf(f, " <none>\n");
|
||||
} else {
|
||||
const ReportID *r = reports + e[i].reports;
|
||||
const ReportID *r = (const ReportID *)(limex_base + e[i].reports);
|
||||
while (*r != MO_INVALID_IDX) {
|
||||
fprintf(f, " %u", *r++);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user