import { argsCount } from "../errors.js"; export default { progn: ({ execute, data, target, nid, ctx }) => { if (data.length < 2) argsCount("progn", 1, data.pos); let newctx = ctx.nextLevel(); return { type: 0, code: `//new code Block ${data.array.slice(1).map(d => execute({ data: d, target, ctx: newctx })).join("\n")} //end Code Block` } }, if: ({ execute, data, target, nid, ctx }) => { if (data.length < 3) argsCount("if", 2, data.pos); let condition = execute({ data: data[1], target }); let id1 = nid(); let id2 = nid(); return { type: 0, code: `//if ${condition.code} BZ $${target},else${id1} ${execute({ data: data[2] }).code} ${data.length > 3 ? "JMP fi" + id2 : ""} else${id1} SWYM ${data.length > 3 ? execute({ data: data[2] }).code : ""} fi${id2} SWYM ` } }, };