MCPcopy Create free account
hub / github.com/RischardV/emoji-shellcoding / Block

Class Block

block/block.cpp:210–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208
209typedef std::vector<std::deque<Instruction>> BlockList;
210class Block {
211 static constexpr size_t max_size = 5;
212public:
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
250static std::map<Bytes, Sequence> sequences;
251static std::map<Bytes, Instruction> instructions;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected