jsx/JSX — pull request #322 by wasabiz (2014-04-23 12:14:45+00:00)
Title: add exceptional control support to CPS transformer

Support cps transformation of try-catch-finally block.

```jsx
class C {
function m () : void {
function * g () : void yield void {
try {
log "in try block";
} catch (e : Error) {
log "in catch block";
} finally {
log "in finally block";
}
}
}
}
```

```js
C.prototype.m$ = function () {
var $this = this;
var g;
function g() {
var $generator;
var $loop;
var $localJumps;
var $return;
var $raised;
var $error;
$generator = new __jsx_generator_object$0();
$localJumps = [ ];
function $loop($next) {
var $a0;
var $a1;
var $a3;
var $a2;
var $a6;
var $a5;
var $a4;
var $a7;
var $a9;
var $a8;
var $a10;
var $a11;
var $a12;
while (true) {
try {
while (true) {
switch ($next) {
case 0:
$localJumps.push(7);
$localJumps.push(1);
$a0 = "in try block";
console.log($a0);
$next = 1;
break;
case 1:
$localJumps.pop();
$next = 2;
break;
case 2:
$a1 = $raised;
if ($a1) {
$next = 3;
break;
} else {
$next = 7;
break;
}
case 3:
$a3 = false;
$a2 = $raised = $a3;
$a2;
$next = 4;
break;
case 4:
$a6 = $error;
$a5 = $a6;
$a4 = $a5 instanceof Error;
if ($a4) {
$next = 5;
break;
} else {
$next = 6;
break;
}
case 5:
$a7 = "in catch block";
console.log($a7);
$next = 7;
break;
case 6:
$a9 = $error;
$a8 = $a9;
throw $a8;
$next = 7;
break;
case 7:
$localJumps.pop();
$a10 = "in finally block";
console.log($a10);
$next = 8;
break;
case 8:
$a11 = $raised;
if ($a11) {
$next = 9;
break;
} else {
$next = 10;
break;
}
case 9:
$a12 = $error;
throw $a12;
$next = 10;
break;
case 10:
$generator.__value = $return;
$generator.__next = -1;
return;
}
}
} catch ($__jsx_catch_0) {
{
$raised = true;
$error = $__jsx_catch_0;
$next = $localJumps[$localJumps.length - 1];
}
} finally {
if ($localJumps.length === 0 && $raised) {
throw $error;
}
}
}
}
$generator.__next = 0;
$generator.__loop = $loop;
return $generator;
}
};
```