#ifndef WILD_OPCODE_LABEL_MANAGER_HPP_ #define WILD_OPCODE_LABEL_MANAGER_HPP_ #include "wild_opcode_label.hpp" #include #include #include class wild_opcode_label_manager { public: void reset_labels() { this->virtual_opcode_labels.clear(); this->virtual_opcode_labels.reserve(0x1000); } public: bool find_label_unread(std::vector::iterator& iter) { iter = std::find_if(this->virtual_opcode_labels.begin(), this->virtual_opcode_labels.end(), [&](wild_opcode_label const& label) -> bool { return (label.is_read == false); }); return (iter != this->virtual_opcode_labels.end()); } bool find_label_by_address(std::vector::iterator& iter, uint32_t address) { iter = std::find_if(this->virtual_opcode_labels.begin(), this->virtual_opcode_labels.end(), [&](wild_opcode_label const& label) -> bool { return (label.address == address); }); return (iter != this->virtual_opcode_labels.end()); } public: bool exists_label(uint32_t address) { std::vector::iterator iter; return this->find_label_by_address(iter, address); } void create_label(uint32_t address, uint32_t offset) { if (!this->exists_label(address)) this->virtual_opcode_labels.push_back(wild_opcode_label(address, offset)); } protected: std::vector virtual_opcode_labels; }; #endif