prebirth: Wrap `if' applications
* build-aux/bootstrap/prebirth.js (fnmap)[if]: Wrap generated code in self-executing function.master
parent
dcc6aed322
commit
59daf7a5b5
|
@ -543,10 +543,13 @@ class Compiler
|
||||||
const fnmap = {
|
const fnmap = {
|
||||||
'js:console': 'console.log',
|
'js:console': 'console.log',
|
||||||
|
|
||||||
// simple if statement with optional else
|
// simple if statement with optional else, wrapped in a self-executing
|
||||||
|
// function to simplify code generation (e.g. returning an if)
|
||||||
'if': ( [ pred, t, f ], stoes ) =>
|
'if': ( [ pred, t, f ], stoes ) =>
|
||||||
`if (${stoes(pred)}) {${stoes(t)};} ` +
|
"(function(){" +
|
||||||
( ( f === undefined ) ? '' : `else {${stoes(f)};}` ),
|
`if (${stoes(pred)}){return ${stoes(t)};}` +
|
||||||
|
( ( f === undefined ) ? '' : `else{return ${stoes(f)};}` ) +
|
||||||
|
"})()",
|
||||||
|
|
||||||
// (let ((binding val) ...) ...body), compiled as a self-executing
|
// (let ((binding val) ...) ...body), compiled as a self-executing
|
||||||
// function which allows us to easily represent the return value of the
|
// function which allows us to easily represent the return value of the
|
||||||
|
|
Loading…
Reference in New Issue