3 ms·
I had an interesting time writing a JIT for Piet some time ago. Piet is a pretty weird language in a few non-obvious ways. From what I remember: * Execution mo
by greenpenguin 11y ago
I had an interesting time writing a JIT for Piet some time ago. Piet is a pretty weird language in a few non-obvious ways. From what I remember:
* Execution moves between blocks of colour. Flood fill algorithms are a valid compiler optimisation!
* Execution can move left/right/up/down. You can't necessarily tell what will be executed without doing it. The 'codel chooser' stuff means you can exit a colour block in two different ways depending on program state (plus left/right/up/down, so 8 ways total...).
* Instructions are encoded in the difference between colour blocks.
* Piet is otherwise a fairly straightforward stack machine.