Switch case impl (Generalized goto style flow control support)
The current switch impl works but does a lot of ugly array stuff and duplicates computations in order to support fallthroughs.
A better solution would be to add support for generic goto style flow control and then use these to support switch case. Each case maps to a specific chunk of code only accessible in the switch block. These are then chained together. Writing this explicitly:
switch (x) {
case 0: // Section 0;
++x;
goto section 1;
default:
case 1: // Section 1:
return 3;
goto section 2;
case 2: // Section 2;
x = 444;
break;
goto section 3;
case 3: // Section 3
x += 10;
goto section 4;
// Section 4
;// Empty statement
}
Implicit goto commands are inserted as the last element of the switch case body. In cases with non normal flow control, these are not reached. Otherwise, they handle the chaining of blocks of code together to support fallthrough.
An empty last noop block is also included to support fallthrough in the last case using the same logic.