#pragma once #include #include #include #include /// /// raw virtual instruction information extracted using lex and yacc... /// struct _vinstr_meta { /// /// virtual instruction name... /// std::string name; /// /// if the virtual instruction has a second operand or not (imm)... /// bool has_imm; /// /// the imm if any... /// std::uintptr_t imm; }; /// /// raw label containing raw virtual instruction data extracted using lex and yacc... /// struct _vlabel_meta { /// /// label name... /// std::string label_name; /// /// vector of raw virtual instruction data... /// std::vector< _vinstr_meta > vinstrs; }; /// /// used for parse_t::for_each... /// using callback_t = std::function< bool( _vlabel_meta * ) >; /// /// this singleton class contains all the information for parsed virtual instructions... /// class parse_t { public: /// /// gets the one and only instance of this class... /// /// returns a pointer to the one and only instance of this class... static auto get_instance() -> parse_t *; /// /// used by yacc file to add new labels... /// /// label name, no pass by reference since a new std::string object must be /// created... void add_label( std::string label_name ); /// /// used by yacc file to add new virtual instruction with no imm... /// /// virtual instruction name, no pass by reference since a new std::string object must be /// created... void add_vinstr( std::string vinstr_name ); /// /// used by yacc file to add new virtual instruction with an imm... /// /// virtual instruction name, no pass by reference since a new std::string object must /// be created... /// imm value... void add_vinstr( std::string vinstr_name, std::uintptr_t imm_val ); /// /// used to loop over every single label... /// /// lambda to call back given the label structure... /// returns true if all labels were looped through... bool for_each( callback_t callback ); private: /// /// vector of raw virtual labels... /// std::vector< _vlabel_meta > virt_labels; /// /// default constructor... private... /// parse_t(); };