Whole purpose of learning C++ over C# and whatnot is for performance and working at a lower level for more control. Since I've been learning a little SIMD I figured a good project to test myself and make stuff better would be to program a basic scripting language that handles integer and float point calculations.
I've got it parsing C-style syntax reasonably well, but I'm a bit confused on how to operate the stack.
Some PsuedoCode assuming x86 so no need for more than 32-byte registers
char* MemoryPool;
int* ir[3] //Integer Register
float* fr[3]; //Float Register fr = ir positions
const char* path;
stack<void (*)(void)> InstructionStack;
int main(void)
{
const char* script = ReadTextFile(path);
vector<Instruction> Instructions = Parse(script);
InitScript(Instructions,&MemoryPool,ir,fr,&InstructionStack);
/*Execute Stack Will Execute Script At This Point <- starting out simple,I know more dynamic implementation would be needed later*/
}
I know I need an Instruction for things like IntAdd,IntSubtract,Mov,FloatAdd,FloatSubtract. I can probably remove Mov but still working out a decent way to do this.
My problem is I don't know how I can setup a stack with function pointers that will accept all these type of instructions. Only thing I can think of is doing Functor type classes and using inheritance to have them accept a bunch of different forms, but I imagine there has to be another way. Any recommendations.