mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: move END instruction to start of enum
Stop overloading END as the last Rose interpreter instruction, use new sentinel LAST_ROSE_INSTRUCTION for that. This change will also make it easier to add new instructions without renumbering END and thus changing all generated bytecodes.
This commit is contained in:
parent
997787bd4b
commit
6e533589bb
@ -1389,9 +1389,15 @@ hwlmcb_rv_t roseRunProgram_i(const struct RoseEngine *t,
|
||||
assert(pc >= pc_base);
|
||||
assert((size_t)(pc - pc_base) < t->size);
|
||||
const u8 code = *(const u8 *)pc;
|
||||
assert(code <= ROSE_INSTR_END);
|
||||
assert(code <= LAST_ROSE_INSTRUCTION);
|
||||
|
||||
switch ((enum RoseInstructionCode)code) {
|
||||
PROGRAM_CASE(END) {
|
||||
DEBUG_PRINTF("finished\n");
|
||||
return HWLM_CONTINUE_MATCHING;
|
||||
}
|
||||
PROGRAM_NEXT_INSTRUCTION
|
||||
|
||||
PROGRAM_CASE(ANCHORED_DELAY) {
|
||||
if (in_anchored && end > t->floatingMinLiteralMatchOffset) {
|
||||
DEBUG_PRINTF("delay until playback\n");
|
||||
@ -1971,12 +1977,6 @@ hwlmcb_rv_t roseRunProgram_i(const struct RoseEngine *t,
|
||||
}
|
||||
}
|
||||
PROGRAM_NEXT_INSTRUCTION
|
||||
|
||||
PROGRAM_CASE(END) {
|
||||
DEBUG_PRINTF("finished\n");
|
||||
return HWLM_CONTINUE_MATCHING;
|
||||
}
|
||||
PROGRAM_NEXT_INSTRUCTION
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,9 +234,12 @@ void dumpProgram(ofstream &os, const RoseEngine *t, const char *pc) {
|
||||
const char *pc_base = pc;
|
||||
for (;;) {
|
||||
u8 code = *(const u8 *)pc;
|
||||
assert(code <= ROSE_INSTR_END);
|
||||
assert(code <= LAST_ROSE_INSTRUCTION);
|
||||
const size_t offset = pc - pc_base;
|
||||
switch (code) {
|
||||
PROGRAM_CASE(END) { return; }
|
||||
PROGRAM_NEXT_INSTRUCTION
|
||||
|
||||
PROGRAM_CASE(ANCHORED_DELAY) {
|
||||
os << " groups 0x" << std::hex << ri->groups << std::dec
|
||||
<< endl;
|
||||
@ -607,9 +610,6 @@ void dumpProgram(ofstream &os, const RoseEngine *t, const char *pc) {
|
||||
PROGRAM_CASE(MATCHER_EOD) {}
|
||||
PROGRAM_NEXT_INSTRUCTION
|
||||
|
||||
PROGRAM_CASE(END) { return; }
|
||||
PROGRAM_NEXT_INSTRUCTION
|
||||
|
||||
default:
|
||||
os << " UNKNOWN (code " << int{code} << ")" << endl;
|
||||
os << " <stopping>" << endl;
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
/** \brief Role program instruction opcodes. */
|
||||
enum RoseInstructionCode {
|
||||
ROSE_INSTR_END, //!< End of program.
|
||||
ROSE_INSTR_ANCHORED_DELAY, //!< Delay until after anchored matcher.
|
||||
ROSE_INSTR_CHECK_LIT_EARLY, //!< Skip matches before floating min offset.
|
||||
ROSE_INSTR_CHECK_GROUPS, //!< Check that literal groups are on.
|
||||
@ -116,7 +117,11 @@ enum RoseInstructionCode {
|
||||
/** \brief Run the EOD-anchored HWLM literal matcher. */
|
||||
ROSE_INSTR_MATCHER_EOD,
|
||||
|
||||
ROSE_INSTR_END //!< End of program.
|
||||
LAST_ROSE_INSTRUCTION = ROSE_INSTR_MATCHER_EOD //!< Sentinel.
|
||||
};
|
||||
|
||||
struct ROSE_STRUCT_END {
|
||||
u8 code; //!< From enum RoseInstructionCode.
|
||||
};
|
||||
|
||||
struct ROSE_STRUCT_ANCHORED_DELAY {
|
||||
@ -460,8 +465,4 @@ struct ROSE_STRUCT_MATCHER_EOD {
|
||||
u8 code; //!< From enum RoseInstructionCode.
|
||||
};
|
||||
|
||||
struct ROSE_STRUCT_END {
|
||||
u8 code; //!< From enum RoseInstructionCode.
|
||||
};
|
||||
|
||||
#endif // ROSE_ROSE_PROGRAM_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user