#include "catchup.h"
#include "init.h"
#include "match.h"
+#include "program_runtime.h"
+#include "rose.h"
+#include "rose_common.h"
#include "nfa/nfa_api.h"
#include "nfa/nfa_internal.h"
#include "nfa/nfa_rev_api.h"
#include "nfa/mcclellan.h"
#include "util/fatbit.h"
-#include "rose.h"
-#include "rose_common.h"
static rose_inline
void runAnchoredTableBlock(const struct RoseEngine *t, const void *atable,
init_outfixes_for_block(t, scratch, state, is_small_block);
}
+static rose_inline
+void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
+ struct hs_scratch *scratch) {
+ assert(t->requiresEodCheck);
+ assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
+ || offset <= t->maxBiAnchoredWidth);
+
+ assert(!can_stop_matching(scratch));
+ assert(t->eodProgramOffset);
+
+ // Ensure that history is correct before we look for EOD matches.
+ roseFlushLastByteHistory(t, scratch, offset);
+ scratch->tctxt.lastEndOffset = offset;
+
+ DEBUG_PRINTF("running eod program at %u\n", t->eodProgramOffset);
+
+ // There should be no pending delayed literals.
+ assert(!scratch->tctxt.filledDelayedSlots);
+
+ const u64a som = 0;
+ const size_t match_len = 0;
+ const char in_anchored = 0;
+ const char in_catchup = 0;
+ const char from_mpv = 0;
+ const char skip_mpv_catchup = 1;
+
+ // Note: we ignore the result, as this is the last thing to ever happen on
+ // a scan.
+ roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
+ in_anchored, in_catchup, from_mpv, skip_mpv_catchup);
+}
+
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch) {
assert(t);
assert(scratch);
assert(!can_stop_matching(scratch));
roseCatchUpTo(t, scratch, length);
+
+ if (!t->requiresEodCheck || !t->eodProgramOffset) {
+ DEBUG_PRINTF("no eod check required\n");
+ return;
+ }
+
+ if (can_stop_matching(scratch)) {
+ DEBUG_PRINTF("bailing, already halted\n");
+ return;
+ }
+
+ roseBlockEodExec(t, length, scratch);
}
initContext(t, offset, scratch);
roseEodExec_i(t, offset, scratch, 1);
}
-
-static rose_inline
-void prepForEod(const struct RoseEngine *t, struct hs_scratch *scratch,
- size_t length) {
- roseFlushLastByteHistory(t, scratch, length);
- scratch->tctxt.lastEndOffset = length;
-}
-
-void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
- struct hs_scratch *scratch) {
- assert(t->requiresEodCheck);
- assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
- || offset <= t->maxBiAnchoredWidth);
-
- assert(!can_stop_matching(scratch));
-
- // Ensure that history is correct before we look for EOD matches
- prepForEod(t, scratch, scratch->core_info.len);
- roseEodExec_i(t, offset, scratch, 0);
-}
// Initialise state space for engine use.
void roseInitState(const struct RoseEngine *t, char *state);
-void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
- struct hs_scratch *scratch);
void roseBlockExec_i(const struct RoseEngine *t, struct hs_scratch *scratch);
/* assumes core_info in scratch has been init to point to data */
// If this block is shorter than our minimum width, then no pattern in this
// RoseEngine could match.
/* minWidth checks should have already been performed by the caller */
- const size_t length = scratch->core_info.len;
- assert(length >= t->minWidth);
+ assert(scratch->core_info.len >= t->minWidth);
// Similarly, we may have a maximum width (for engines constructed entirely
// of bi-anchored patterns).
/* This check is now handled by the interpreter */
assert(t->maxBiAnchoredWidth == ROSE_BOUND_INF
- || length <= t->maxBiAnchoredWidth);
+ || scratch->core_info.len <= t->maxBiAnchoredWidth);
roseBlockExec_i(t, scratch);
-
- if (!t->requiresEodCheck) {
- DEBUG_PRINTF("no eod check required\n");
- return;
- }
-
- if (can_stop_matching(scratch)) {
- DEBUG_PRINTF("bailing, already halted\n");
- return;
- }
-
- roseBlockEodExec(t, length, scratch);
}
/* assumes core_info in scratch has been init to point to data */