nv-cli-tailize-try-catch-final
v1.0.12
Published
nv-cli-tailize-try-catch-final ============================== - cli tool - its purpose is to tailized rtrn/thrw of try-stmt AND transform the finalizer to its proper position - to make the write/read order same-as the execution-order
Downloads
11
Readme
nv-cli-tailize-try-catch-final
- cli tool
- its purpose is to tailized rtrn/thrw of try-stmt AND transform the finalizer to its proper position
- to make the write/read order same-as the execution-order
install
- npm install nv-cli-tailize-try-catch-final -g
usage
Usage: nv_cli_tailize_tcf [options]
Options:
-i, --input input string ,default stdin
-o, --output output string,default stdout
-h, --help usage
example
nv_cli_tailize_tcf -i
input
var src =`
function tst() {
let a = 100;
try {
let a = (()=>{
try {
throw(1);
console.log("unreachable")
} catch(e) {
return(e);
console.log("unreachable")
} finally {
console.log('inner')
}
})();
if(a>0) {
return(a*2);
console.log("unreachable")
} else {
return(a*3)
console.log("unreachable")
}
} catch ({e}) {
console.log("unreachable")
} finally {
let arr = [a,a*2,a*3]
console.log(arr)
}
let c = a*3;
return(c)
}
`
/*
> tst()
inner
[ 100, 200, 300 ]
2
>
*/
press ctrl + D
output
function tst() {
let a = 100;
//outer-try-catch-final
{
let ___τfinalización = [undefined, undefined];
//outer-try-block
{
let a = (() => {
//inner- try-catch-final
{
let ___τfinalización = [undefined, undefined];
//inner-try-block
{
___τfinalización = [false, 1];
}
//inner-catch-handle
if (___τfinalización[0] === false) {
let ___τcatch_clause_value = ___τfinalización[1];
{
let e = ___τcatch_clause_value;
___τfinalización = [true, e];
}
} else {}
//inner-final-block
{
console.log('inner');
}
//inner-tailized-completion-of-try-catch-final-stmt
if (___τfinalización[0] === undefined) {} else if (___τfinalización[0] === true) {
return ___τfinalización[1];
} else {
throw ___τfinalización[1];
}
}
})();
if (a > 0) {
___τfinalización = [true, a * 2];
} else {
___τfinalización = [true, a * 3];
}
}
//outer-catch-handle
if (___τfinalización[0] === false) {
let ___τcatch_clause_value = ___τfinalización[1];
{
let {
e
} = ___τcatch_clause_value;
console.log("unreachable");
}
} else {}
//outer-final-block
{
let arr = [a, a * 2, a * 3];
console.log(arr);
}
//out-tailized-completion-of-try-catch-final-stmt
if (___τfinalización[0] === undefined) {} else if (___τfinalización[0] === true) {
return ___τfinalización[1];
} else {
throw ___τfinalización[1];
}
}
let c = a * 3;
return c;
}
/*
> tst()
inner
[ 100, 200, 300 ]
2
>
*/
LICENSE
- ISC