Browse Source

feat: support src cases record

legacy
Dnomd343 2 years ago
parent
commit
b144e16507
  1. 13
      src/analyse/analyse.cc
  2. 6
      src/analyse/analyse.h

13
src/analyse/analyse.cc

@ -23,8 +23,12 @@ void Analyse::start_analyse(uint64_t code) {
cache.emplace(&cases.emplace(code, analyse_t { cache.emplace(&cases.emplace(code, analyse_t {
.code = code, .code = code,
.mask = 0, .mask = 0,
.step = 0,
.src = std::move(std::set<analyse_t*>{}),
}).first->second); }).first->second);
// std::cout << "src size: " << cases[code].src.size() << std::endl;
while (!cache.empty()) { while (!cache.empty()) {
core.next_step(cache.front()->code, cache.front()->mask); core.next_step(cache.front()->code, cache.front()->mask);
@ -39,11 +43,20 @@ void Analyse::new_case(uint64_t code, uint64_t mask) {
auto current = cases.find(code); auto current = cases.find(code);
if (current != cases.end()) { // find existed case if (current != cases.end()) { // find existed case
current->second.mask |= mask; // update mask info current->second.mask |= mask; // update mask info
// current->second.src.emplace()
if (current->second.step != cache.front()->step) {
current->second.src.emplace(cache.front());
}
return; return;
} }
cache.emplace(&cases.emplace(code, analyse_t { cache.emplace(&cases.emplace(code, analyse_t {
.code = code, .code = code,
.mask = mask, .mask = mask,
.step = cache.front()->step + 1,
.src = std::move(std::set<analyse_t*>{cache.front()}),
}).first->second); }).first->second);
} }

6
src/analyse/analyse.h

@ -4,15 +4,19 @@
#include <cstdint> #include <cstdint>
#include <unordered_map> #include <unordered_map>
#include <set>
#include <list>
class Analyse { class Analyse {
public: public:
struct analyse_t { struct analyse_t {
uint64_t code; uint64_t code;
uint64_t mask; uint64_t mask;
// int step; int step;
// TODO: try set / unordered_set // TODO: try set / unordered_set
// std::list<analyse_t*> src; // std::list<analyse_t*> src;
std::set<analyse_t*> src;
}; };
std::queue<analyse_t*> cache; std::queue<analyse_t*> cache;

Loading…
Cancel
Save