Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function* debDumbBindStmt(s) {
for (const i of s) {
switch (symName(i.type)) {
case "letStmt":
const hasBind = i.value.sym != null;
if (i.enter) {
if (hasBind) {
yield D.copyComment(
i,
D.setComment(
Kit.enter(i.pos, Tag.VariableDeclaration, {
node: {
kind: "var"
// kind:"const"
},
eff: i.value.eff
}),
"S",
"font-size:xx-large;color:orange"
)
);
yield Kit.enter(Tag.declarations, Tag.Array);
yield Kit.enter(Tag.push, Tag.VariableDeclarator);
yield Kit.tok(Tag.id, Tag.Identifier, { sym: i.value.sym });
yield Kit.enter(Tag.init, Kit.Subst);
} else {
res += i.bound ? "+" : "-";
}
return res;
}
for (let i of s) {
if (i.enter) {
if (i.pos === Tag.top) {
let txt = "";
if (i.value.savedDecls)
txt += `|decls:[${[...i.value.savedDecls.keys()].map(id).join(",")}]`;
if (i.value.errSym) txt += `|errSym:[${id(i.value.errSym)}]`;
if (i.value.resSym) txt += `|resSym:[${id(i.value.resSym)}]`;
i = D.setComment(i, txt, "hl");
}
const v = i.value;
if (v.funcId) i = D.setComment(i, `${v.funcId.id}`, "hl");
if (v.sym) {
i = D.setComment(i, `[${id(v.sym)}]`, "hl");
}
if (v.declSym != null) {
let hndl = "";
if (v.repeatStart) hndl += "|Repeat";
if (v.catchCont) {
if (v.catchCont.goto)
hndl += `|Err{${
v.catchCont.errSym ? id(v.catchCont.errSym) : "?"
}<-${id(v.catchCont.goto.declSym)}}`;
hndl += v.catchCont.frameArgs
? `|ErrArgs{${[...v.catchCont.frameArgs]
.map(([k, v]) => `${id(k)}=${id(v)}`)
.join()}}`
: "";
function hls(t, e, n) {
return D.setComment(e, t, `small${n || ""}`);
}
function hl(t, e, style) {
return D.setComment(e, t, style || "large");
}
(s.has(i) ? "!" : "") +
(d.has(i) ? "d" : "") +
(saved.has(i) ? "D" : "") +
(i === v.sym ? "S" : "") +
(!clos.has(i) && dst.has(i) ? "C" : "") +
(i === v.errSym ? "E" : "") +
(i === v.patSym ? "B" : ":")
)
.join()}}`
: "";
i = D.setComment(
i,
`label{${id(v.declSym)}}${paramStr}${hndl}${fin}`,
"hl"
);
if (i.dstClass) i = D.setComment(i, `class{${id(i.dstClass.declSym)}}`);
}
if (symName(i.type) === "letStmt" || symName(i.type) === "jump") {
let fin =
v.preCompose && v.preCompose.length
? `|Pre{${v.preCompose
.map(
i =>
id(i.declSym) +
"->" +
(i.contArg ? id(i.contArg.declSym) : "")
)
.join()}}`
: "";
let args = v.frameArgs
? `|Args{${[...v.frameArgs]
.map(([k, v]) => `${id(k)}=${id(v)}`)
yield b.enter(Tag.push, Kit.Subst);
yield* walk();
yield* b.leave();
yield* b.leave();
yield* b.leave();
}
break;
case "frame":
if (i.enter) {
const lab = b.label();
let txt = `#${(i.value.patSym && i.value.patSym.id) || ""}`;
if (i.value.bindsResult) txt += "_";
if (i.value.hasStmts) txt += "=";
yield D.copyComment(
i,
D.setComment(
b.enter(i.pos, Tag.BlockStatement),
txt,
"color:blue;font-size:large"
)
);
yield b.enter(Tag.body, Tag.Array);
yield b.enter(Tag.push, Kit.Subst);
yield* walk();
yield* lab();
}
break;
default:
if (i.type.ctrl) {
if (i.type.arg === "b") {
if (i.enter) {
yield D.copyComment(
? `|Thread{${v.threadArgs
.map(i => id(i[0]) + "<-" + id(i[1]))
.join()}}`
: "";
let dst = v.goto ? v.goto.declSym.id : "EXIT";
if (v.goto && v.goto.instances) {
const inst = [...v.goto.instances].map(i => id(i.declSym)).join();
dst = `|${dst}<${inst}>`;
}
if (v.indirGoto) dst = `${dst}~>${v.indirGoto.declSym.id}`;
let name = v.result ? "ret" : "goto";
if (v.ext) name += `.X-${v.ext.funcId.id}`;
if (v.tmpVar) name += `.T-${v.tmpVar.id}`;
if (v.contextSym) name += `.S-${v.contextSym.id}`;
i = D.setComment(
i,
`${name}[${dst}${args}${thread}${fin}]#${i.value.id || "u"}`,
"hl"
);
}
}
yield i;
}
}
if (i.numConst) res += `$${i.numConst}`;
if (i.dummy) res += ".dummy";
if (i.bound != null) {
res += i.bound ? "+" : "-";
}
return res;
}
for (let i of s) {
if (i.enter) {
if (i.pos === Tag.top) {
let txt = "";
if (i.value.savedDecls)
txt += `|decls:[${[...i.value.savedDecls.keys()].map(id).join(",")}]`;
if (i.value.errSym) txt += `|errSym:[${id(i.value.errSym)}]`;
if (i.value.resSym) txt += `|resSym:[${id(i.value.resSym)}]`;
i = D.setComment(i, txt, "hl");
}
const v = i.value;
if (v.funcId) i = D.setComment(i, `${v.funcId.id}`, "hl");
if (v.sym) {
i = D.setComment(i, `[${id(v.sym)}]`, "hl");
}
if (v.declSym != null) {
let hndl = "";
if (v.repeatStart) hndl += "|Repeat";
if (v.catchCont) {
if (v.catchCont.goto)
hndl += `|Err{${
v.catchCont.errSym ? id(v.catchCont.errSym) : "?"
}<-${id(v.catchCont.goto.declSym)}}`;
hndl += v.catchCont.frameArgs
? `|ErrArgs{${[...v.catchCont.frameArgs]
"color:blue;font-size:large"
)
);
yield b.enter(Tag.arguments, Tag.Array);
yield b.enter(Tag.push, Kit.Subst);
yield* walk();
yield* b.leave();
yield* b.leave();
yield* b.leave();
}
break;
case "forPar":
if (i.enter) {
yield D.copyComment(
i,
D.setComment(
b.enter(i.pos, Tag.ArrowFunctionExpression, {
node: { params: [] }
}),
`PAR`,
"color:blue;font-size:large"
)
);
yield b.enter(Tag.body, Tag.ForStatement);
yield* walk();
yield* b.leave();
yield* b.leave();
}
break;
case "effExpr":
if (i.enter) {
yield b.enter(i.pos, Kit.Subst);
"color:blue;font-size:large"
)
);
yield b.enter(Tag.body, Tag.Array);
yield b.enter(Tag.push, Kit.Subst);
yield* walk();
yield* lab();
}
break;
default:
if (i.type.ctrl) {
if (i.type.arg === "b") {
if (i.enter) {
yield D.copyComment(
i,
D.setComment(
b.enter(i.pos, Tag.BlockStatement),
symName(i.type),
"color:blue;font-size:large"
)
);
yield b.enter(Tag.body, Tag.Array);
yield b.enter(Tag.push, Kit.Subst);
yield* walk();
yield* b.leave();
yield* b.leave();
yield* b.leave();
}
break;
}
}
yield i;