Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (funcId) {
const copy = Kit.scope.newSym(funcId.orig);
copy.num = -copy.num;
copy.strict = true;
funcId.strict = false;
i.value.funcAlias = copy;
if (
funcId.interpr === Bind.ctxField &&
funcId.declScope === i.value &&
// funcId.hasReads
((noOpts && funcId.bound) || funcId.hasReads)
) {
assigns.push({
sym: funcId,
init: [
sl.tok(Tag.right, Tag.Identifier, {
sym: copy,
lhs: false,
rhs: true,
decl: false
})
]
});
}
// this makes more likely for the function to have same name
}
decls.push(
...[...i.value.savedDecls].sort((a, b) => a[0].num - b[0].num)
);
const vars = [];
const raw = [];
if (i.value.paramSyms) {
yield* s.template(
Tag.push,
`=${i.value.sym ? "$I =" : ""}` +
`${i.value.bindName || (i.value.eff ? "e" : "p")}` +
`(${i.value.tmpVar ? "$I=" : ""}` +
`$E${i.value.goto ? "," + i.value.goto.declSym.id : ""}` +
`${
i.value.indirGoto ? "," + i.value.indirGoto.declSym.id : ""
}` +
`,${i.value.id})`,
...args
);
if (!i.leave)
yield* Kit.reposOne(
_frame(),
i.value.tmpVar ? Tag.right : Tag.push
);
yield* s.leave();
}
s.close(i);
continue;
case "jump":
{
const args = [];
if (i.value.tmpVar) args.push(i.value.tmpVar);
if (i.value.goto) args.push(i.value.goto.declSym);
yield* s.template(
Tag.push,
`=${i.value.tmpVar ? "$I =" : ""}` +
`j($E${i.value.goto ? "," + i.value.goto.declSym.id : ""}` +
`${
i.value.indirGoto ? "," + i.value.indirGoto.declSym.id : ""
}
ids.push(j);
}
const sym = Bind.tempVarSym(top.value, "ex");
const lab = sl.label();
yield sl.peel(i);
yield sl.tok(Tag.param, Tag.Identifier, { sym });
yield sl.peel();
yield* sl.peelTo(Tag.body);
const blab = sl.label();
yield sl.enter(Tag.push, Tag.ExpressionStatement);
yield sl.enter(Tag.expression, Tag.AssignmentExpression, {
node: { operator: "=" }
});
yield* Kit.reposOne(ids, Tag.left);
yield sl.tok(Tag.right, Tag.Identifier, {
sym,
lhs: false,
rhs: true,
decl: false
});
yield* blab();
yield* _saveDecls();
yield* lab();
}
continue;
}
break;
case Tag.VariableDeclaration:
const kind = i.value.node.kind;
i.value.node.kind = "var";
const declarators = [];
invariant(j.type === Tag.VariableDeclarator);
let hasInit = false;
const asgn = [];
const id = [...sl.one()];
asgn.push(...id);
for (const j of id) {
if (j.enter && j.type === Tag.Identifier && j.value.decl) {
const sym = j.value.sym;
if (!sym.noDecl && !decls.has(sym)) {
decls.set(sym, { raw: null, node: j.value.node });
}
j.value.decl = false;
}
}
if (sl.cur().pos === Tag.init) {
asgn.push(...Kit.reposOne(sl.one(), Tag.right));
hasInit = true;
} else if (kind === "let" && i.pos !== Tag.left) {
asgn.push(
sl.tok(Tag.right, Tag.Identifier, {
sym: Kit.scope.undefinedSym
})
);
hasInit = true;
}
if (hasInit) {
id[0].pos = id[id.length - 1].pos = Tag.left;
declarators.push(asgn);
} else {
if (i.pos === Tag.left) {
id[0].pos = id[id.length - 1].pos = i.pos;
yield* id;
asgn.push(...id);
for (const j of id) {
if (j.enter && j.type === Tag.Identifier && j.value.decl) {
const sym = j.value.sym;
if (!sym.noDecl && !decls.has(sym)) {
decls.set(sym, { raw: null, node: j.value.node });
}
j.value.decl = false;
}
}
if (sl.cur().pos === Tag.init) {
asgn.push(...Kit.reposOne(sl.one(), Tag.right));
hasInit = true;
} else if (kind === "let" && i.pos !== Tag.left) {
asgn.push(
sl.tok(Tag.right, Tag.Identifier, {
sym: Kit.scope.undefinedSym
})
);
hasInit = true;
}
if (hasInit) {
id[0].pos = id[id.length - 1].pos = Tag.left;
declarators.push(asgn);
} else {
if (i.pos === Tag.left) {
id[0].pos = id[id.length - 1].pos = i.pos;
yield* id;
} else yield sl.tok(i.pos, Tag.Null);
}
sl.close(j);
}
})
]
});
}
}
}
for (const [k, v] of decls) {
if (k.removed) continue;
if (v.raw) raw.push(v);
else {
v.sym = k;
if (k.interpr === Bind.ctxField || k.param) {
if (v.init) {
assigns.push({
sym: k,
init: Kit.reposOneArr(v.init, Tag.right)
});
}
} else vars.push(v);
}
}
if (vars.length) {
const lab = sl.label();
yield sl.enter(Tag.push, Tag.VariableDeclaration, {
node: { kind: "var" }
});
yield sl.enter(Tag.declarations, Tag.Array);
for (const { sym, init } of vars) {
if (sym.substSym) continue;
yield sl.enter(Tag.push, Tag.VariableDeclarator);
yield sl.tok(Tag.id, Tag.Identifier, { sym, decl: true });
if (init) yield* init;