In this recipe, we added basic lowering support for the switch operator (?:), which enabled us to compile and execute source code with this new operator and give expected runtime results. Note that this is not an optimal implementation of the lowering/code generation phase for this operator, and requires further work to generate optimized MSIL. This is left as an exercise for the reader.
The C# lowering phase is responsible for transforming the initial bound tree from the binder into a simpler bound tree that can be operated by the code generation phase. The code generation phase operates on the lowered bound tree and transforms it into MSIL. In this recipe, we added lowering support for the switch operator that rewrites a ...