#pragma once #include #include #include #include #include "common/link_types.h" #include "common/type_system/TypeSpec.h" #include "decompiler/Disasm/DecompilerLabel.h" #include "decompiler/config.h" #include "decompiler/util/DecompilerTypeSystem.h" namespace decompiler { struct LabelInfo { std::string name; TypeSpec result_type; int idx = -1; bool known = false; bool is_value = false; bool from_user = false; std::optional array_size; std::string print() const; }; class LabelDB { public: LabelDB(const std::unordered_map& config, const std::vector& labels, const DecompilerTypeSystem& dts); const LabelInfo& lookup(int idx) const; const LabelInfo& lookup(const std::string& name) const; int get_index_by_offset(int seg, int offset) const; std::optional try_get_index_by_offset(int seg, int offset) const; int get_index_by_name(const std::string& name) const; // automatic, or from user bool label_info_known_by_name(const std::string& name) const; LabelInfo set_and_get_previous(int idx, const TypeSpec& type, bool is_value, std::optional array_size); private: std::vector m_info; std::unordered_map m_labels_by_name; std::vector> m_labels_by_offset_into_seg; // in bytes. }; } // namespace decompiler