void init(simctx_t &ctx, const char *string);
int finalize(const simctx_t &ctx, const char *string, size_t nmatch, regmatch_t pmatch[]);
-inline uint32_t index(const nfa_t *, const nfa_state_t *);
int regexec_dfa(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
int regexec_nfa_posix(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
int regexec_nfa_posix_trie(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
return static_cast<int32_t>(nodes.size() - 1);
}
-uint32_t index(const nfa_t *nfa, const nfa_state_t *state)
-{
- return static_cast<uint32_t>(state - nfa->states);
-}
-
bool ran_or_fin_t::operator()(const conf_t &c)
{
switch (c.state->type) {
simctx_t &ctx = *preg->simctx;
init(ctx, string);
+ // root state can be non-core, so we pass zero as origin to avoid checks
const conf_t c0(ctx.nfa->root, 0, history_t::ROOT);
ctx.reach.push_back(c0);
closure_leftmost(ctx);
simctx_t &ctx = *preg->simctx;
init(ctx, string);
- const conf_t c0(ctx.nfa->root, 0, history_t::ROOT);
+ nfa_state_t *s0 = ctx.nfa->root;
+ const conf_t c0(s0, s0->coreid, history_t::ROOT);
ctx.reach.push_back(c0);
closure_leftmost(ctx);
simctx_t &ctx = *preg->simctx;
init(ctx, string);
+ // root state can be non-core, so we pass zero as origin to avoid checks
const conf_t c0(ctx.nfa->root, 0, history_t::ROOT);
ctx.reach.push_back(c0);
closure_posix<ALG>(ctx);
simctx_t &ctx = *preg->simctx;
init(ctx, string);
- const nfa_t *nfa = ctx.nfa;
-
- const conf_t c0(nfa->root, index(nfa, nfa->root), history_t::ROOT);
+ nfa_state_t *s0 = ctx.nfa->root;
+ const conf_t c0(s0, s0->coreid, history_t::ROOT);
ctx.reach.push_back(c0);
closure_posix(ctx);
for (;;) {
void make_step(simctx_t &ctx, uint32_t sym)
{
- const nfa_t *nfa = ctx.nfa;
const confset_t &state = ctx.state;
confset_t &reach = ctx.reach;
cconfiter_t b = state.begin(), e = state.end(), i;
if (s->type == nfa_state_t::RAN) {
for (const Range *r = s->ran.ran; r; r = r->next()) {
if (r->lower() <= sym && sym < r->upper()) {
- const conf_t c(s->ran.out, index(nfa, s), i->thist);
+ const conf_t c(s->ran.out, s->coreid, i->thist);
reach.push_back(c);
break;
}