How to use the @effectful/transducers.Tag.push 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 / state.js View on Github external
});
                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;
                  yield* sl.leave();
                }
                yield* lab();
              }

              for (const j of decls) if (j[1].raw != null) yield* j[1].raw;
              if (assigns.length) {
                for (const { sym, init } of assigns) {
                  yield sl.enter(Tag.push, Tag.ExpressionStatement);
                  yield sl.enter(Tag.expression, Tag.AssignmentExpression, {
                    node: { operator: "=" }
                  });
                  yield sl.tok(Tag.left, Tag.Identifier, {
                    sym,
                    lhs: true,
                    rhs: false,
                    decl: false
                  });
                  yield* init;
                  yield* sl.leave();
                  yield* sl.leave();
                }
              }
              // babel's hoist re-hack
              if (i.value.babelHoistReHack) {
github awto / effectfuljs / packages / core / src / state.js View on Github external
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;
                  yield* sl.leave();
                }
                yield* lab();
              }

              for (const j of decls) if (j[1].raw != null) yield* j[1].raw;
              if (assigns.length) {
                for (const { sym, init } of assigns) {
                  yield sl.enter(Tag.push, Tag.ExpressionStatement);
                  yield sl.enter(Tag.expression, Tag.AssignmentExpression, {
                    node: { operator: "=" }
                  });
                  yield sl.tok(Tag.left, Tag.Identifier, {
                    sym,
github awto / effectfuljs / packages / core / src / state.js View on Github external
yield i;
              yield m;
              continue;
            }
            yield i;
            yield s.enter(Tag.callee, Tag.MemberExpression);
            yield s.enter(Tag.object, Tag.MemberExpression, m.value);
            yield* walk();
            yield* s.leave();
            s.close(m);
            yield s.tok(Tag.property, Tag.Identifier, {
              node: { name: "call" }
            });
            yield* s.leave();
            yield* s.till(i => i.pos === Tag.arguments);
            yield s.tok(Tag.push, Tag.Identifier, {
              sym: thisSym,
              lhs: false,
              rhs: true,
              decl: false
            });
            continue;
          case Tag.Super:
            if (!root.ref) break;
            let classSym = root.ref.classId;
            if (!classSym) classSym = root.ref.classId = Kit.scope.newSym("C");
            yield* s.toks(
              i.pos,
              static_
                ? "=$1.getPrototypeOf($2.prototype)"
                : "=$1.getPrototypeOf($2.prototype)",
              Kit.scope.ObjectSym,
github awto / effectfuljs / packages / core / src / state.js View on Github external
yield* sl.leave();
              yield* sl.leave();
              continue;
            case Tag.FunctionDeclaration:
              const old = decls.get(i.value.funcId);
              const init = [
                ...sl.copy(
                  Kit.setType(Kit.setPos(i, Tag.init), Tag.FunctionExpression)
                )
              ];
              if (old)
                old.init = old.init
                  ? [
                      sl.enter(Tag.init, Tag.SequenceExpression),
                      sl.enter(Tag.expressions, Tag.Array),
                      ...Kit.reposOneArr(old.init, Tag.push),
                      ...Kit.reposOneArr(init, Tag.push),
                      ...sl.leave(),
                      ...sl.leave()
                    ]
                  : init;
              else
                decls.set(i.value.funcId, {
                  raw: null,
                  init
                });
              if (i.value.wrapId) i.value.funcId = i.value.wrapId;
              continue;
            case Tag.TryStatement:
              if (!i.value.eff) {
                yield i;
                yield* _saveDecls(true);
github awto / effectfuljs / packages / core / src / state.js View on Github external
const { sym } = j.value;
                      if (!decls.has(sym)) decls.set(sym, { raw: null });
                      j.value.lhs = true;
                      j.value.rhs = false;
                      j.value.decl = false;
                    }
                    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;
              }
github awto / effectfuljs / packages / core / src / control.js View on Github external
if (i.enter) {
                    let pos = i.pos;
                    const { ctrlNode } = i.value.block;
                    const j = s.enter(pos, jump, {
                      bind: true,
                      ctrlNode,
                      result:
                        i.type === Tag.ReturnStatement && s.curLev() != null,
                      orig: i.value
                    });
                    if (ctrlNode)
                      (ctrlNode.brkRefs || (ctrlNode.brkRefs = [])).push(
                        j.value
                      );
                    yield j;
                    yield* Kit.reposOne(s.sub(), Tag.push);
                    yield* s.leave();
                    s.close(i);
                    continue;
                  }
                }
            }
          }
          yield i;
        }
      },
      Policy.stage("after-control-jumps")
github awto / effectfuljs / packages / core / src / debug.js View on Github external
}
            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;
        }
      }
    }
    yield* walk();