Rose: replace internal_report with program

Replace the use of the internal_report structure (for reports from
engines, MPV etc) with the Rose program interpreter.

SOM processing was reworked to use a new som_operation structure that is
embedded in the appropriate instructions.
This commit is contained in:
Justin Viiret
2016-03-22 16:45:09 +11:00
committed by Matthew Barr
parent 68851742cc
commit 36150bbc19
31 changed files with 877 additions and 1356 deletions

View File

@@ -34,31 +34,49 @@
#ifndef UTIL_REPORT_H
#define UTIL_REPORT_H
#include "internal_report.h"
#include "util/exhaust.h" // for INVALID_EKEY
#include "order_check.h"
#include "ue2common.h"
#include <cassert>
struct internal_report;
namespace ue2 {
class ReportManager;
enum ReportType {
EXTERNAL_CALLBACK,
EXTERNAL_CALLBACK_SOM_REL,
INTERNAL_SOM_LOC_SET,
INTERNAL_SOM_LOC_SET_IF_UNSET,
INTERNAL_SOM_LOC_SET_IF_WRITABLE,
INTERNAL_SOM_LOC_SET_SOM_REV_NFA,
INTERNAL_SOM_LOC_SET_SOM_REV_NFA_IF_UNSET,
INTERNAL_SOM_LOC_SET_SOM_REV_NFA_IF_WRITABLE,
INTERNAL_SOM_LOC_COPY,
INTERNAL_SOM_LOC_COPY_IF_WRITABLE,
INTERNAL_SOM_LOC_MAKE_WRITABLE,
EXTERNAL_CALLBACK_SOM_STORED,
EXTERNAL_CALLBACK_SOM_ABS,
EXTERNAL_CALLBACK_SOM_REV_NFA,
INTERNAL_SOM_LOC_SET_FROM,
INTERNAL_SOM_LOC_SET_FROM_IF_WRITABLE,
INTERNAL_ROSE_CHAIN,
EXTERNAL_CALLBACK_SOM_PASS
};
/**
* \brief All the data we use for handling a match.
*
* Includes extparam constraints and bounds, exhaustion/dedupe keys, offset
* adjustment and SOM information.
*
* The data in this structure is converted into an \ref internal_report in the
* bytecode.
* The data in this structure eventually becomes a list of Rose programs
* instructions.
*/
struct Report {
Report(u8 type_in, u32 onmatch_in) : type(type_in), onmatch(onmatch_in) {
assert(type <= INTERNAL_ROSE_CHAIN);
}
Report(ReportType type_in, u32 onmatch_in)
: type(type_in), onmatch(onmatch_in) {}
/** \brief True if this report has bounds from extended parameters, i.e.
* min offset, max offset, min length. */
@@ -66,8 +84,8 @@ struct Report {
return minOffset > 0 || maxOffset < MAX_OFFSET || minLength > 0;
}
/** \brief from EXTERNAL_ and INTERNAL_ defined in internal_report.h. */
u8 type;
/** \brief Type of this report. */
ReportType type;
/** \brief use SOM for minLength, but don't report it to user callback. */
bool quashSom = false;
@@ -147,6 +165,7 @@ bool isInternalSomReport(const Report &r) {
case EXTERNAL_CALLBACK_SOM_ABS:
case EXTERNAL_CALLBACK_SOM_REV_NFA:
case INTERNAL_ROSE_CHAIN:
case EXTERNAL_CALLBACK_SOM_PASS:
return false;
default:
break; // fall through
@@ -176,6 +195,7 @@ bool isExternalReport(const Report &r) {
case EXTERNAL_CALLBACK_SOM_STORED:
case EXTERNAL_CALLBACK_SOM_ABS:
case EXTERNAL_CALLBACK_SOM_REV_NFA:
case EXTERNAL_CALLBACK_SOM_PASS:
return true;
default:
break; // fall through
@@ -228,7 +248,7 @@ Report makeSomRelativeCallback(u32 report, s32 offsetAdjust, u64a distance) {
}
static inline
Report makeRoseTrigger(u32 event, u64a squashDistance) {
Report makeMpvTrigger(u32 event, u64a squashDistance) {
Report ir(INTERNAL_ROSE_CHAIN, event);
ir.ekey = INVALID_EKEY;
ir.topSquashDistance = squashDistance;
@@ -254,22 +274,6 @@ bool isSimpleExhaustible(const Report &ir) {
return true;
}
/** True if this report requires some of the more esoteric processing in the
* rose adaptor, rather than just firing a callback or doing SOM handling.
*/
static inline
bool isComplexReport(const Report &ir) {
if (ir.hasBounds() || ir.ekey != INVALID_EKEY) {
return true;
}
return false;
}
/** \brief Write the given Report into an internal_report structure. */
void writeInternalReport(const Report &report, const ReportManager &rm,
internal_report *ir);
} // namespace
#endif // UTIL_REPORT_H