I'm working on a small custom Assembler
I have a vector of struc to storing OPCODE informations (Mnemonic, number and type of argument, parsing function,...)
typedef char args_type_t; typedef struct op_s { std::string opcode; char nbr_args; args_type_t type[4]; int code; Tryte (*fct)(std::vector<std::string>); } op_t; the parsing function is pointer on a static member function :
{"MOV", 2, {T_REGISTER | T_ADDRESS, T_REGISTER | T_ADDRESS | T_CONSTANT}, 1, &Opcodes::MOV}, and the function :
class Opcodes { public: static Tryte Opcodes::MOV(std::vector<std::string> _opMap) { return Tryte(0); } }; I try this, but I get SEGFAULT (str() is a member function of Tryte) :
for (int i = 0; i < opMap.size(); i++) { for (int j = 0; j < op_tab.size(); j++) { if (!op_tab[j].opcode.compare(opMap[i][2])) { std::cout << "OPBYTE : " << op_tab[j].fct(opMap[i]).str() << std::endl; } } } I want to call my function without instanciate Opcodes object it's posible ?
EDIT :
my error was here : if (!op_tab[j].opcode.compare(opMap[i][2])) my mnemonic is the 1st item n opMap
(op_tab[j].fct)(opMap[i]).str(). The braces are important for grouping, sincefctis a pointer to a function, not a member function.