decltype(arg), (NFAEngineType)0>::doOp(i, arg)
}
-typedef bool (*has_accel_fn)(const NFA *nfa);
+typedef bool (*nfa_dispatch_fn)(const NFA *nfa);
template<typename T>
static
return limex->accelCount;
}
+template<typename T>
+static
+bool has_repeats_limex(const NFA *nfa) {
+ const T *limex = (const T *)getImplNfa(nfa);
+ return limex->repeatCount;
+}
+
+
+template<typename T>
+static
+bool has_repeats_other_than_firsts_limex(const NFA *nfa) {
+ const T *limex = (const T *)getImplNfa(nfa);
+ const char *ptr = (const char *)limex;
+
+ const u32 *repeatOffset = (const u32 *)(ptr + limex->repeatOffset);
+
+ for (u32 i = 0; i < limex->repeatCount; i++) {
+ u32 offset = repeatOffset[i];
+ const NFARepeatInfo *info = (const NFARepeatInfo *)(ptr + offset);
+ const RepeatInfo *repeat =
+ (const RepeatInfo *)((const char *)info + sizeof(*info));
+ if (repeat->type != REPEAT_FIRST) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
static
-bool has_accel_generic(const NFA *) {
+bool dispatch_false(const NFA *) {
return false;
}
static const NFACategory category = NFA_LIMEX; \
typedef LimExNFA##mlt_size implNFA_t; \
typedef u_##mlt_size tableRow_t; \
- static const has_accel_fn has_accel; \
+ static const nfa_dispatch_fn has_accel; \
+ static const nfa_dispatch_fn has_repeats; \
+ static const nfa_dispatch_fn has_repeats_other_than_firsts; \
static const u32 stateAlign = \
MAX(alignof(tableRow_t), alignof(RepeatControl)); \
static const bool fast = mlt_size <= 64; \
}; \
- const has_accel_fn NFATraits<LIMEX_NFA_##mlt_size>::has_accel \
+ const nfa_dispatch_fn NFATraits<LIMEX_NFA_##mlt_size>::has_accel \
= has_accel_limex<LimExNFA##mlt_size>; \
+ const nfa_dispatch_fn NFATraits<LIMEX_NFA_##mlt_size>::has_repeats \
+ = has_repeats_limex<LimExNFA##mlt_size>; \
+ const nfa_dispatch_fn \
+ NFATraits<LIMEX_NFA_##mlt_size>::has_repeats_other_than_firsts \
+ = has_repeats_other_than_firsts_limex<LimExNFA##mlt_size>; \
DO_IF_DUMP_SUPPORT( \
const char *NFATraits<LIMEX_NFA_##mlt_size>::name \
= "LimEx "#mlt_size; \
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 1;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<MCCLELLAN_NFA_8>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<MCCLELLAN_NFA_8>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<MCCLELLAN_NFA_8>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<MCCLELLAN_NFA_8>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<MCCLELLAN_NFA_8>::name = "McClellan 8";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 2;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<MCCLELLAN_NFA_16>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<MCCLELLAN_NFA_16>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<MCCLELLAN_NFA_16>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<MCCLELLAN_NFA_16>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<MCCLELLAN_NFA_16>::name = "McClellan 16";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<GOUGH_NFA_8>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<GOUGH_NFA_8>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<GOUGH_NFA_8>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<GOUGH_NFA_8>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<GOUGH_NFA_8>::name = "Goughfish 8";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<GOUGH_NFA_16>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<GOUGH_NFA_16>::has_accel = has_accel_dfa;
+const nfa_dispatch_fn NFATraits<GOUGH_NFA_16>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<GOUGH_NFA_16>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<GOUGH_NFA_16>::name = "Goughfish 16";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<MPV_NFA_0>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<MPV_NFA_0>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<MPV_NFA_0>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<MPV_NFA_0>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<MPV_NFA_0>::name = "Mega-Puff-Vac";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<CASTLE_NFA_0>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<CASTLE_NFA_0>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<CASTLE_NFA_0>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<CASTLE_NFA_0>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<CASTLE_NFA_0>::name = "Castle";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<LBR_NFA_Dot>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Dot>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Dot>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Dot>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<LBR_NFA_Dot>::name = "Lim Bounded Repeat (D)";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<LBR_NFA_Verm>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Verm>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Verm>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Verm>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<LBR_NFA_Verm>::name = "Lim Bounded Repeat (V)";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<LBR_NFA_NVerm>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<LBR_NFA_NVerm>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_NVerm>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_NVerm>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<LBR_NFA_NVerm>::name = "Lim Bounded Repeat (NV)";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<LBR_NFA_Shuf>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Shuf>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Shuf>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Shuf>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<LBR_NFA_Shuf>::name = "Lim Bounded Repeat (S)";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 8;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<LBR_NFA_Truf>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Truf>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Truf>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<LBR_NFA_Truf>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<LBR_NFA_Truf>::name = "Lim Bounded Repeat (M)";
#endif
static const NFACategory category = NFA_OTHER;
static const u32 stateAlign = 32;
static const bool fast = true;
- static const has_accel_fn has_accel;
+ static const nfa_dispatch_fn has_accel;
+ static const nfa_dispatch_fn has_repeats;
+ static const nfa_dispatch_fn has_repeats_other_than_firsts;
};
-const has_accel_fn NFATraits<TAMARAMA_NFA_0>::has_accel = has_accel_generic;
+const nfa_dispatch_fn NFATraits<TAMARAMA_NFA_0>::has_accel = dispatch_false;
+const nfa_dispatch_fn NFATraits<TAMARAMA_NFA_0>::has_repeats = dispatch_false;
+const nfa_dispatch_fn NFATraits<TAMARAMA_NFA_0>::has_repeats_other_than_firsts = dispatch_false;
#if defined(DUMP_SUPPORT)
const char *NFATraits<TAMARAMA_NFA_0>::name = "Tamarama";
#endif
};
}
-bool has_bounded_repeats_other_than_firsts(const NFA &nfa) {
- if (!DISPATCH_BY_NFA_TYPE((NFAEngineType)nfa.type, is_limex, &nfa)) {
- return false;
+namespace {
+template<NFAEngineType t>
+struct has_repeats_other_than_firsts_dispatch {
+ static nfa_dispatch_fn call(const void *) {
+ return NFATraits<t>::has_repeats_other_than_firsts;
}
+};
+}
- const LimExNFABase *limex = (const LimExNFABase *)getImplNfa(&nfa);
- const char *ptr = (const char *)limex;
-
- const u32 *repeatOffset = (const u32 *)(ptr + limex->repeatOffset);
+bool has_bounded_repeats_other_than_firsts(const NFA &nfa) {
+ return DISPATCH_BY_NFA_TYPE((NFAEngineType)nfa.type,
+ has_repeats_other_than_firsts_dispatch,
+ &nfa)(&nfa);
+}
- for (u32 i = 0; i < limex->repeatCount; i++) {
- u32 offset = repeatOffset[i];
- const NFARepeatInfo *info = (const NFARepeatInfo *)(ptr + offset);
- const RepeatInfo *repeat =
- (const RepeatInfo *)((const char *)info + sizeof(*info));
- if (repeat->type != REPEAT_FIRST) {
- return true;
- }
+namespace {
+template<NFAEngineType t>
+struct has_repeats_dispatch {
+ static nfa_dispatch_fn call(const void *) {
+ return NFATraits<t>::has_repeats;
}
-
- return false;
+};
}
bool has_bounded_repeats(const NFA &nfa) {
- if (!DISPATCH_BY_NFA_TYPE((NFAEngineType)nfa.type, is_limex, &nfa)) {
- return false;
- }
-
- const LimExNFABase *limex = (const LimExNFABase *)getImplNfa(&nfa);
- return limex->repeatCount;
+ return DISPATCH_BY_NFA_TYPE((NFAEngineType)nfa.type, has_repeats_dispatch,
+ &nfa)(&nfa);
}
namespace {
template<NFAEngineType t>
struct has_accel_dispatch {
- static has_accel_fn call(const void *) {
+ static nfa_dispatch_fn call(const void *) {
return NFATraits<t>::has_accel;
}
};
bool has_accel(const NFA &nfa) {
return DISPATCH_BY_NFA_TYPE((NFAEngineType)nfa.type, has_accel_dispatch,
- &nfa)
- (&nfa);
+ &nfa)(&nfa);
}
bool requires_decompress_key(const NFA &nfa) {