Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
yield D.copyComment(
i,
D.setComment(
Kit.enter(i.pos, Tag.ExpressionStatement, {
node: {},
eff: i.value.eff
}),
"S",
"font-size:xx-large;color:orange"
)
);
yield Kit.enter(Tag.expression, Kit.Subst);
}
}
if (i.leave) yield* Kit.repeat(hasBind ? 4 : 2, Kit.leave());
init.push(
sl.enter(Tag.object, Tag.MemberExpression),
sl.tok(Tag.object, Tag.Identifier, { sym: ctx }),
sl.tok(Tag.property, Tag.Identifier, {
node: { name: fld.subField }
}),
...sl.leave()
);
} else init.push(sl.tok(Tag.object, Tag.Identifier, { sym: ctx }));
init.push(
sl.tok(Tag.property, Tag.Identifier, {
node: { name: fld.fieldName }
}),
...sl.leave()
);
} else init.push(sl.tok(Tag.init, Tag.Identifier, { sym: fld }));
} else {
const pos = varField ? Tag.object : Tag.init;
init.push(sl.tok(pos, Tag.Identifier, { sym: ctx }));
if (varField) {
init.unshift(sl.enter(Tag.init, Tag.MemberExpression));
init.push(
sl.tok(Tag.property, Tag.Identifier, {
node: { name: root.opts.varStorageField }
}),
...sl.leave()
);
}
}
if (closConv && !closField) {
saved.set(copy, {
raw: null,
const static_ = root.node && root.node.static;
if (!usesThis && !usesArgs) return sa;
let storeRoot = root;
while (storeRoot && storeRoot.origType === Tag.ArrowFunctionExpression)
storeRoot = storeRoot.parentScope;
if (!storeRoot) return sa;
const decls = storeRoot.savedDecls || (storeRoot.savedDecls = new Map());
let thisSym;
if (usesThis) {
thisSym = storeRoot.thisSym;
if (!thisSym) {
thisSym = storeRoot.thisSym = Bind.tempVarSym(storeRoot, "_this");
thisSym.singleAssign = true;
decls.set(thisSym, {
raw: null,
init: [s.tok(Tag.init, Tag.ThisExpression)]
});
storeRoot.scopeDecls.add(thisSym);
}
if (storeRoot !== root) {
thisSym.closCapt = true;
(thisSym.refScopes || (thisSym.refScopes = new Set())).add(root);
root.scopeCapt.add(thisSym);
}
}
let argsSym;
if (usesArgs) {
argsSym = storeRoot.argsSym;
if (!argsSym) {
argsSym = storeRoot.argsSym = Bind.tempVarSym(storeRoot, "_args");
decls.set(argsSym, {
raw: null,
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 = [];
const stmt = i.pos !== Tag.init && i.pos !== Tag.left;
sl.peel(i);
sl.peel();
for (const j of sl.sub()) {
invariant(j.enter);
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;
invariant(j.enter);
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;