On Fri Jun 23 20:49:48 2023 +0000, Zebediah Figura wrote:
My problem isn't so much with doing extra passes later, and in fact, given the complexity of this pass, I *probably* prefer this to be its own pass instead of something that's handled in create_loop(). My problem is that I want the IR to have a universally unambiguous meaning, so we can do things like dump it to stderr at any point, look at it, and check whether it's correct.
I agree. Would it be feasible to immediately store somewhere in the context the iteration code when parsing `for (...; ...; ...)` (before parsing the body), and then immediately copy it each time it is needed while parsing the body, therefore removing the need for a double pass? That might require some refactoring, but shouldn't be too difficult.
Similarly, I don't like too much the fact that the `continue`/`break` validation is done in a different pass. The frontend should be responsible for creating valid IR in the first place. If you refactor the code the way I said you can avoid that, simply by keeping a boolean telling you whether you are in a loop or not.