The code generation backend has a break statement (SBreak()), but it is not handled correctly. Furthermore, it would be difficult to handle correctly, since the code generation backend often compiles loop-like constructs to non-loop-like constructs (e.g. looping over a singleton list just executes the loop body once instead).
One possible fix is to remove SBreak and its uses and replace it with some kind of "escapable block" statement and a corresponding "escape" statement. An escapable block has a name, and an escape statement jumps to the end of the block it names. In C++ this would be implemented with goto:
The code generation backend has a break statement (
SBreak()
), but it is not handled correctly. Furthermore, it would be difficult to handle correctly, since the code generation backend often compiles loop-like constructs to non-loop-like constructs (e.g. looping over a singleton list just executes the loop body once instead).One possible fix is to remove
SBreak
and its uses and replace it with some kind of "escapable block" statement and a corresponding "escape" statement. An escapable block has a name, and an escape statement jumps to the end of the block it names. In C++ this would be implemented withgoto
:In Java, you can use labeled loops: