|
|
@ -2,6 +2,7 @@ |
|
|
|
#include "analyse.h" |
|
|
|
|
|
|
|
#include <iostream> |
|
|
|
#include "raw_code.h" |
|
|
|
|
|
|
|
Core Analyse::new_core() { |
|
|
|
return Core( |
|
|
@ -11,6 +12,20 @@ Core Analyse::new_core() { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
void Analyse::backtrack(uint64_t code) { |
|
|
|
|
|
|
|
// backtrack start at code
|
|
|
|
std::cout << "start backtrack" << std::endl; |
|
|
|
|
|
|
|
std::cout << RawCode(code).dump_case() << std::endl; |
|
|
|
std::cout << "src size: " << cases[code].src.size() << std::endl; |
|
|
|
|
|
|
|
auto last_1 = cases[code].src.front(); |
|
|
|
std::cout << RawCode(last_1->code).dump_case() << std::endl; |
|
|
|
std::cout << "src size: " << last_1->src.size() << std::endl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void Analyse::start_analyse(uint64_t code) { |
|
|
|
|
|
|
|
auto core = new_core(); |
|
|
@ -24,6 +39,7 @@ void Analyse::start_analyse(uint64_t code) { |
|
|
|
.code = code, |
|
|
|
.mask = 0, |
|
|
|
.step = 0, |
|
|
|
// .highlight = false,
|
|
|
|
// .src = std::move(std::list<analyse_t*>{}),
|
|
|
|
}).first->second); |
|
|
|
|
|
|
@ -40,39 +56,41 @@ void Analyse::start_analyse(uint64_t code) { |
|
|
|
void Analyse::new_case(uint64_t code, uint64_t mask) { |
|
|
|
|
|
|
|
|
|
|
|
auto temp = cases.emplace(code, analyse_t { |
|
|
|
.code = code, |
|
|
|
.mask = mask, |
|
|
|
.step = cache.front()->step + 1, |
|
|
|
.src = std::move(std::list<analyse_t*>{cache.front()}) |
|
|
|
}); |
|
|
|
// auto temp = cases.emplace(code, analyse_t {
|
|
|
|
// .code = code,
|
|
|
|
// .mask = mask,
|
|
|
|
// .step = cache.front()->step + 1,
|
|
|
|
// .src = std::move(std::list<analyse_t*>{cache.front()})
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// if (temp.second) {
|
|
|
|
// cache.emplace(&temp.first->second);
|
|
|
|
// } else {
|
|
|
|
// temp.first->second.mask |= mask;
|
|
|
|
//
|
|
|
|
// if (temp.first->second.step != cache.front()->step) {
|
|
|
|
// temp.first->second.src.push_back(cache.front());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (temp.second) { |
|
|
|
cache.emplace(&temp.first->second); |
|
|
|
} else { |
|
|
|
temp.first->second.mask |= mask; |
|
|
|
auto current = cases.find(code); |
|
|
|
if (current != cases.end()) { // find existed case
|
|
|
|
current->second.mask |= mask; // update mask info
|
|
|
|
|
|
|
|
if (temp.first->second.step != cache.front()->step) { |
|
|
|
temp.first->second.src.push_back(cache.front()); |
|
|
|
if (current->second.step != cache.front()->step) { |
|
|
|
current->second.src.push_back(cache.front()); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// auto current = cases.find(code);
|
|
|
|
// if (current != cases.end()) { // find existed case
|
|
|
|
// current->second.mask |= mask; // update mask info
|
|
|
|
//
|
|
|
|
// if (current->second.step != cache.front()->step) {
|
|
|
|
// current->second.src.push_back(cache.front());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// cache.emplace(&cases.emplace(code, analyse_t {
|
|
|
|
// .code = code,
|
|
|
|
// .mask = mask,
|
|
|
|
// .step = cache.front()->step + 1,
|
|
|
|
// .src = std::move(std::list<analyse_t*>{cache.front()}),
|
|
|
|
// }).first->second);
|
|
|
|
cache.emplace(&cases.emplace(code, analyse_t { |
|
|
|
.code = code, |
|
|
|
.mask = mask, |
|
|
|
.step = cache.front()->step + 1, |
|
|
|
// .highlight = false,
|
|
|
|
.src = std::move(std::list<analyse_t*>{cache.front()}), |
|
|
|
}).first->second); |
|
|
|
|
|
|
|
} |
|
|
|