How to use the @effectful/transducers/dump.setComment function in @effectful/transducers

To help you get started, we’ve selected a few @effectful/transducers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awto / effectfuljs / packages / core / src / debug.js View on Github external
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 {
github awto / effectfuljs / packages / core / src / debug.js View on Github external
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()}}`
            : "";
github awto / effectfuljs / packages / core / src / debug.js View on Github external
function hls(t, e, n) {
  return D.setComment(e, t, `small${n || ""}`);
}
github awto / effectfuljs / packages / core / src / debug.js View on Github external
function hl(t, e, style) {
  return D.setComment(e, t, style || "large");
}
github awto / effectfuljs / packages / core / src / debug.js View on Github external
(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)}`)
github awto / effectfuljs / packages / core / src / debug.js View on Github external
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(
github awto / effectfuljs / packages / core / src / debug.js View on Github external
? `|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;
  }
}
github awto / effectfuljs / packages / core / src / debug.js View on Github external
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]
github awto / effectfuljs / packages / core / src / debug.js View on Github external
"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);
github awto / effectfuljs / packages / core / src / debug.js View on Github external
"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;