zach-r-hughes / MindustryCompiler

C-style compiler for Mindustry.
12 stars 0 forks source link

Recursive functions not implemented. #3

Open zach-r-hughes opened 2 years ago

zach-r-hughes commented 2 years ago

Currently, recursive functions are not implemented. An array may be required for implementation, which would potentially require a memory cell for the program to execute correctly.

zach-r-hughes commented 2 years ago

Without a memory cell/array (a stack), function calls may be implementable if two functions 'A' and 'B' are called in such a way that 'A' calls 'B', but 'B' never calls 'A' (in the same context).

Another potential, memory-cell less implementation would be to pre-allocate a massive amount of memory on program start, and write a index radix-style address reduction algorithm that with 4 iterations could allow up to 1000 elements. This would potentially increase the start-up time of the program, though, as many, many variables would have to be allocated, and a massive ugly 'if' statement would need to be implemented that would reduce to the correct array element.

zach-r-hughes commented 2 years ago

If there were some way to read/manipulate the characters from a string, there may be some opportunity there for an array-like data structure. It doesn't appear however that there is such functionality in vanilla Mindustry.