| 208 | |
| 209 | typedef std::vector<std::deque<Instruction>> BlockList; |
| 210 | class Block { |
| 211 | static constexpr size_t max_size = 5; |
| 212 | public: |
| 213 | Instruction goal; |
| 214 | bool is_sequence; |
| 215 | bool prefix[max_size]; |
| 216 | bool suffix[max_size]; |
| 217 | BlockList prev[max_size]; |
| 218 | BlockList next[max_size]; |
| 219 | |
| 220 | Block(const Instruction &in_goal) { |
| 221 | goal = in_goal; |
| 222 | is_sequence = false; |
| 223 | for (size_t i=0; i<max_size; i++) { |
| 224 | prefix[i] = false; |
| 225 | suffix[i] = false; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | bool is_good(size_t idx) const { |
| 230 | if ((suffix[idx] || (prev[idx].size() > 0)) |
| 231 | && ((goal.is_jump() && prefix[idx]) || (next[idx].size() > 0))) { |
| 232 | return true; |
| 233 | } |
| 234 | if (suffix[idx] && ((idx == goal.size()) || (goal.is_jump() && (idx > 0)))) { |
| 235 | return true; |
| 236 | } |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | bool is_good(void) const { |
| 241 | for (size_t idx=0; idx<=goal.size(); idx++) { |
| 242 | if (is_good(idx)) { |
| 243 | return true; |
| 244 | } |
| 245 | } |
| 246 | return false; |
| 247 | } |
| 248 | }; |
| 249 | |
| 250 | static std::map<Bytes, Sequence> sequences; |
| 251 | static std::map<Bytes, Instruction> instructions; |
nothing calls this directly
no outgoing calls
no test coverage detected