How to use the @effectful/transducers.Tag.VariableDeclarator 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
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 {
              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);
            }
github awto / effectfuljs / packages / core / src / state.js View on Github external
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;
                  }
                }
                if (sl.cur().pos === Tag.init) {
                  asgn.push(...Kit.reposOne(sl.one(), Tag.right));
                  hasInit = true;
github awto / effectfuljs / packages / core / src / kit / snippets.js View on Github external
export function* openVarDecl(idNode, s, kind = "var") {
  const value =
    idNode.node === null
      ? { node: idNode, lhs: true, decl: true, rhs: false }
      : idNode;
  yield s.enter(Tag.init, Tag.VariableDeclaration, { node: { kind } });
  yield s.enter(Tag.declarations, Tag.Array);
  yield s.enter(Tag.push, Tag.VariableDeclarator);
  yield tok(Tag.id, Tag.Identifier, value);
}
github awto / effectfuljs / packages / core / src / state.js View on Github external
callee.value.isLocal = true;
                    callee.value.localFuncRef = callee.value;
                }
              }
            }
            break;
          case Tag.FunctionDeclaration:
            yield* s.one();
          case Tag.FunctionExpression:
            const j = s.curLev();
            if (j && j.pos === Tag.id) {
              j.value.source = i.value;
            }
            break;
          case Tag.AssignmentExpression:
          case Tag.VariableDeclarator:
            yield i;
            const first = [...s.one()];
            const l = s.curLev();
            if (l) first[0].value.source = l.value;
            yield* walk(s.one());
            yield* first;
            continue;
        }
      }
      yield i;
    }
  }
  return walk(s);