drwhut/decision

Add functions to manipulate strings.

Opened this issue · 3 comments

For example, Concatenate.

Length was trivial to implement, but there is a problem with implementing functions like Concatenate - some strings in the bytecode point directly to strings in the .data section, some point to external malloc'd strings (e.g. string variables), and there's no way to know which is which. Best course of action would probably be to wait for #5 to be resolved first.

Maybe it is best if strings are immutable? When using a function like Concatenate, it should make a new string. This would mean the VM would have to keep track of malloc'd strings and free them after they are used.

Since the new stack-based VM has been implemented, I will make it so each item in the stack has a flag to say whether it should be freed when it is popped from the stack. The same would go for string variables.