@elaraai/east 0.0.1-beta.2 → 0.0.1-beta.21

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.
Files changed (110) hide show
  1. package/LICENSE.md +15 -666
  2. package/README.md +30 -8
  3. package/dist/src/ast_to_ir.d.ts +6 -0
  4. package/dist/src/ast_to_ir.d.ts.map +1 -1
  5. package/dist/src/ast_to_ir.js +33 -1
  6. package/dist/src/ast_to_ir.js.map +1 -1
  7. package/dist/src/builtins.d.ts +1 -1
  8. package/dist/src/builtins.d.ts.map +1 -1
  9. package/dist/src/builtins.js +10 -0
  10. package/dist/src/builtins.js.map +1 -1
  11. package/dist/src/comparison.d.ts.map +1 -1
  12. package/dist/src/comparison.js +12 -4
  13. package/dist/src/comparison.js.map +1 -1
  14. package/dist/src/compile.d.ts +7 -1
  15. package/dist/src/compile.d.ts.map +1 -1
  16. package/dist/src/compile.js +219 -172
  17. package/dist/src/compile.js.map +1 -1
  18. package/dist/src/eastir.d.ts.map +1 -1
  19. package/dist/src/eastir.js +21 -5
  20. package/dist/src/eastir.js.map +1 -1
  21. package/dist/src/error.d.ts +4 -0
  22. package/dist/src/error.d.ts.map +1 -1
  23. package/dist/src/error.js +20 -0
  24. package/dist/src/error.js.map +1 -1
  25. package/dist/src/expr/array.d.ts +101 -1
  26. package/dist/src/expr/array.d.ts.map +1 -1
  27. package/dist/src/expr/array.js +149 -0
  28. package/dist/src/expr/array.js.map +1 -1
  29. package/dist/src/expr/blob.d.ts +65 -1
  30. package/dist/src/expr/blob.d.ts.map +1 -1
  31. package/dist/src/expr/blob.js +80 -1
  32. package/dist/src/expr/blob.js.map +1 -1
  33. package/dist/src/expr/block.d.ts +23 -3
  34. package/dist/src/expr/block.d.ts.map +1 -1
  35. package/dist/src/expr/block.js +28 -3
  36. package/dist/src/expr/block.js.map +1 -1
  37. package/dist/src/expr/boolean.d.ts +36 -0
  38. package/dist/src/expr/boolean.d.ts.map +1 -1
  39. package/dist/src/expr/boolean.js +41 -0
  40. package/dist/src/expr/boolean.js.map +1 -1
  41. package/dist/src/expr/datetime.d.ts +107 -0
  42. package/dist/src/expr/datetime.d.ts.map +1 -1
  43. package/dist/src/expr/datetime.js +119 -0
  44. package/dist/src/expr/datetime.js.map +1 -1
  45. package/dist/src/expr/dict.d.ts +34 -0
  46. package/dist/src/expr/dict.d.ts.map +1 -1
  47. package/dist/src/expr/dict.js +39 -0
  48. package/dist/src/expr/dict.js.map +1 -1
  49. package/dist/src/expr/expr.d.ts.map +1 -1
  50. package/dist/src/expr/expr.js.map +1 -1
  51. package/dist/src/expr/float.d.ts +107 -0
  52. package/dist/src/expr/float.d.ts.map +1 -1
  53. package/dist/src/expr/float.js +122 -0
  54. package/dist/src/expr/float.js.map +1 -1
  55. package/dist/src/expr/function.d.ts +9 -2
  56. package/dist/src/expr/function.d.ts.map +1 -1
  57. package/dist/src/expr/function.js.map +1 -1
  58. package/dist/src/expr/index.d.ts +40 -1
  59. package/dist/src/expr/index.d.ts.map +1 -1
  60. package/dist/src/expr/index.js +39 -1
  61. package/dist/src/expr/index.js.map +1 -1
  62. package/dist/src/expr/integer.d.ts +107 -0
  63. package/dist/src/expr/integer.d.ts.map +1 -1
  64. package/dist/src/expr/integer.js +119 -0
  65. package/dist/src/expr/integer.js.map +1 -1
  66. package/dist/src/expr/libs/integer.d.ts +19 -0
  67. package/dist/src/expr/libs/integer.d.ts.map +1 -1
  68. package/dist/src/expr/libs/integer.js +47 -0
  69. package/dist/src/expr/libs/integer.js.map +1 -1
  70. package/dist/src/expr/set.d.ts +36 -2
  71. package/dist/src/expr/set.d.ts.map +1 -1
  72. package/dist/src/expr/set.js +41 -2
  73. package/dist/src/expr/set.js.map +1 -1
  74. package/dist/src/expr/string.d.ts +106 -0
  75. package/dist/src/expr/string.d.ts.map +1 -1
  76. package/dist/src/expr/string.js +119 -0
  77. package/dist/src/expr/string.js.map +1 -1
  78. package/dist/src/expr/struct.d.ts.map +1 -1
  79. package/dist/src/expr/types.d.ts +6 -6
  80. package/dist/src/expr/types.d.ts.map +1 -1
  81. package/dist/src/expr/variant.d.ts +115 -1
  82. package/dist/src/expr/variant.d.ts.map +1 -1
  83. package/dist/src/expr/variant.js +53 -0
  84. package/dist/src/expr/variant.js.map +1 -1
  85. package/dist/src/internal.d.ts +8 -0
  86. package/dist/src/internal.d.ts.map +1 -1
  87. package/dist/src/internal.js +8 -0
  88. package/dist/src/internal.js.map +1 -1
  89. package/dist/src/serialization/beast.d.ts.map +1 -1
  90. package/dist/src/serialization/beast.js +53 -18
  91. package/dist/src/serialization/beast.js.map +1 -1
  92. package/dist/src/serialization/beast2.d.ts +39 -3
  93. package/dist/src/serialization/beast2.d.ts.map +1 -1
  94. package/dist/src/serialization/beast2.js +132 -18
  95. package/dist/src/serialization/beast2.js.map +1 -1
  96. package/dist/src/serialization/csv.d.ts +139 -0
  97. package/dist/src/serialization/csv.d.ts.map +1 -0
  98. package/dist/src/serialization/csv.js +615 -0
  99. package/dist/src/serialization/csv.js.map +1 -0
  100. package/dist/src/serialization/index.d.ts +2 -1
  101. package/dist/src/serialization/index.d.ts.map +1 -1
  102. package/dist/src/serialization/index.js +2 -1
  103. package/dist/src/serialization/index.js.map +1 -1
  104. package/dist/src/type_of_type.d.ts +11 -0
  105. package/dist/src/type_of_type.d.ts.map +1 -1
  106. package/dist/src/type_of_type.js +61 -0
  107. package/dist/src/type_of_type.js.map +1 -1
  108. package/dist/src/types.js +4 -4
  109. package/dist/src/types.js.map +1 -1
  110. package/package.json +4 -4
@@ -11,13 +11,18 @@ import { EastError } from "./error.js";
11
11
  import { SortedSet } from "./containers/sortedset.js";
12
12
  import { SortedMap } from "./containers/sortedmap.js";
13
13
  import { BufferWriter } from "./serialization/binary-utils.js";
14
- import { decodeBeast2For, decodeBeastFor, encodeBeast2For, encodeBeastFor, fromJSONFor, toJSONFor } from "./serialization/index.js";
14
+ import { decodeBeast2For, decodeBeastFor, encodeBeast2For, encodeBeastFor, fromJSONFor, toJSONFor, decodeCsvFor, encodeCsvFor } from "./serialization/index.js";
15
15
  import { formatDateTime } from "./datetime_format/print.js";
16
16
  import { parseDateTimeFormatted } from "./datetime_format/parse.js";
17
17
  import { EastTypeValueType, isTypeValueEqual, expandTypeValue } from "./type_of_type.js";
18
18
  import { ref } from "./containers/ref.js";
19
19
  export { isTypeValueEqual };
20
20
  export const printTypeValue = printFor(EastTypeValueType);
21
+ /**
22
+ * Symbol used to attach source IR to compiled functions.
23
+ * This enables serialization of free functions (functions with no captures).
24
+ */
25
+ export const EAST_IR_SYMBOL = Symbol.for("east.ir");
21
26
  /** @internal Track iteration locks to prevent concurrent modification */
22
27
  const iterationLocks = new WeakMap();
23
28
  /** @internal Lock a collection for iteration (prevents size/keyset modifications) */
@@ -63,7 +68,7 @@ class BreakException {
63
68
  *
64
69
  * @internal
65
70
  */
66
- export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx = true, compilingNodes = new Set()) {
71
+ export function compile_internal(ir, ctx, platform, asyncPlatformFns, platformDef, fresh_ctx = true, compilingNodes = new Set()) {
67
72
  // The IR is checked prior to compilation, so we can assume it's valid here.
68
73
  // The compiler needs to take care that Promises are properly awaited, so most IR nodes need both sync and async implementations.
69
74
  // We assume unnecessary `async` functions degrade performance but unnecessary `await`s are not too bad, so while we could be more "specific" in our awaits we do not bother
@@ -73,7 +78,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
73
78
  return (_ctx) => v;
74
79
  }
75
80
  else if (ir.type === "Error") {
76
- const message_compiled = compile_internal(ir.value.message, ctx, platform, asyncPlatformFns, false, compilingNodes);
81
+ const message_compiled = compile_internal(ir.value.message, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
77
82
  const location = ir.value.location;
78
83
  if (ir.value.isAsync) {
79
84
  return async (ctx) => { throw new EastError(await message_compiled(ctx), { location: location }); };
@@ -83,15 +88,15 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
83
88
  }
84
89
  }
85
90
  else if (ir.type === "TryCatch") {
86
- const try_body = compile_internal(ir.value.try_body, Object.create(ctx), platform, asyncPlatformFns, true, compilingNodes);
91
+ const try_body = compile_internal(ir.value.try_body, Object.create(ctx), platform, asyncPlatformFns, platformDef, true, compilingNodes);
87
92
  const new_ctx = Object.create(ctx);
88
93
  const message_name = ir.value.message.value.name;
89
94
  const stack_name = ir.value.stack.value.name;
90
95
  new_ctx[message_name] = ir.value.message.value.type;
91
96
  new_ctx[stack_name] = ir.value.stack.value.type;
92
- const catch_body = compile_internal(ir.value.catch_body, new_ctx, platform, asyncPlatformFns, true, compilingNodes);
97
+ const catch_body = compile_internal(ir.value.catch_body, new_ctx, platform, asyncPlatformFns, platformDef, true, compilingNodes);
93
98
  // Don't include finally unless necessary (Value nodes are effect free)
94
- const finally_body = ir.value.finally_body.type === "Value" ? undefined : compile_internal(ir.value.finally_body, Object.create(ctx), platform, asyncPlatformFns, true, compilingNodes);
99
+ const finally_body = ir.value.finally_body.type === "Value" ? undefined : compile_internal(ir.value.finally_body, Object.create(ctx), platform, asyncPlatformFns, platformDef, true, compilingNodes);
95
100
  if (ir.value.isAsync) {
96
101
  if (finally_body === undefined) {
97
102
  return async (ctx) => {
@@ -185,7 +190,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
185
190
  }
186
191
  }
187
192
  else if (ir.type === "Let") {
188
- const compiled_statement = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
193
+ const compiled_statement = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
189
194
  const name = ir.value.variable.value.name;
190
195
  ctx[name] = ir.value.variable.value.type;
191
196
  if (ir.value.variable.value.mutable && ir.value.variable.value.captured) {
@@ -219,7 +224,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
219
224
  }
220
225
  else if (ir.type === "Assign") {
221
226
  const name = ir.value.variable.value.name;
222
- const compiled_statement = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
227
+ const compiled_statement = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
223
228
  if (ir.value.variable.value.mutable && ir.value.variable.value.captured) {
224
229
  if (ir.value.isAsync) {
225
230
  return async (ctx) => {
@@ -262,17 +267,17 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
262
267
  else if (ir.type === "As") {
263
268
  // in dynamically typed runtimes like Javascript, this is a no-op
264
269
  // (for statically typed runtimes this assists in unifying types in branches)
265
- return compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, fresh_ctx, compilingNodes);
270
+ return compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, fresh_ctx, compilingNodes);
266
271
  }
267
272
  else if (ir.type === "UnwrapRecursive") {
268
273
  // in dynamically typed runtimes like Javascript, this is a no-op
269
274
  // (for statically typed runtimes this assists in e.g. typing a reference or pointer)
270
- return compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, fresh_ctx, compilingNodes);
275
+ return compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, fresh_ctx, compilingNodes);
271
276
  }
272
277
  else if (ir.type === "WrapRecursive") {
273
278
  // in dynamically typed runtimes like Javascript, this is a no-op
274
279
  // (for statically typed runtimes this assists in e.g. typing a heap allocation)
275
- return compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
280
+ return compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
276
281
  }
277
282
  else if (ir.type === "Function") {
278
283
  const ctx2 = {};
@@ -283,19 +288,29 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
283
288
  const parameter_name = parameter.value.name;
284
289
  ctx2[parameter_name] = parameter.value.type;
285
290
  }
286
- const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
291
+ const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
287
292
  const capture_names = ir.value.captures.map(v => v.value.name);
288
293
  const parameter_names = ir.value.parameters.map(v => v.value.name);
294
+ // Store original IR for potential serialization
295
+ const originalIR = ir;
289
296
  return (ctx) => {
290
297
  const ctx2 = {};
291
298
  for (const name of capture_names) {
292
299
  ctx2[name] = ctx[name];
293
300
  }
294
- return (...args) => {
301
+ const fn = (...args) => {
295
302
  const ctx3 = { ...ctx2 };
296
303
  parameter_names.forEach((name, i) => ctx3[name] = args[i]);
297
304
  return compiled_body(ctx3);
298
305
  };
306
+ // Attach IR to function for serialization support
307
+ Object.defineProperty(fn, EAST_IR_SYMBOL, {
308
+ value: originalIR,
309
+ writable: false,
310
+ enumerable: false,
311
+ configurable: false
312
+ });
313
+ return fn;
299
314
  };
300
315
  }
301
316
  else if (ir.type === "AsyncFunction") {
@@ -307,24 +322,34 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
307
322
  const parameter_name = parameter.value.name;
308
323
  ctx2[parameter_name] = parameter.value.type;
309
324
  }
310
- const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
325
+ const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
311
326
  const capture_names = ir.value.captures.map(v => v.value.name);
312
327
  const parameter_names = ir.value.parameters.map(v => v.value.name);
328
+ // Store original IR for potential serialization
329
+ const originalIR = ir;
313
330
  return (ctx) => {
314
331
  const ctx2 = {};
315
332
  for (const name of capture_names) {
316
333
  ctx2[name] = ctx[name];
317
334
  }
318
- return (...args) => {
335
+ const fn = (...args) => {
319
336
  const ctx3 = { ...ctx2 };
320
337
  parameter_names.forEach((name, i) => ctx3[name] = args[i]);
321
338
  return compiled_body(ctx3); // Promise can pass through in tail position
322
339
  };
340
+ // Attach IR to function for serialization support
341
+ Object.defineProperty(fn, EAST_IR_SYMBOL, {
342
+ value: originalIR,
343
+ writable: false,
344
+ enumerable: false,
345
+ configurable: false
346
+ });
347
+ return fn;
323
348
  };
324
349
  }
325
350
  else if (ir.type === "Call") {
326
- const compiled_f = compile_internal(ir.value.function, ctx, platform, asyncPlatformFns, false, compilingNodes);
327
- const compiled_args = ir.value.arguments.map(argument => compile_internal(argument, ctx, platform, asyncPlatformFns, false, compilingNodes));
351
+ const compiled_f = compile_internal(ir.value.function, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
352
+ const compiled_args = ir.value.arguments.map(argument => compile_internal(argument, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes));
328
353
  const location = ir.value.location;
329
354
  if (ir.value.isAsync) {
330
355
  // need to await the arguments
@@ -383,8 +408,8 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
383
408
  }
384
409
  }
385
410
  else if (ir.type === "CallAsync") {
386
- const compiled_f = compile_internal(ir.value.function, ctx, platform, asyncPlatformFns, false, compilingNodes);
387
- const compiled_args = ir.value.arguments.map(argument => compile_internal(argument, ctx, platform, asyncPlatformFns, false, compilingNodes));
411
+ const compiled_f = compile_internal(ir.value.function, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
412
+ const compiled_args = ir.value.arguments.map(argument => compile_internal(argument, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes));
388
413
  const location = ir.value.location;
389
414
  return async (ctx) => {
390
415
  try {
@@ -422,11 +447,11 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
422
447
  asyncPredicate = true;
423
448
  }
424
449
  ifs.push({
425
- predicate: compile_internal(predicate, ctx, platform, asyncPlatformFns, false, compilingNodes),
426
- body: compile_internal(body, Object.create(ctx), platform, asyncPlatformFns, true, compilingNodes),
450
+ predicate: compile_internal(predicate, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes),
451
+ body: compile_internal(body, Object.create(ctx), platform, asyncPlatformFns, platformDef, true, compilingNodes),
427
452
  });
428
453
  }
429
- const else_body = compile_internal(ir.value.else_body, Object.create(ctx), platform, asyncPlatformFns, true, compilingNodes);
454
+ const else_body = compile_internal(ir.value.else_body, Object.create(ctx), platform, asyncPlatformFns, platformDef, true, compilingNodes);
430
455
  if (ir.value.isAsync) {
431
456
  if (asyncPredicate) {
432
457
  return async (ctx) => {
@@ -461,7 +486,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
461
486
  }
462
487
  }
463
488
  else if (ir.type === "Match") {
464
- const compiled_variant = compile_internal(ir.value.variant, ctx, platform, asyncPlatformFns, false, compilingNodes);
489
+ const compiled_variant = compile_internal(ir.value.variant, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
465
490
  const compiled_cases = {};
466
491
  const data_names = {};
467
492
  for (const { case: k, variable, body } of ir.value.cases) {
@@ -469,7 +494,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
469
494
  const data_name = variable.value.name;
470
495
  data_names[k] = data_name;
471
496
  ctx2[data_name] = variable.value.type;
472
- compiled_cases[k] = compile_internal(body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
497
+ compiled_cases[k] = compile_internal(body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
473
498
  }
474
499
  if (ir.value.isAsync) {
475
500
  if (ir.value.variant.value.isAsync) {
@@ -499,9 +524,9 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
499
524
  }
500
525
  }
501
526
  else if (ir.type === "While") {
502
- const compiled_predicate = compile_internal(ir.value.predicate, ctx, platform, asyncPlatformFns, false, compilingNodes);
527
+ const compiled_predicate = compile_internal(ir.value.predicate, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
503
528
  const ctx2 = Object.create(ctx);
504
- const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
529
+ const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
505
530
  const label = ir.value.label.name;
506
531
  if (ir.value.isAsync) {
507
532
  return async (ctx) => {
@@ -550,13 +575,13 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
550
575
  }
551
576
  else if (ir.type === "ForArray") {
552
577
  const value_type = expandTypeValue(ir.value.array.value.type).value;
553
- const compiled_array = compile_internal(ir.value.array, ctx, platform, asyncPlatformFns, false, compilingNodes);
578
+ const compiled_array = compile_internal(ir.value.array, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
554
579
  const ctx2 = Object.create(ctx);
555
580
  const key_name = ir.value.key.value.name;
556
581
  const value_name = ir.value.value.value.name;
557
582
  ctx2[key_name] = variant("Integer", null);
558
583
  ctx2[value_name] = value_type;
559
- const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
584
+ const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
560
585
  const label = ir.value.label.name;
561
586
  if (ir.value.isAsync) {
562
587
  return async (ctx) => {
@@ -623,11 +648,11 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
623
648
  }
624
649
  else if (ir.type === "ForSet") {
625
650
  const key_type = expandTypeValue(ir.value.set.value.type).value;
626
- const compiled_set = compile_internal(ir.value.set, ctx, platform, asyncPlatformFns, false, compilingNodes);
651
+ const compiled_set = compile_internal(ir.value.set, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
627
652
  const ctx2 = Object.create(ctx);
628
653
  const key_name = ir.value.key.value.name;
629
654
  ctx2[key_name] = key_type;
630
- const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
655
+ const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
631
656
  const label = ir.value.label.name;
632
657
  if (ir.value.isAsync) {
633
658
  return async (ctx) => {
@@ -693,13 +718,13 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
693
718
  else if (ir.type === "ForDict") {
694
719
  const key_type = expandTypeValue(ir.value.dict.value.type).value.key;
695
720
  const value_type = expandTypeValue(ir.value.dict.value.type).value.value;
696
- const compiled_dict = compile_internal(ir.value.dict, ctx, platform, asyncPlatformFns, false, compilingNodes);
721
+ const compiled_dict = compile_internal(ir.value.dict, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
697
722
  const ctx2 = Object.create(ctx);
698
723
  const key_name = ir.value.key.value.name;
699
724
  const value_name = ir.value.value.value.name;
700
725
  ctx2[key_name] = key_type;
701
726
  ctx2[value_name] = value_type;
702
- const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, true, compilingNodes);
727
+ const compiled_body = compile_internal(ir.value.body, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
703
728
  const label = ir.value.label.name;
704
729
  if (ir.value.isAsync) {
705
730
  return async (ctx) => {
@@ -770,7 +795,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
770
795
  if (fresh_ctx) {
771
796
  const compiled_statements = [];
772
797
  for (const statement of ir.value.statements) {
773
- const compiled_statement = compile_internal(statement, ctx, platform, asyncPlatformFns, true, compilingNodes);
798
+ const compiled_statement = compile_internal(statement, ctx, platform, asyncPlatformFns, platformDef, true, compilingNodes);
774
799
  compiled_statements.push(compiled_statement);
775
800
  }
776
801
  if (ir.value.isAsync) {
@@ -796,7 +821,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
796
821
  const ctx2 = Object.create(ctx);
797
822
  const compiled_statements = [];
798
823
  for (const statement of ir.value.statements) {
799
- const compiled_statement = compile_internal(statement, ctx2, platform, asyncPlatformFns, true, compilingNodes);
824
+ const compiled_statement = compile_internal(statement, ctx2, platform, asyncPlatformFns, platformDef, true, compilingNodes);
800
825
  compiled_statements.push(compiled_statement);
801
826
  }
802
827
  if (ir.value.isAsync) {
@@ -822,7 +847,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
822
847
  }
823
848
  }
824
849
  else if (ir.type === "GetField") {
825
- const struct = compile_internal(ir.value.struct, ctx, platform, asyncPlatformFns, false, compilingNodes);
850
+ const struct = compile_internal(ir.value.struct, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
826
851
  const field = ir.value.field;
827
852
  if (ir.value.isAsync) {
828
853
  return async (ctx) => (await struct(ctx))[field];
@@ -833,7 +858,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
833
858
  }
834
859
  else if (ir.type === "Struct") {
835
860
  const fields = ir.value.fields.map(f => {
836
- return compile_internal(f.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
861
+ return compile_internal(f.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
837
862
  });
838
863
  const keys = ir.value.fields.map(f => f.name);
839
864
  if (ir.value.isAsync) {
@@ -851,7 +876,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
851
876
  }
852
877
  else if (ir.type === "Variant") {
853
878
  const k = ir.value.case;
854
- const v = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
879
+ const v = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
855
880
  if (ir.value.isAsync) {
856
881
  return async (ctx) => variant(k, await v(ctx));
857
882
  }
@@ -860,7 +885,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
860
885
  }
861
886
  }
862
887
  else if (ir.type === "NewRef") {
863
- const value = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
888
+ const value = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
864
889
  if (ir.value.isAsync) {
865
890
  return async (ctx) => ref(await value(ctx));
866
891
  }
@@ -870,7 +895,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
870
895
  }
871
896
  else if (ir.type === "NewArray") {
872
897
  const values = ir.value.values.map(a => {
873
- return compile_internal(a, ctx, platform, asyncPlatformFns, false, compilingNodes);
898
+ return compile_internal(a, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
874
899
  });
875
900
  if (ir.value.isAsync) {
876
901
  return async (ctx) => {
@@ -887,7 +912,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
887
912
  }
888
913
  else if (ir.type === "NewSet") {
889
914
  const values = ir.value.values.map(a => {
890
- return compile_internal(a, ctx, platform, asyncPlatformFns, false, compilingNodes);
915
+ return compile_internal(a, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
891
916
  });
892
917
  const keyComparer = compareFor(ir.value.type.value);
893
918
  if (ir.value.isAsync) {
@@ -905,7 +930,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
905
930
  }
906
931
  else if (ir.type === "NewDict") {
907
932
  const values = ir.value.values.map(({ key, value }) => {
908
- return [compile_internal(key, ctx, platform, asyncPlatformFns, false, compilingNodes), compile_internal(value, ctx, platform, asyncPlatformFns, false, compilingNodes)];
933
+ return [compile_internal(key, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes), compile_internal(value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes)];
909
934
  });
910
935
  const keyComparer = compareFor(ir.value.type.value.key);
911
936
  if (ir.value.isAsync) {
@@ -922,7 +947,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
922
947
  }
923
948
  }
924
949
  else if (ir.type === "Return") {
925
- const compiled_value = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, false, compilingNodes);
950
+ const compiled_value = compile_internal(ir.value.value, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
926
951
  if (ir.value.isAsync) {
927
952
  return async (ctx) => {
928
953
  throw new ReturnException(await compiled_value(ctx));
@@ -952,7 +977,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
952
977
  if (a.value.isAsync) {
953
978
  argsAsync = true;
954
979
  }
955
- return compile_internal(a, ctx, platform, asyncPlatformFns, false, compilingNodes);
980
+ return compile_internal(a, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
956
981
  });
957
982
  // Special optimization for regex builtins with literal pattern/flags
958
983
  if ((ir.value.builtin === "RegexContains" || ir.value.builtin === "RegexIndexOf" || ir.value.builtin === "RegexReplace") &&
@@ -1127,7 +1152,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
1127
1152
  }
1128
1153
  }
1129
1154
  }
1130
- const evaluator = builtin_evaluators[ir.value.builtin](ir.value.location, ...ir.value.type_parameters);
1155
+ const evaluator = builtin_evaluators[ir.value.builtin](ir.value.location, platformDef, ...ir.value.type_parameters);
1131
1156
  if (argsAsync) {
1132
1157
  return async (ctx) => {
1133
1158
  const args_resolved = [];
@@ -1147,7 +1172,7 @@ export function compile_internal(ir, ctx, platform, asyncPlatformFns, fresh_ctx
1147
1172
  if (a.value.isAsync) {
1148
1173
  argsAsync = true;
1149
1174
  }
1150
- return compile_internal(a, ctx, platform, asyncPlatformFns, false, compilingNodes);
1175
+ return compile_internal(a, ctx, platform, asyncPlatformFns, platformDef, false, compilingNodes);
1151
1176
  });
1152
1177
  const evaluator = platform[ir.value.name];
1153
1178
  if (evaluator === undefined) {
@@ -1196,13 +1221,13 @@ function call_function(location, compiled_f, ...args) {
1196
1221
  }
1197
1222
  /** @internal */
1198
1223
  const builtin_evaluators = {
1199
- Is: (_location, T) => isFor(T),
1200
- Equal: (_location, T) => equalFor(T),
1201
- NotEqual: (_location, T) => notEqualFor(T),
1202
- Less: (_location, T) => lessFor(T),
1203
- LessEqual: (_location, T) => lessEqualFor(T),
1204
- Greater: (_location, T) => greaterFor(T),
1205
- GreaterEqual: (_location, T) => greaterEqualFor(T),
1224
+ Is: (_location, _platformDef, T) => isFor(T),
1225
+ Equal: (_location, _platformDef, T) => equalFor(T),
1226
+ NotEqual: (_location, _platformDef, T) => notEqualFor(T),
1227
+ Less: (_location, _platformDef, T) => lessFor(T),
1228
+ LessEqual: (_location, _platformDef, T) => lessEqualFor(T),
1229
+ Greater: (_location, _platformDef, T) => greaterFor(T),
1230
+ GreaterEqual: (_location, _platformDef, T) => greaterEqualFor(T),
1206
1231
  BooleanNot: (_location) => (x) => !x,
1207
1232
  BooleanOr: (_location) => (x, y) => x || y,
1208
1233
  BooleanAnd: (_location) => (x, y) => x && y,
@@ -1257,10 +1282,10 @@ const builtin_evaluators = {
1257
1282
  FloatSin: (_location) => (value) => Math.sin(value),
1258
1283
  FloatCos: (_location) => (value) => Math.cos(value),
1259
1284
  FloatTan: (_location) => (value) => Math.tan(value),
1260
- Print: (_location, T) => {
1285
+ Print: (_location, _platformDef, T) => {
1261
1286
  return printFor(T);
1262
1287
  },
1263
- Parse: (location, T) => {
1288
+ Parse: (location, _platformDef, T) => {
1264
1289
  const p = parseFor(T);
1265
1290
  return (x) => {
1266
1291
  const result = p(x);
@@ -1460,7 +1485,7 @@ const builtin_evaluators = {
1460
1485
  return buffer.toUint8Array();
1461
1486
  };
1462
1487
  },
1463
- StringParseJSON: (location, type) => {
1488
+ StringParseJSON: (location, _platformDef, type) => {
1464
1489
  const fromJSON = fromJSONFor(type);
1465
1490
  return (x) => {
1466
1491
  let parsed;
@@ -1478,7 +1503,7 @@ const builtin_evaluators = {
1478
1503
  }
1479
1504
  };
1480
1505
  },
1481
- StringPrintJSON: (_location, type) => {
1506
+ StringPrintJSON: (_location, _platformDef, type) => {
1482
1507
  const toJSON = toJSONFor(type);
1483
1508
  return (x) => JSON.stringify(toJSON(x));
1484
1509
  },
@@ -1555,13 +1580,13 @@ const builtin_evaluators = {
1555
1580
  }
1556
1581
  };
1557
1582
  },
1558
- BlobEncodeBeast: (_location, type) => {
1583
+ BlobEncodeBeast: (_location, _platformDef, type) => {
1559
1584
  const encodeBeast = encodeBeastFor(type);
1560
1585
  return (value) => {
1561
1586
  return encodeBeast(value);
1562
1587
  };
1563
1588
  },
1564
- BlobDecodeBeast: (location, type) => {
1589
+ BlobDecodeBeast: (location, _platformDef, type) => {
1565
1590
  const decodeBeast = decodeBeastFor(type);
1566
1591
  return (data) => {
1567
1592
  try {
@@ -1572,14 +1597,14 @@ const builtin_evaluators = {
1572
1597
  }
1573
1598
  };
1574
1599
  },
1575
- BlobEncodeBeast2: (_location, type) => {
1600
+ BlobEncodeBeast2: (_location, _platformDef, type) => {
1576
1601
  const encodeBeast2 = encodeBeast2For(type);
1577
1602
  return (value) => {
1578
1603
  return encodeBeast2(value);
1579
1604
  };
1580
1605
  },
1581
- BlobDecodeBeast2: (location, type) => {
1582
- const decodeBeast2 = decodeBeast2For(type);
1606
+ BlobDecodeBeast2: (location, platformDef, type) => {
1607
+ const decodeBeast2 = decodeBeast2For(type, { platform: platformDef });
1583
1608
  return (data) => {
1584
1609
  try {
1585
1610
  return decodeBeast2(data);
@@ -1589,17 +1614,39 @@ const builtin_evaluators = {
1589
1614
  }
1590
1615
  };
1591
1616
  },
1592
- RefGet: (_location, _T) => (ref) => {
1617
+ BlobDecodeCsv: (location, _platformDef, structType, _configType) => {
1618
+ return (data, config) => {
1619
+ try {
1620
+ const decoder = decodeCsvFor(structType, config);
1621
+ return decoder(data);
1622
+ }
1623
+ catch (e) {
1624
+ throw new EastError(`Failed to decode CSV data: ${e.message}`, { location });
1625
+ }
1626
+ };
1627
+ },
1628
+ ArrayEncodeCsv: (location, _platformDef, structType, _configType) => {
1629
+ return (data, config) => {
1630
+ try {
1631
+ const encoder = encodeCsvFor(structType, config);
1632
+ return encoder(data);
1633
+ }
1634
+ catch (e) {
1635
+ throw new EastError(`Failed to encode CSV data: ${e.message}`, { location });
1636
+ }
1637
+ };
1638
+ },
1639
+ RefGet: (_location, _platformDef, _T) => (ref) => {
1593
1640
  return ref.value;
1594
1641
  },
1595
- RefUpdate: (location, _T) => (ref, value) => {
1642
+ RefUpdate: (location, _platformDef, _T) => (ref, value) => {
1596
1643
  if (Object.isFrozen(ref)) {
1597
1644
  throw new EastError("Cannot modify frozen Ref", { location });
1598
1645
  }
1599
1646
  ref.value = value;
1600
1647
  return null;
1601
1648
  },
1602
- RefMerge: (location, _T) => (ref, value, merger) => {
1649
+ RefMerge: (location, _platformDef, _T) => (ref, value, merger) => {
1603
1650
  if (Object.isFrozen(ref)) {
1604
1651
  throw new EastError("Cannot modify frozen Ref", { location });
1605
1652
  }
@@ -1607,7 +1654,7 @@ const builtin_evaluators = {
1607
1654
  ref.value = new_value;
1608
1655
  return null;
1609
1656
  },
1610
- ArrayGenerate: (location, _T) => (size, f) => {
1657
+ ArrayGenerate: (location, _platformDef, _T) => (size, f) => {
1611
1658
  const result = [];
1612
1659
  for (let i = 0n; i < size; i += 1n) {
1613
1660
  const v = call_function(location, f, i);
@@ -1648,12 +1695,12 @@ const builtin_evaluators = {
1648
1695
  }
1649
1696
  return result;
1650
1697
  },
1651
- ArraySize: (_location, _T) => (array) => BigInt(array.length),
1652
- ArrayHas: (_location, _T) => (array, key) => {
1698
+ ArraySize: (_location, _platformDef, _T) => (array) => BigInt(array.length),
1699
+ ArrayHas: (_location, _platformDef, _T) => (array, key) => {
1653
1700
  const i = Number(key);
1654
1701
  return i >= 0 && i < array.length;
1655
1702
  },
1656
- ArrayGet: (location, _T) => (array, key) => {
1703
+ ArrayGet: (location, _platformDef, _T) => (array, key) => {
1657
1704
  const i = Number(key);
1658
1705
  if (i < 0 || i >= array.length) {
1659
1706
  throw new EastError(`Array index ${key} out of bounds`, { location });
@@ -1662,7 +1709,7 @@ const builtin_evaluators = {
1662
1709
  return array[i];
1663
1710
  }
1664
1711
  },
1665
- ArrayGetOrDefault: (location, _T) => (array, key, defaultFn) => {
1712
+ ArrayGetOrDefault: (location, _platformDef, _T) => (array, key, defaultFn) => {
1666
1713
  const i = Number(key);
1667
1714
  if (i < 0 || i >= array.length) {
1668
1715
  return call_function(location, defaultFn, key);
@@ -1671,7 +1718,7 @@ const builtin_evaluators = {
1671
1718
  return array[i];
1672
1719
  }
1673
1720
  },
1674
- ArrayTryGet: (_location, _T) => (array, key) => {
1721
+ ArrayTryGet: (_location, _platformDef, _T) => (array, key) => {
1675
1722
  const i = Number(key);
1676
1723
  if (i < 0 || i >= array.length) {
1677
1724
  return variant("none", null);
@@ -1680,7 +1727,7 @@ const builtin_evaluators = {
1680
1727
  return variant("some", array[i]);
1681
1728
  }
1682
1729
  },
1683
- ArrayUpdate: (location, _T) => (array, key, value) => {
1730
+ ArrayUpdate: (location, _platformDef, _T) => (array, key, value) => {
1684
1731
  if (Object.isFrozen(array)) {
1685
1732
  throw new EastError("Cannot modify frozen Array", { location });
1686
1733
  }
@@ -1693,7 +1740,7 @@ const builtin_evaluators = {
1693
1740
  return null;
1694
1741
  }
1695
1742
  },
1696
- ArrayMerge: (location, _T) => (array, key, value, merger) => {
1743
+ ArrayMerge: (location, _platformDef, _T) => (array, key, value, merger) => {
1697
1744
  if (Object.isFrozen(array)) {
1698
1745
  throw new EastError("Cannot modify frozen Array", { location });
1699
1746
  }
@@ -1707,7 +1754,7 @@ const builtin_evaluators = {
1707
1754
  return null;
1708
1755
  }
1709
1756
  },
1710
- ArrayPushLast: (location, _T) => (array, value) => {
1757
+ ArrayPushLast: (location, _platformDef, _T) => (array, value) => {
1711
1758
  if (Object.isFrozen(array)) {
1712
1759
  throw new EastError("Cannot modify frozen Array", { location });
1713
1760
  }
@@ -1717,7 +1764,7 @@ const builtin_evaluators = {
1717
1764
  array.push(value);
1718
1765
  return null;
1719
1766
  },
1720
- ArrayPopLast: (location, _T) => (array) => {
1767
+ ArrayPopLast: (location, _platformDef, _T) => (array) => {
1721
1768
  if (Object.isFrozen(array)) {
1722
1769
  throw new EastError("Cannot modify frozen Array", { location });
1723
1770
  }
@@ -1731,7 +1778,7 @@ const builtin_evaluators = {
1731
1778
  return array.pop();
1732
1779
  }
1733
1780
  },
1734
- ArrayPushFirst: (location, _T) => (array, value) => {
1781
+ ArrayPushFirst: (location, _platformDef, _T) => (array, value) => {
1735
1782
  if (Object.isFrozen(array)) {
1736
1783
  throw new EastError("Cannot modify frozen Array", { location });
1737
1784
  }
@@ -1741,7 +1788,7 @@ const builtin_evaluators = {
1741
1788
  array.unshift(value);
1742
1789
  return null;
1743
1790
  },
1744
- ArrayPopFirst: (location, _T) => (array) => {
1791
+ ArrayPopFirst: (location, _platformDef, _T) => (array) => {
1745
1792
  if (Object.isFrozen(array)) {
1746
1793
  throw new EastError("Cannot modify frozen Array", { location });
1747
1794
  }
@@ -1755,7 +1802,7 @@ const builtin_evaluators = {
1755
1802
  return array.shift();
1756
1803
  }
1757
1804
  },
1758
- ArrayAppend: (location, _T) => (array, other) => {
1805
+ ArrayAppend: (location, _platformDef, _T) => (array, other) => {
1759
1806
  if (Object.isFrozen(array)) {
1760
1807
  throw new EastError("Cannot modify frozen Array", { location });
1761
1808
  }
@@ -1765,7 +1812,7 @@ const builtin_evaluators = {
1765
1812
  array.push(...other);
1766
1813
  return null;
1767
1814
  },
1768
- ArrayPrepend: (location, _T) => (array, other) => {
1815
+ ArrayPrepend: (location, _platformDef, _T) => (array, other) => {
1769
1816
  if (Object.isFrozen(array)) {
1770
1817
  throw new EastError("Cannot modify frozen Array", { location });
1771
1818
  }
@@ -1775,7 +1822,7 @@ const builtin_evaluators = {
1775
1822
  array.unshift(...other);
1776
1823
  return null;
1777
1824
  },
1778
- ArrayMergeAll: (location, _T, _T2) => (array, other, merger) => {
1825
+ ArrayMergeAll: (location, _platformDef, _T, _T2) => (array, other, merger) => {
1779
1826
  if (Object.isFrozen(array)) {
1780
1827
  throw new EastError("Cannot modify frozen Array", { location });
1781
1828
  }
@@ -1799,7 +1846,7 @@ const builtin_evaluators = {
1799
1846
  }
1800
1847
  return null;
1801
1848
  },
1802
- ArrayClear: (location, _T) => (array) => {
1849
+ ArrayClear: (location, _platformDef, _T) => (array) => {
1803
1850
  if (Object.isFrozen(array)) {
1804
1851
  throw new EastError("Cannot modify frozen Array", { location });
1805
1852
  }
@@ -1809,7 +1856,7 @@ const builtin_evaluators = {
1809
1856
  array.length = 0;
1810
1857
  return null;
1811
1858
  },
1812
- ArraySortInPlace: (location, T, T2) => (array, by) => {
1859
+ ArraySortInPlace: (location, _platformDef, T, T2) => (array, by) => {
1813
1860
  if (Object.isFrozen(array)) {
1814
1861
  throw new EastError("Cannot modify frozen Array", { location });
1815
1862
  }
@@ -1830,7 +1877,7 @@ const builtin_evaluators = {
1830
1877
  }
1831
1878
  return null;
1832
1879
  },
1833
- ArrayReverseInPlace: (location, _T) => (array) => {
1880
+ ArrayReverseInPlace: (location, _platformDef, _T) => (array) => {
1834
1881
  if (Object.isFrozen(array)) {
1835
1882
  throw new EastError("Cannot modify frozen Array", { location });
1836
1883
  }
@@ -1840,7 +1887,7 @@ const builtin_evaluators = {
1840
1887
  array.reverse();
1841
1888
  return null;
1842
1889
  },
1843
- ArraySort: (location, T, T2) => (array, by) => {
1890
+ ArraySort: (location, _platformDef, T, T2) => (array, by) => {
1844
1891
  const cmp = compareFor(T2);
1845
1892
  const newArray = [...array];
1846
1893
  newArray.sort((a, b) => {
@@ -1850,12 +1897,12 @@ const builtin_evaluators = {
1850
1897
  });
1851
1898
  return newArray;
1852
1899
  },
1853
- ArrayReverse: (_location, _T) => (array) => {
1900
+ ArrayReverse: (_location, _platformDef, _T) => (array) => {
1854
1901
  const newArray = [...array];
1855
1902
  newArray.reverse();
1856
1903
  return newArray;
1857
1904
  },
1858
- ArrayIsSorted: (location, T, T2) => {
1905
+ ArrayIsSorted: (location, _platformDef, T, T2) => {
1859
1906
  const cmp = compareFor(T2);
1860
1907
  return (array, by) => {
1861
1908
  if (array.length < 2)
@@ -1877,7 +1924,7 @@ const builtin_evaluators = {
1877
1924
  return true;
1878
1925
  };
1879
1926
  },
1880
- ArrayFindSortedFirst: (location, T, T2) => {
1927
+ ArrayFindSortedFirst: (location, _platformDef, T, T2) => {
1881
1928
  const cmp = compareFor(T2);
1882
1929
  return (array, key, by) => {
1883
1930
  let low = 0;
@@ -1901,7 +1948,7 @@ const builtin_evaluators = {
1901
1948
  return BigInt(low);
1902
1949
  };
1903
1950
  },
1904
- ArrayFindSortedLast: (location, T, T2) => {
1951
+ ArrayFindSortedLast: (location, _platformDef, T, T2) => {
1905
1952
  const cmp = compareFor(T2);
1906
1953
  return (array, key, by) => {
1907
1954
  let low = 0;
@@ -1925,7 +1972,7 @@ const builtin_evaluators = {
1925
1972
  return BigInt(low);
1926
1973
  };
1927
1974
  },
1928
- ArrayFindSortedRange: (location, T, T2) => {
1975
+ ArrayFindSortedRange: (location, _platformDef, T, T2) => {
1929
1976
  const cmp = compareFor(T2);
1930
1977
  return (array, key, by) => {
1931
1978
  let lo = -1;
@@ -1983,7 +2030,7 @@ const builtin_evaluators = {
1983
2030
  return { start: BigInt(lo + 1), end: BigInt(lo + 1) };
1984
2031
  };
1985
2032
  },
1986
- ArrayFindFirst: (location, T, T2) => {
2033
+ ArrayFindFirst: (location, _platformDef, T, T2) => {
1987
2034
  const cmp = compareFor(T2);
1988
2035
  return (array, value, by) => {
1989
2036
  lockForIteration(array);
@@ -2001,15 +2048,15 @@ const builtin_evaluators = {
2001
2048
  }
2002
2049
  };
2003
2050
  },
2004
- ArrayConcat: (_location, _T) => (a1, a2) => {
2051
+ ArrayConcat: (_location, _platformDef, _T) => (a1, a2) => {
2005
2052
  return [...a1, ...a2];
2006
2053
  },
2007
- ArraySlice: (_location, _T) => (array, start, end) => {
2054
+ ArraySlice: (_location, _platformDef, _T) => (array, start, end) => {
2008
2055
  const startNum = Number(start);
2009
2056
  const endNum = Number(end);
2010
2057
  return array.slice(startNum, endNum);
2011
2058
  },
2012
- ArrayGetKeys: (location, _T) => (array, keys, onMissing) => {
2059
+ ArrayGetKeys: (location, _platformDef, _T) => (array, keys, onMissing) => {
2013
2060
  return keys.map(k => {
2014
2061
  const i = Number(k);
2015
2062
  if (i < 0 || i >= array.length) {
@@ -2020,7 +2067,7 @@ const builtin_evaluators = {
2020
2067
  }
2021
2068
  });
2022
2069
  },
2023
- ArrayForEach: (location, _T, _T2) => (array, f) => {
2070
+ ArrayForEach: (location, _platformDef, _T, _T2) => (array, f) => {
2024
2071
  lockForIteration(array);
2025
2072
  try {
2026
2073
  array.forEach((x, i) => {
@@ -2032,10 +2079,10 @@ const builtin_evaluators = {
2032
2079
  unlockForIteration(array);
2033
2080
  }
2034
2081
  },
2035
- ArrayCopy: (_location, _T) => (array) => {
2082
+ ArrayCopy: (_location, _platformDef, _T) => (array) => {
2036
2083
  return [...array];
2037
2084
  },
2038
- ArrayMap: (location, _T, _T2) => (array, f) => {
2085
+ ArrayMap: (location, _platformDef, _T, _T2) => (array, f) => {
2039
2086
  lockForIteration(array);
2040
2087
  try {
2041
2088
  return array.map((x, i) => {
@@ -2046,7 +2093,7 @@ const builtin_evaluators = {
2046
2093
  unlockForIteration(array);
2047
2094
  }
2048
2095
  },
2049
- ArrayFilter: (location, _T, _T2) => (array, f) => {
2096
+ ArrayFilter: (location, _platformDef, _T, _T2) => (array, f) => {
2050
2097
  lockForIteration(array);
2051
2098
  try {
2052
2099
  return array.filter((x, i) => {
@@ -2057,7 +2104,7 @@ const builtin_evaluators = {
2057
2104
  unlockForIteration(array);
2058
2105
  }
2059
2106
  },
2060
- ArrayFilterMap: (location, _T, _T2) => (array, f) => {
2107
+ ArrayFilterMap: (location, _platformDef, _T, _T2) => (array, f) => {
2061
2108
  lockForIteration(array);
2062
2109
  try {
2063
2110
  const result = [];
@@ -2073,7 +2120,7 @@ const builtin_evaluators = {
2073
2120
  unlockForIteration(array);
2074
2121
  }
2075
2122
  },
2076
- ArrayFirstMap: (location, _T, _T2) => (array, f) => {
2123
+ ArrayFirstMap: (location, _platformDef, _T, _T2) => (array, f) => {
2077
2124
  lockForIteration(array);
2078
2125
  try {
2079
2126
  for (let i = 0; i < array.length; i++) {
@@ -2088,7 +2135,7 @@ const builtin_evaluators = {
2088
2135
  unlockForIteration(array);
2089
2136
  }
2090
2137
  },
2091
- ArrayFold: (location, _T, _T2) => (array, init, f) => {
2138
+ ArrayFold: (location, _platformDef, _T, _T2) => (array, init, f) => {
2092
2139
  lockForIteration(array);
2093
2140
  try {
2094
2141
  return array.reduce((acc, x, i) => {
@@ -2099,7 +2146,7 @@ const builtin_evaluators = {
2099
2146
  unlockForIteration(array);
2100
2147
  }
2101
2148
  },
2102
- ArrayMapReduce: (location, _T, _T2) => (array, mapFn, reduceFn) => {
2149
+ ArrayMapReduce: (location, _platformDef, _T, _T2) => (array, mapFn, reduceFn) => {
2103
2150
  if (array.length === 0) {
2104
2151
  throw new EastError("Cannot reduce empty array with no initial value", { location });
2105
2152
  }
@@ -2116,8 +2163,8 @@ const builtin_evaluators = {
2116
2163
  unlockForIteration(array);
2117
2164
  }
2118
2165
  },
2119
- ArrayStringJoin: (_location) => (x, y) => x.join(y),
2120
- ArrayToSet: (location, _T, T2) => {
2166
+ ArrayStringJoin: (_location, _platformDef) => (x, y) => x.join(y),
2167
+ ArrayToSet: (location, _platformDef, _T, T2) => {
2121
2168
  const compare = compareFor(T2);
2122
2169
  return (array, f) => {
2123
2170
  lockForIteration(array);
@@ -2134,7 +2181,7 @@ const builtin_evaluators = {
2134
2181
  }
2135
2182
  };
2136
2183
  },
2137
- ArrayToDict: (location, _T, K2, _T2) => {
2184
+ ArrayToDict: (location, _platformDef, _T, K2, _T2) => {
2138
2185
  const compare = compareFor(K2);
2139
2186
  return (array, keyFn, valueFn, onConflict) => {
2140
2187
  const result = new SortedMap([], compare);
@@ -2160,12 +2207,12 @@ const builtin_evaluators = {
2160
2207
  }
2161
2208
  };
2162
2209
  },
2163
- ArrayFlattenToArray: (location, _T) => (array, fn) => {
2210
+ ArrayFlattenToArray: (location, _platformDef, _T) => (array, fn) => {
2164
2211
  return array.flatMap(v => {
2165
2212
  return call_function(location, fn, v);
2166
2213
  });
2167
2214
  },
2168
- ArrayFlattenToSet: (location, _T, K2) => {
2215
+ ArrayFlattenToSet: (location, _platformDef, _T, K2) => {
2169
2216
  const compare = compareFor(K2);
2170
2217
  return (array, fn) => {
2171
2218
  const result = new SortedSet([], compare);
@@ -2184,7 +2231,7 @@ const builtin_evaluators = {
2184
2231
  }
2185
2232
  };
2186
2233
  },
2187
- ArrayFlattenToDict: (location, _T, K2, _T2) => {
2234
+ ArrayFlattenToDict: (location, _platformDef, _T, K2, _T2) => {
2188
2235
  const compare = compareFor(K2);
2189
2236
  return (array, fn, onConflict) => {
2190
2237
  const result = new SortedMap([], compare);
@@ -2210,7 +2257,7 @@ const builtin_evaluators = {
2210
2257
  }
2211
2258
  };
2212
2259
  },
2213
- ArrayGroupFold: (location, _T, K2, _V2) => {
2260
+ ArrayGroupFold: (location, _platformDef, _T, K2, _V2) => {
2214
2261
  const compare = compareFor(K2);
2215
2262
  return (array, keyFn, init, folder) => {
2216
2263
  const result = new SortedMap([], compare);
@@ -2233,7 +2280,7 @@ const builtin_evaluators = {
2233
2280
  }
2234
2281
  };
2235
2282
  },
2236
- SetGenerate: (location, K) => {
2283
+ SetGenerate: (location, _platformDef, K) => {
2237
2284
  const keyComparer = compareFor(K);
2238
2285
  return (size, keyFn, onConflict) => {
2239
2286
  const result = new SortedSet([], keyComparer);
@@ -2249,9 +2296,9 @@ const builtin_evaluators = {
2249
2296
  return result;
2250
2297
  };
2251
2298
  },
2252
- SetSize: (_location, _K) => (s) => BigInt(s.size),
2253
- SetHas: (_location, _K) => (s, key) => s.has(key),
2254
- SetInsert: (location, K) => {
2299
+ SetSize: (_location, _platformDef, _K) => (s) => BigInt(s.size),
2300
+ SetHas: (_location, _platformDef, _K) => (s, key) => s.has(key),
2301
+ SetInsert: (location, _platformDef, K) => {
2255
2302
  const print = printFor(K);
2256
2303
  return (s, key) => {
2257
2304
  if (Object.isFrozen(s)) {
@@ -2268,7 +2315,7 @@ const builtin_evaluators = {
2268
2315
  return null;
2269
2316
  };
2270
2317
  },
2271
- SetTryInsert: (location, _K) => (s, key) => {
2318
+ SetTryInsert: (location, _platformDef, _K) => (s, key) => {
2272
2319
  if (Object.isFrozen(s)) {
2273
2320
  throw new EastError("Cannot modify frozen Set", { location });
2274
2321
  }
@@ -2279,7 +2326,7 @@ const builtin_evaluators = {
2279
2326
  s.add(key);
2280
2327
  return s.size > size_before;
2281
2328
  },
2282
- SetDelete: (location, K) => {
2329
+ SetDelete: (location, _platformDef, K) => {
2283
2330
  const print = printFor(K);
2284
2331
  return (s, key) => {
2285
2332
  if (Object.isFrozen(s)) {
@@ -2294,7 +2341,7 @@ const builtin_evaluators = {
2294
2341
  return null;
2295
2342
  };
2296
2343
  },
2297
- SetTryDelete: (location, _K) => (s, key) => {
2344
+ SetTryDelete: (location, _platformDef, _K) => (s, key) => {
2298
2345
  if (Object.isFrozen(s)) {
2299
2346
  throw new EastError("Cannot modify frozen Set", { location });
2300
2347
  }
@@ -2303,7 +2350,7 @@ const builtin_evaluators = {
2303
2350
  }
2304
2351
  return s.delete(key);
2305
2352
  },
2306
- SetClear: (location, _K) => (s) => {
2353
+ SetClear: (location, _platformDef, _K) => (s) => {
2307
2354
  if (Object.isFrozen(s)) {
2308
2355
  throw new EastError("Cannot modify frozen Set", { location });
2309
2356
  }
@@ -2313,7 +2360,7 @@ const builtin_evaluators = {
2313
2360
  s.clear();
2314
2361
  return null;
2315
2362
  },
2316
- SetUnionInPlace: (location, _K) => (s1, s2) => {
2363
+ SetUnionInPlace: (location, _platformDef, _K) => (s1, s2) => {
2317
2364
  if (Object.isFrozen(s1)) {
2318
2365
  throw new EastError("Cannot modify frozen Set", { location });
2319
2366
  }
@@ -2323,19 +2370,19 @@ const builtin_evaluators = {
2323
2370
  s2.forEach(v => s1.add(v));
2324
2371
  return null;
2325
2372
  },
2326
- SetUnion: (_location, _K) => (s1, s2) => s1.union(s2),
2327
- SetIntersect: (_location, _K) => (s1, s2) => s1.intersection(s2),
2328
- SetDiff: (_location, _K) => (s1, s2) => s1.difference(s2),
2329
- SetSymDiff: (_location, _K) => (s1, s2) => s1.symmetricDifference(s2),
2330
- SetIsSubset: (_location, _K) => (s1, s2) => s1.isSubsetOf(s2),
2331
- SetIsDisjoint: (_location, _K) => (s1, s2) => s1.isDisjointFrom(s2),
2332
- SetCopy: (_location, K) => {
2373
+ SetUnion: (_location, _platformDef, _K) => (s1, s2) => s1.union(s2),
2374
+ SetIntersect: (_location, _platformDef, _K) => (s1, s2) => s1.intersection(s2),
2375
+ SetDiff: (_location, _platformDef, _K) => (s1, s2) => s1.difference(s2),
2376
+ SetSymDiff: (_location, _platformDef, _K) => (s1, s2) => s1.symmetricDifference(s2),
2377
+ SetIsSubset: (_location, _platformDef, _K) => (s1, s2) => s1.isSubsetOf(s2),
2378
+ SetIsDisjoint: (_location, _platformDef, _K) => (s1, s2) => s1.isDisjointFrom(s2),
2379
+ SetCopy: (_location, _platformDef, K) => {
2333
2380
  const compare = compareFor(K);
2334
2381
  return (s) => {
2335
2382
  return new SortedSet([...s], compare);
2336
2383
  };
2337
2384
  },
2338
- SetForEach: (location, _K, _T2) => (s, f) => {
2385
+ SetForEach: (location, _platformDef, _K, _T2) => (s, f) => {
2339
2386
  lockForIteration(s);
2340
2387
  try {
2341
2388
  s.forEach(x => {
@@ -2347,7 +2394,7 @@ const builtin_evaluators = {
2347
2394
  unlockForIteration(s);
2348
2395
  }
2349
2396
  },
2350
- SetFilter: (location, K) => {
2397
+ SetFilter: (location, _platformDef, K) => {
2351
2398
  const compare = compareFor(K);
2352
2399
  return (s, f) => {
2353
2400
  const result = new SortedSet([], compare);
@@ -2366,7 +2413,7 @@ const builtin_evaluators = {
2366
2413
  }
2367
2414
  };
2368
2415
  },
2369
- SetFilterMap: (location, K, _V2) => {
2416
+ SetFilterMap: (location, _platformDef, K, _V2) => {
2370
2417
  const compare = compareFor(K);
2371
2418
  return (s, f) => {
2372
2419
  const result = new SortedMap([], compare);
@@ -2385,7 +2432,7 @@ const builtin_evaluators = {
2385
2432
  }
2386
2433
  };
2387
2434
  },
2388
- SetFirstMap: (location, _K, _T2) => (s, f) => {
2435
+ SetFirstMap: (location, _platformDef, _K, _T2) => (s, f) => {
2389
2436
  lockForIteration(s);
2390
2437
  try {
2391
2438
  for (const k of s) {
@@ -2400,7 +2447,7 @@ const builtin_evaluators = {
2400
2447
  unlockForIteration(s);
2401
2448
  }
2402
2449
  },
2403
- SetMapReduce: (location, _K, _T2) => (s, mapFn, reduceFn) => {
2450
+ SetMapReduce: (location, _platformDef, _K, _T2) => (s, mapFn, reduceFn) => {
2404
2451
  if (s.size === 0) {
2405
2452
  throw new EastError("Cannot reduce empty set with no initial value", { location });
2406
2453
  }
@@ -2419,7 +2466,7 @@ const builtin_evaluators = {
2419
2466
  unlockForIteration(s);
2420
2467
  }
2421
2468
  },
2422
- SetMap: (location, K, _T2) => {
2469
+ SetMap: (location, _platformDef, K, _T2) => {
2423
2470
  const compare = compareFor(K);
2424
2471
  return (s, f) => {
2425
2472
  const result = new SortedMap([], compare);
@@ -2436,7 +2483,7 @@ const builtin_evaluators = {
2436
2483
  }
2437
2484
  };
2438
2485
  },
2439
- SetReduce: (location, _K, _T2) => (s, f, init) => {
2486
+ SetReduce: (location, _platformDef, _K, _T2) => (s, f, init) => {
2440
2487
  let acc = init;
2441
2488
  lockForIteration(s);
2442
2489
  try {
@@ -2449,7 +2496,7 @@ const builtin_evaluators = {
2449
2496
  unlockForIteration(s);
2450
2497
  }
2451
2498
  },
2452
- SetToArray: (location, _K, _T2) => (s, valueFn) => {
2499
+ SetToArray: (location, _platformDef, _K, _T2) => (s, valueFn) => {
2453
2500
  const ret = [];
2454
2501
  lockForIteration(s);
2455
2502
  try {
@@ -2463,7 +2510,7 @@ const builtin_evaluators = {
2463
2510
  unlockForIteration(s);
2464
2511
  }
2465
2512
  },
2466
- SetToSet: (location, K, K2) => {
2513
+ SetToSet: (location, _platformDef, K, K2) => {
2467
2514
  const compare = compareFor(K2);
2468
2515
  return (s, f) => {
2469
2516
  const result = new SortedSet([], compare);
@@ -2481,7 +2528,7 @@ const builtin_evaluators = {
2481
2528
  }
2482
2529
  };
2483
2530
  },
2484
- SetToDict: (location, K, K2, _V2) => {
2531
+ SetToDict: (location, _platformDef, K, K2, _V2) => {
2485
2532
  const compare = compareFor(K2);
2486
2533
  return (s, keyFn, valueFn, onConflict) => {
2487
2534
  const result = new SortedMap([], compare);
@@ -2506,7 +2553,7 @@ const builtin_evaluators = {
2506
2553
  }
2507
2554
  };
2508
2555
  },
2509
- SetFlattenToArray: (location, _K, _T2) => (s, fn) => {
2556
+ SetFlattenToArray: (location, _platformDef, _K, _T2) => (s, fn) => {
2510
2557
  const ret = [];
2511
2558
  lockForIteration(s);
2512
2559
  try {
@@ -2520,7 +2567,7 @@ const builtin_evaluators = {
2520
2567
  unlockForIteration(s);
2521
2568
  }
2522
2569
  },
2523
- SetFlattenToSet: (location, _K, K2) => {
2570
+ SetFlattenToSet: (location, _platformDef, _K, K2) => {
2524
2571
  const compare = compareFor(K2);
2525
2572
  return (s, fn) => {
2526
2573
  const result = new SortedSet([], compare);
@@ -2539,7 +2586,7 @@ const builtin_evaluators = {
2539
2586
  }
2540
2587
  };
2541
2588
  },
2542
- SetFlattenToDict: (location, _K, K2, _V2) => {
2589
+ SetFlattenToDict: (location, _platformDef, _K, K2, _V2) => {
2543
2590
  const compare = compareFor(K2);
2544
2591
  return (s, fn, onConflict) => {
2545
2592
  const result = new SortedMap([], compare);
@@ -2565,7 +2612,7 @@ const builtin_evaluators = {
2565
2612
  }
2566
2613
  };
2567
2614
  },
2568
- SetGroupFold: (location, _K, K2, _T2) => {
2615
+ SetGroupFold: (location, _platformDef, _K, K2, _T2) => {
2569
2616
  const compare = compareFor(K2);
2570
2617
  return (s, keyFn, init, folder) => {
2571
2618
  const result = new SortedMap([], compare);
@@ -2587,7 +2634,7 @@ const builtin_evaluators = {
2587
2634
  }
2588
2635
  };
2589
2636
  },
2590
- DictGenerate: (location, K, _V) => {
2637
+ DictGenerate: (location, _platformDef, K, _V) => {
2591
2638
  const keyComparer = compareFor(K);
2592
2639
  return (size, keyFn, valueFn, onConflict) => {
2593
2640
  const result = new SortedMap([], keyComparer);
@@ -2606,9 +2653,9 @@ const builtin_evaluators = {
2606
2653
  return result;
2607
2654
  };
2608
2655
  },
2609
- DictSize: (_location, _K, _V) => (d) => BigInt(d.size),
2610
- DictHas: (_location, _K, _V) => (d, key) => d.has(key),
2611
- DictGet: (location, K, _V) => {
2656
+ DictSize: (_location, _platformDef, _K, _V) => (d) => BigInt(d.size),
2657
+ DictHas: (_location, _platformDef, _K, _V) => (d, key) => d.has(key),
2658
+ DictGet: (location, _platformDef, K, _V) => {
2612
2659
  const print = printFor(K);
2613
2660
  return (d, key) => {
2614
2661
  const result = d.get(key);
@@ -2620,7 +2667,7 @@ const builtin_evaluators = {
2620
2667
  }
2621
2668
  };
2622
2669
  },
2623
- DictGetOrDefault: (location, _K, _V) => (d, key, onMissingFn) => {
2670
+ DictGetOrDefault: (location, _platformDef, _K, _V) => (d, key, onMissingFn) => {
2624
2671
  const result = d.get(key);
2625
2672
  if (result === undefined) {
2626
2673
  return call_function(location, onMissingFn, key);
@@ -2629,7 +2676,7 @@ const builtin_evaluators = {
2629
2676
  return result;
2630
2677
  }
2631
2678
  },
2632
- DictTryGet: (_location, _K, _V) => (d, key) => {
2679
+ DictTryGet: (_location, _platformDef, _K, _V) => (d, key) => {
2633
2680
  const result = d.get(key);
2634
2681
  if (result === undefined) {
2635
2682
  return variant("none", null);
@@ -2638,7 +2685,7 @@ const builtin_evaluators = {
2638
2685
  return variant("some", result);
2639
2686
  }
2640
2687
  },
2641
- DictInsert: (location, K, _V) => {
2688
+ DictInsert: (location, _platformDef, K, _V) => {
2642
2689
  const print = printFor(K);
2643
2690
  return (d, key, value) => {
2644
2691
  if (Object.isFrozen(d)) {
@@ -2657,7 +2704,7 @@ const builtin_evaluators = {
2657
2704
  return null;
2658
2705
  };
2659
2706
  },
2660
- DictGetOrInsert: (location, _K, _V) => (d, key, onMissing) => {
2707
+ DictGetOrInsert: (location, _platformDef, _K, _V) => (d, key, onMissing) => {
2661
2708
  if (Object.isFrozen(d)) {
2662
2709
  throw new EastError("Cannot modify frozen Dict", { location });
2663
2710
  }
@@ -2674,7 +2721,7 @@ const builtin_evaluators = {
2674
2721
  return existing;
2675
2722
  }
2676
2723
  },
2677
- DictInsertOrUpdate: (location, _K, _V) => (d, key, value, onConflictFn) => {
2724
+ DictInsertOrUpdate: (location, _platformDef, _K, _V) => (d, key, value, onConflictFn) => {
2678
2725
  if (Object.isFrozen(d)) {
2679
2726
  throw new EastError("Cannot modify frozen Dict", { location });
2680
2727
  }
@@ -2691,7 +2738,7 @@ const builtin_evaluators = {
2691
2738
  }
2692
2739
  return null;
2693
2740
  },
2694
- DictUpdate: (location, K, _V) => {
2741
+ DictUpdate: (location, _platformDef, K, _V) => {
2695
2742
  const print = printFor(K);
2696
2743
  return (d, key, value) => {
2697
2744
  if (Object.isFrozen(d)) {
@@ -2706,7 +2753,7 @@ const builtin_evaluators = {
2706
2753
  }
2707
2754
  };
2708
2755
  },
2709
- DictSwap: (location, K, _V) => {
2756
+ DictSwap: (location, _platformDef, K, _V) => {
2710
2757
  const print = printFor(K);
2711
2758
  return (d, key, value) => {
2712
2759
  if (Object.isFrozen(d)) {
@@ -2720,7 +2767,7 @@ const builtin_evaluators = {
2720
2767
  return existing;
2721
2768
  };
2722
2769
  },
2723
- DictMerge: (location, _K, _V) => (d, key, value, mergeFn, initialFn) => {
2770
+ DictMerge: (location, _platformDef, _K, _V) => (d, key, value, mergeFn, initialFn) => {
2724
2771
  if (Object.isFrozen(d)) {
2725
2772
  throw new EastError("Cannot modify frozen Dict", { location });
2726
2773
  }
@@ -2735,7 +2782,7 @@ const builtin_evaluators = {
2735
2782
  d.set(key, new_value);
2736
2783
  return null;
2737
2784
  },
2738
- DictDelete: (location, K, _V) => {
2785
+ DictDelete: (location, _platformDef, K, _V) => {
2739
2786
  const print = printFor(K);
2740
2787
  return (d, key) => {
2741
2788
  if (Object.isFrozen(d)) {
@@ -2751,7 +2798,7 @@ const builtin_evaluators = {
2751
2798
  return null;
2752
2799
  };
2753
2800
  },
2754
- DictTryDelete: (location, _K, _V) => (d, key) => {
2801
+ DictTryDelete: (location, _platformDef, _K, _V) => (d, key) => {
2755
2802
  if (Object.isFrozen(d)) {
2756
2803
  throw new EastError("Cannot modify frozen Dict", { location });
2757
2804
  }
@@ -2760,7 +2807,7 @@ const builtin_evaluators = {
2760
2807
  }
2761
2808
  return d.delete(key);
2762
2809
  },
2763
- DictPop: (location, K, _V) => {
2810
+ DictPop: (location, _platformDef, K, _V) => {
2764
2811
  const print = printFor(K);
2765
2812
  return (d, key) => {
2766
2813
  if (Object.isFrozen(d)) {
@@ -2779,7 +2826,7 @@ const builtin_evaluators = {
2779
2826
  }
2780
2827
  };
2781
2828
  },
2782
- DictClear: (location, _K, _V) => (d) => {
2829
+ DictClear: (location, _platformDef, _K, _V) => (d) => {
2783
2830
  if (Object.isFrozen(d)) {
2784
2831
  throw new EastError("Cannot modify frozen Dict", { location });
2785
2832
  }
@@ -2789,7 +2836,7 @@ const builtin_evaluators = {
2789
2836
  d.clear();
2790
2837
  return null;
2791
2838
  },
2792
- DictUnionInPlace: (location, _K, _V) => (d1, d2, onConflict) => {
2839
+ DictUnionInPlace: (location, _platformDef, _K, _V) => (d1, d2, onConflict) => {
2793
2840
  if (Object.isFrozen(d1)) {
2794
2841
  throw new EastError("Cannot modify frozen Dict", { location });
2795
2842
  }
@@ -2808,7 +2855,7 @@ const builtin_evaluators = {
2808
2855
  });
2809
2856
  return null;
2810
2857
  },
2811
- DictMergeAll: (location, _K, _V) => (d1, d2, mergeFn, initialFn) => {
2858
+ DictMergeAll: (location, _platformDef, _K, _V) => (d1, d2, mergeFn, initialFn) => {
2812
2859
  if (Object.isFrozen(d1)) {
2813
2860
  throw new EastError("Cannot modify frozen Dict", { location });
2814
2861
  }
@@ -2825,13 +2872,13 @@ const builtin_evaluators = {
2825
2872
  });
2826
2873
  return null;
2827
2874
  },
2828
- DictKeys: (_location, K, _V) => {
2875
+ DictKeys: (_location, _platformDef, K, _V) => {
2829
2876
  const compare = compareFor(K);
2830
2877
  return (d) => {
2831
2878
  return new SortedSet([...d.keys()], compare);
2832
2879
  };
2833
2880
  },
2834
- DictGetKeys: (location, K, _V) => {
2881
+ DictGetKeys: (location, _platformDef, K, _V) => {
2835
2882
  const compare = compareFor(K);
2836
2883
  return (d, keys, onMissing) => {
2837
2884
  const result = new SortedMap([], compare);
@@ -2848,7 +2895,7 @@ const builtin_evaluators = {
2848
2895
  return result;
2849
2896
  };
2850
2897
  },
2851
- DictForEach: (location, _K, _V, _T2) => (d, f) => {
2898
+ DictForEach: (location, _platformDef, _K, _V, _T2) => (d, f) => {
2852
2899
  lockForIteration(d);
2853
2900
  try {
2854
2901
  d.forEach((v, k) => {
@@ -2860,13 +2907,13 @@ const builtin_evaluators = {
2860
2907
  unlockForIteration(d);
2861
2908
  }
2862
2909
  },
2863
- DictCopy: (_location, K, _V) => {
2910
+ DictCopy: (_location, _platformDef, K, _V) => {
2864
2911
  const compare = compareFor(K);
2865
2912
  return (d) => {
2866
2913
  return new SortedMap([...d], compare);
2867
2914
  };
2868
2915
  },
2869
- DictMap: (location, K, _V, _V2) => {
2916
+ DictMap: (location, _platformDef, K, _V, _V2) => {
2870
2917
  const compare = compareFor(K);
2871
2918
  return (d, f) => {
2872
2919
  const result = new SortedMap([], compare);
@@ -2883,7 +2930,7 @@ const builtin_evaluators = {
2883
2930
  }
2884
2931
  };
2885
2932
  },
2886
- DictFilter: (location, K, _V) => {
2933
+ DictFilter: (location, _platformDef, K, _V) => {
2887
2934
  const compare = compareFor(K);
2888
2935
  return (d, f) => {
2889
2936
  const result = new SortedMap([], compare);
@@ -2902,7 +2949,7 @@ const builtin_evaluators = {
2902
2949
  }
2903
2950
  };
2904
2951
  },
2905
- DictFilterMap: (location, K, _V, _V2) => {
2952
+ DictFilterMap: (location, _platformDef, K, _V, _V2) => {
2906
2953
  const compare = compareFor(K);
2907
2954
  return (d, f) => {
2908
2955
  const result = new SortedMap([], compare);
@@ -2921,7 +2968,7 @@ const builtin_evaluators = {
2921
2968
  }
2922
2969
  };
2923
2970
  },
2924
- DictFirstMap: (location, _K, _V, _T2) => (d, f) => {
2971
+ DictFirstMap: (location, _platformDef, _K, _V, _T2) => (d, f) => {
2925
2972
  lockForIteration(d);
2926
2973
  try {
2927
2974
  for (const [k, v] of d) {
@@ -2936,7 +2983,7 @@ const builtin_evaluators = {
2936
2983
  unlockForIteration(d);
2937
2984
  }
2938
2985
  },
2939
- DictMapReduce: (location, _K, _V, _T2) => (d, mapFn, reduceFn) => {
2986
+ DictMapReduce: (location, _platformDef, _K, _V, _T2) => (d, mapFn, reduceFn) => {
2940
2987
  if (d.size === 0) {
2941
2988
  throw new EastError("Cannot reduce empty dictionary with no initial value", { location });
2942
2989
  }
@@ -2955,7 +3002,7 @@ const builtin_evaluators = {
2955
3002
  unlockForIteration(d);
2956
3003
  }
2957
3004
  },
2958
- DictReduce: (location, _K, _V, _T2) => (d, f, init) => {
3005
+ DictReduce: (location, _platformDef, _K, _V, _T2) => (d, f, init) => {
2959
3006
  let acc = init;
2960
3007
  lockForIteration(d);
2961
3008
  try {
@@ -2968,7 +3015,7 @@ const builtin_evaluators = {
2968
3015
  unlockForIteration(d);
2969
3016
  }
2970
3017
  },
2971
- DictToArray: (location, _K, _V, _T2) => (d, valueFn) => {
3018
+ DictToArray: (location, _platformDef, _K, _V, _T2) => (d, valueFn) => {
2972
3019
  const ret = [];
2973
3020
  lockForIteration(d);
2974
3021
  try {
@@ -2982,7 +3029,7 @@ const builtin_evaluators = {
2982
3029
  unlockForIteration(d);
2983
3030
  }
2984
3031
  },
2985
- DictToSet: (location, _K, _V, K2) => {
3032
+ DictToSet: (location, _platformDef, _K, _V, K2) => {
2986
3033
  const compare = compareFor(K2);
2987
3034
  return (d, fn) => {
2988
3035
  const result = new SortedSet([], compare);
@@ -2999,7 +3046,7 @@ const builtin_evaluators = {
2999
3046
  }
3000
3047
  };
3001
3048
  },
3002
- DictToDict: (location, K, _V, K2, _V2) => {
3049
+ DictToDict: (location, _platformDef, K, _V, K2, _V2) => {
3003
3050
  const compare = compareFor(K2);
3004
3051
  return (d, keyFn, valueFn, onConflict) => {
3005
3052
  const result = new SortedMap([], compare);
@@ -3024,7 +3071,7 @@ const builtin_evaluators = {
3024
3071
  }
3025
3072
  };
3026
3073
  },
3027
- DictFlattenToArray: (location, _K, _V, _T2) => (d, fn) => {
3074
+ DictFlattenToArray: (location, _platformDef, _K, _V, _T2) => (d, fn) => {
3028
3075
  const ret = [];
3029
3076
  lockForIteration(d);
3030
3077
  try {
@@ -3040,7 +3087,7 @@ const builtin_evaluators = {
3040
3087
  unlockForIteration(d);
3041
3088
  }
3042
3089
  },
3043
- DictFlattenToSet: (location, _K, _V, K2) => {
3090
+ DictFlattenToSet: (location, _platformDef, _K, _V, K2) => {
3044
3091
  const compare = compareFor(K2);
3045
3092
  return (d, fn) => {
3046
3093
  const result = new SortedSet([], compare);
@@ -3059,7 +3106,7 @@ const builtin_evaluators = {
3059
3106
  }
3060
3107
  };
3061
3108
  },
3062
- DictFlattenToDict: (location, _K, _V, K2, _V2) => {
3109
+ DictFlattenToDict: (location, _platformDef, _K, _V, K2, _V2) => {
3063
3110
  const compare = compareFor(K2);
3064
3111
  return (d, fn, onConflict) => {
3065
3112
  const result = new SortedMap([], compare);
@@ -3085,7 +3132,7 @@ const builtin_evaluators = {
3085
3132
  }
3086
3133
  };
3087
3134
  },
3088
- DictGroupFold: (location, _K, _V, K2, _T2) => {
3135
+ DictGroupFold: (location, _platformDef, _K, _V, K2, _T2) => {
3089
3136
  const compare = compareFor(K2);
3090
3137
  return (d, keyFn, init, folder) => {
3091
3138
  const result = new SortedMap([], compare);