rose: rework storage of extra lookaround information

- remove explicit lookaround table from bytecode
- make the RoseInstr responsible for adding required info to blob
This commit is contained in:
Alex Coyte
2017-05-01 16:09:10 +10:00
committed by Matthew Barr
parent 1a04d1330e
commit 15c8a7bd98
12 changed files with 231 additions and 263 deletions

View File

@@ -34,6 +34,7 @@
#include "ue2common.h"
#include "util/alloc.h"
#include "util/bytecode_ptr.h"
#include "util/charreach.h"
#include "util/container.h"
#include "util/multibit_build.h"
#include "util/noncopyable.h"
@@ -45,6 +46,21 @@
namespace ue2 {
class RoseEngineBlob;
struct lookaround_info : noncopyable {
u32 get_offset_of(const std::vector<std::vector<CharReach>> &look,
RoseEngineBlob &blob);
u32 get_offset_of(const std::vector<CharReach> &reach,
RoseEngineBlob &blob);
u32 get_offset_of(const std::vector<s8> &look, RoseEngineBlob &blob);
private:
unordered_map<std::vector<std::vector<CharReach>>, u32> multi_cache;
unordered_map<std::vector<s8>, u32> lcache;
unordered_map<std::vector<CharReach>, u32> rcache;
};
class RoseEngineBlob : noncopyable {
public:
/** \brief Base offset of engine_blob in the Rose engine bytecode. */
@@ -133,6 +149,8 @@ public:
copy_bytes((char *)engine + base_offset, blob);
}
lookaround_info lookaround_cache;
private:
void pad(size_t align) {
assert(ISALIGNED_N(base_offset, align));