Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR is a precursor to being able to decompose expressions. We need to be able to decompose statements and expressions that contain more than one function call, since those function calls could be (or contain) yield points. Consider a statement like: ```go a[b()] = c() + d(e()) ``` When yielding, we need to keep track of which functions have already been called (and their results), so that we can jump over them when resuming. We may need to decompose the statement above like so (according to https://go.dev/ref/spec#Order_of_evaluation): ```go _b := b() _c := c() _e := e() _d := d(_e) a[_b] = _c + _d ``` After decomposition, we're able to inject dispatch control flow and jump over function calls. This decomposition is problematic because there are places in the AST where only certain statements and expressions are valid. In those cases, additional desugaring is required so that expressions that may contain yield points are in a place where additional temporary variables can be introduced safely. This PR desugars `if`, `for`, `switch` and `select` statements further, hoisting statements and expressions out of the control flow and into outer or inner blocks so that they can be decomposed safely. I've added unit tests to increase coverage of the desugaring passes. This will help in the next PR where we decompose expressions.
- Loading branch information