-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't store pointers #1
Comments
This could be achieved by using |
That only sets the value of Would need to be able to set Thus you kinda have pointers, which are basically a necessity for doing anything of substance |
You can replace the
|
What if the buffer identifier has to be dynamic? Like it may be 1,2,3,4... etc as the result of a loop |
Asking btw because I'm building a Brainf*ck-to-PocoBytecode compiler to test out a generic Brainf*ck compiler I'm making, will need to access a pointer for the current cell in Brainf*ck |
Im not familiar with brainf*ck really, its not really a language you use for what I typically do. The buffer identifier (a, b, c, 1, 4, ...) can be any single character, if thats what you are asking. |
No one uses brainf*ck for anything :P Just a stupid side-project to get comfortable working on compilers. I'll make a pull request in a bit, but all I'll be adding is: if the second argument in a 4x command is 1 instead of 2, it does this: storage[storage[line[1].substring(0, 1)]] = storage[line[1].substring(2, 3)]; (Which uses the value of the first buffer as the buffer identifier for the ACTUAL buffer your setting too. This is similar to a pointer, which is a common part of most close-to-metal languages like C) instead of this: storage[line[1].substring(0, 1)] = storage[line[1].substring(2, 3)]; |
Okay, I wrote some basic API docs in the wiki if you want to add it. |
For the docs, could you give a quick description of the function? |
Would be useful for higher-level programming if Poco was able to reference registers from memory. Currently, reference data types like arrays or hash-maps couldn't be compiled to Poco bytecode because theres no way to call 4x set commands using data from a register.
You might not even have to make a pointer type, maybe use the second argument of 4x as a flag to make the source register act as a pointer, like so:
Init:
Byte Code
After:
The text was updated successfully, but these errors were encountered: