@mark1russell7/vex-compiler 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/facts.ts","../src/loop.ts","../src/tiers.ts","../src/module.ts","../src/runtime.ts"],"mappings":";;;KAgCY,aAAa;;;;;KAMb,OAAO;;;;;UAYF;WACN,SAAS,SAAS,eAAe;WACjC,OAAO,SAAS,eAAe;;;UAIzB;WACN,mBAAmB;WACnB,MAAM,SAAS,eAAe;WAC9B,aAAa,SAAS,eAAe;WACrC,SAAS;;;;;KCzCR;;KAeA;;KA2BA;WACG;WAAqB;;WACrB;WAAqB;;WACrB;WAAmB;;WACnB;WAAoB;;WACpB;;WACA;WAAqB,gBAAgB;;WACrC;WAAoB,IAAI;WAAiB,eAAe;;WACxD;WAAoB,IAAI;WAAoB,eAAe;;WAK3D;WAAkB;WAAuB,eAAe;WAAkB,iBAAiB;;WAE3F;WAAoB;;WAEpB;WAAuB;WAAuB,gBAAgB,OAAO,OAAO;;;;;;;;;;;KAW/E;WACG;;WACA;WAAwB;WAAwB;aAAoB,MAAM;aAAgB,MAAM;;;WAChG;WAAqB;;;KAGxB;WAEG;WAAmB;WAAoB,OAAO;;WAE9C;WAAmB;WAAoB,OAAO;;WAE9C;WAAqB,IAAI;WAAgB;WAAyB,MAAM;;WAExE;WAAoB,MAAM;;WAC1B;WAAkB,MAAM;WAAgB,cAAc;WAAkB,aAAa;;WAKrF;WAAoB;WAAwB;WAAuB;WAAwB;WAAwB,MAAM;WAAgB,eAAe;;WAExJ;WAAqB;WAAwB,eAAe;;WAE5D;WAAsB;WAAwB,eAAe;;WAE7D;;WAEA;WAAoB;WAAoB,OAAO;;WAC/C;WAAsB,OAAO;;;UAG3B;WACN,eAAe;WACf;;WAEA;;;;;KCrHC,kBAAkB;WAA4B,SAAS;;;;;;KAUvD;WACG;WAAmB,SAAS;WAAs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,SAAS,QAAQ,OAAO,UAAU,UAAS,kBAAuB;;;;;wBAkBlE,KAAK,WAAW,QAAQ;WAAsB;KAAc;;UAO3D;;WAEN;;WAEA;;;UAIM,sBAAsB;;WAE5B;;WAEA;WACA,OAAO;;;;;;;wBAQF,OAAO,QAAQ,OAAO,UAAU,UAAS,kBAAuB;;;;UCjD/D;WACN,mBAAmB;;WAEnB,QAAQ;;WAER;;;KAIC;WAAqB;WAAmB;;WAA8B;WAAoB;;;;;;;wBAwrDtF,WAAW,QAAQ,OAAO,UAAU,SAAS,gBAAgB;;;;qBC3rDhE;KACD,kBAAkB;;KAGlB,iBAAiB;;;;;;UAOZ;MACX;EACJ,GAAG;WACM,IAAI;WACJ,MAAM;;;KAIL,WAAW,QAAQ;WAAiB;;;UAG/B;WACN;WACA;;;UAIM;WACN;WACA;;;;;;UAOM;EACf,IAAI,GAAG,OAAO,2BAA2B;EACzC,IAAI,GAAG,OAAO,0BAA0B,YAAY,cAAc;;;UAgBnD;WACN,GAAG;EACZ,IAAI,GAAG,OAAO;;EAEd,KAAK,GAAG,OAAO,gBAAgB,eAAe,IAAI,MAAM;;;;;EAKxD,KAAK,MAAM,YAAY,GAAG,OAAO,gBAAgB,kBAAkB,UAAU;EAC7E,MAAM,QAAQ,SAAS,eAAe,qBAAqB;EAC3D,KAAK,GAAG;;EAER,KAAK,cAAc,gBAAgB;;EAEnC,QAAQ;;EAER,OAAO,gBAAgB;;EAEvB,MAAM,kBAAkB;EACxB,KAAK,cAAc,cAAc;EACjC,OAAO;EACP,KAAK;EACL,IAAI,0BAA0B;EAC9B,KAAK,yBAAyB;EAC9B,OAAO;EACP,IAAI,cAAc,eAAe,GAAG,OAAO,gBAAgB,eAAe;EAC1E,IAAI,MAAM,SAAS,sCAAsC;;;wBAI3C,cAAc,SAAS,iBAAiB"}
package/build/index.js CHANGED
@@ -10,21 +10,31 @@ import { MAX_NESTING, addrExprs, axisTargets, children, compile, findMethod, fix
10
10
  * twice doubles its body, so a chain of such functions grows fast. A module prints each function once.
11
11
  */
12
12
  const MAX_CALLS = 1e4;
13
- /** The list ops that give a list or read a position of a list (LIST.SORT, LIST.TAKE, LIST.NTH). */
13
+ /**
14
+ * The list ops that give a list, or read a position or a key of a list (LIST.SORT, LIST.TAKE, LIST.NTH, LIST.BUILD,
15
+ * LIST.GET).
16
+ */
14
17
  const ORDER_OPS = /* @__PURE__ */ new Set([
15
18
  "sortBy",
16
19
  "take",
17
- "nth"
20
+ "nth",
21
+ "drop",
22
+ "append",
23
+ "flat",
24
+ "without",
25
+ "get"
18
26
  ]);
19
27
  /**
20
- * This function gives the reason that tier 2 cannot take a program with lists as values. The reason is the axis `list`
21
- * or an op on the order of a list. Tier 1 evaluates such a program. It uses a stack, not recursion.
28
+ * This function gives the reason that tier 2 cannot take a program with lists as values. The reason is the axis `list`,
29
+ * an op on the order or the keys of a list, or a list literal. Tier 1 evaluates such a program. It uses a stack, not
30
+ * recursion.
22
31
  */
23
32
  function listReason(expr) {
24
33
  const todo = [expr];
25
34
  for (let x = todo.pop(); x !== void 0; x = todo.pop()) {
26
35
  if ((x.tag === "each" || x.tag === "fold") && listOf(x.axis) !== void 0) return "the program has the axis \"list\", and tier 2 does not have lists as values yet";
27
36
  if (x.tag === "app" && ORDER_OPS.has(x.op)) return `the program has the list op "${x.op}", and tier 2 does not have lists as values yet`;
37
+ if (x.tag === "lit" && isVexList(x.value)) return "the program has a list literal, and tier 2 does not have lists as values yet";
28
38
  todo.push(...children(x));
29
39
  }
30
40
  }
@@ -1324,6 +1334,11 @@ var Lowerer = class {
1324
1334
  case "sortBy":
1325
1335
  case "take":
1326
1336
  case "nth":
1337
+ case "drop":
1338
+ case "append":
1339
+ case "flat":
1340
+ case "without":
1341
+ case "get":
1327
1342
  /* v8 ignore next -- @preserve */
1328
1343
  throw new Unsupported(`the list op "${op}"`);
1329
1344
  }
@@ -2050,6 +2065,14 @@ const BOOLEAN_LIST_OPS = /* @__PURE__ */ new Set([
2050
2065
  "all",
2051
2066
  "none"
2052
2067
  ]);
2068
+ /** The list ops that build a list from lists (LIST.BUILD), and `get` (LIST.GET). A module gives a reason for them. */
2069
+ const BUILD_OPS = /* @__PURE__ */ new Set([
2070
+ "drop",
2071
+ "append",
2072
+ "flat",
2073
+ "without",
2074
+ "get"
2075
+ ]);
2053
2076
  /** This function gives the kind of the result of a list op: first gives the kind of its items. */
2054
2077
  const listKind = (op, item) => NUMBER_LIST_OPS.has(op) ? "number" : BOOLEAN_LIST_OPS.has(op) ? "boolean" : item;
2055
2078
  const LOOPS = /* @__PURE__ */ new WeakMap();
@@ -2921,6 +2944,7 @@ var Printer = class {
2921
2944
  const [head] = args;
2922
2945
  if (LIST_OPS.has(op) && head?.tag === "each") return this.#list(op, head, args.slice(1), ctx);
2923
2946
  if (head !== void 0 && (op === "sortBy" || op === "take")) return this.#order(op, head, args.slice(1), ctx);
2947
+ if (head !== void 0 && BUILD_OPS.has(op) && this.#isList(head, ctx)) throw new NotStandalone(`the list op "${op}" is not in a module yet`);
2924
2948
  if (head !== void 0 && (LIST_OPS.has(op) || op === "nth") && this.#isList(head, ctx)) return this.#overList(op, head, args.slice(1), ctx);
2925
2949
  const raw = args.map((x) => this.expr(x, ctx));
2926
2950
  const deps = depsOf(...raw);