globalsIn

tcmts.cli.placement.globalsIn · #zrmiidob · term · runs anywhere

The globals ir's code uses as values: what's only named in types (el: Element) is erased, and doesn't run.

import type { IR } from "#codebase/tcmts/core/hash";
import { isErased } from "#codebase/tcmts/core/ir";

export function globalsIn(ir: IR, out = new Set<string>()): Set<string> {
  if (typeof ir === "string" || isErased(ir)) return out;
  if (ir[0] === "G" && typeof ir[1] === "string") out.add(ir[1]);
  else for (const c of ir) globalsIn(c, out);
  return out;
}

uses

used by