solve-engine 1.0.1 → 1.1.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.
- package/dist/{BytecodeBuilder-B0xskcv5.d.cts → BytecodeBuilder-Bp9xeTmX.d.cts} +4 -0
- package/dist/{BytecodeBuilder-B0xskcv5.d.ts → BytecodeBuilder-Bp9xeTmX.d.ts} +4 -0
- package/dist/{Configuration-B-G5gTRn.d.cts → Configuration-C9W8tJv_.d.cts} +53 -1
- package/dist/{Configuration-B-G5gTRn.d.ts → Configuration-C9W8tJv_.d.ts} +53 -1
- package/dist/{EngineError-LU7W7AgI.d.cts → EngineError-B61GS1jp.d.cts} +14 -0
- package/dist/{EngineError-LU7W7AgI.d.ts → EngineError-B61GS1jp.d.ts} +14 -0
- package/dist/FormattingSettings-CJHyxcYu.d.cts +27 -0
- package/dist/FormattingSettings-CJHyxcYu.d.ts +27 -0
- package/dist/{Lexer-D78E2yDW.d.cts → Lexer-BOs7euZe.d.cts} +58 -1
- package/dist/{Lexer-BN5mt30n.d.ts → Lexer-CSI_lwbW.d.ts} +58 -1
- package/dist/PackageCompatibility-B-7rK1TD.d.cts +76 -0
- package/dist/PackageCompatibility-Dh59eF-X.d.ts +76 -0
- package/dist/{PackageRegistry-B37mRvvz.d.cts → PackageRegistry-BHWJP83F.d.cts} +449 -11
- package/dist/{PackageRegistry-DCUEzbQt.d.ts → PackageRegistry-_8rDlvxI.d.ts} +449 -11
- package/dist/{Parselet-BaySkMV3.d.ts → Parselet-BBT8riYh.d.ts} +12 -3
- package/dist/{Parselet-DuI1Pjiq.d.cts → Parselet-BHcgK9S7.d.cts} +12 -3
- package/dist/{ScopeManager-B6GzdhVG.d.cts → ScopeManager-8vf02dwj.d.cts} +56 -5
- package/dist/{ScopeManager-udv4Twwq.d.ts → ScopeManager-CxA24W5n.d.ts} +56 -5
- package/dist/{Token-BzG5G4ja.d.cts → Token-B1hdkedD.d.cts} +9 -0
- package/dist/{Token-BzG5G4ja.d.ts → Token-B1hdkedD.d.ts} +9 -0
- package/dist/{TokenNormalizer-t_GotBxr.d.ts → TokenNormalizer-C6VzZgHa.d.ts} +1 -1
- package/dist/{TokenNormalizer-DGVa24Q-.d.cts → TokenNormalizer-DRc1Js1V.d.cts} +1 -1
- package/dist/{VMCheckpoints-DwLjivM7.d.cts → VMCheckpoints-ELYqITdF.d.cts} +3 -3
- package/dist/{VMCheckpoints-BiaIlOOY.d.ts → VMCheckpoints-MK--EBH2.d.ts} +3 -3
- package/dist/{Value-CXJqDH9J.d.cts → Value-BUi1RA3S.d.cts} +124 -5
- package/dist/{Value-CXJqDH9J.d.ts → Value-BUi1RA3S.d.ts} +124 -5
- package/dist/WorkerError-_-RkoQ5P.d.ts +75 -0
- package/dist/WorkerError-gzmaopj2.d.cts +75 -0
- package/dist/{chunk-GQCOSXMG.js → chunk-267JPOTF.js} +43 -5
- package/dist/chunk-267JPOTF.js.map +1 -0
- package/dist/{chunk-JMXUNXQS.cjs → chunk-2TZKENDH.cjs} +51 -8
- package/dist/chunk-2TZKENDH.cjs.map +1 -0
- package/dist/chunk-3OWCDIPN.js +215 -0
- package/dist/chunk-3OWCDIPN.js.map +1 -0
- package/dist/{chunk-VB37OC6I.js → chunk-4D6NIHE2.js} +40 -3
- package/dist/chunk-4D6NIHE2.js.map +1 -0
- package/dist/{chunk-TY3TLZAW.cjs → chunk-536WPM2V.cjs} +18 -2
- package/dist/chunk-536WPM2V.cjs.map +1 -0
- package/dist/chunk-5HRB36DK.js +405 -0
- package/dist/chunk-5HRB36DK.js.map +1 -0
- package/dist/chunk-5ON7PUAZ.js +12 -0
- package/dist/chunk-5ON7PUAZ.js.map +1 -0
- package/dist/{chunk-KV7UW6T6.js → chunk-7KYSUDQO.js} +12 -5
- package/dist/chunk-7KYSUDQO.js.map +1 -0
- package/dist/{chunk-6WFMPTGB.cjs → chunk-7ZX6B7SY.cjs} +774 -528
- package/dist/chunk-7ZX6B7SY.cjs.map +1 -0
- package/dist/chunk-ALYRJ72W.cjs +434 -0
- package/dist/chunk-ALYRJ72W.cjs.map +1 -0
- package/dist/{chunk-5KMIY374.cjs → chunk-B4HBEFTB.cjs} +17 -2
- package/dist/chunk-B4HBEFTB.cjs.map +1 -0
- package/dist/chunk-B7NLZMQ3.cjs +74 -0
- package/dist/chunk-B7NLZMQ3.cjs.map +1 -0
- package/dist/{chunk-UQ3UIZJC.js → chunk-BLI4NIQY.js} +6 -2
- package/dist/chunk-BLI4NIQY.js.map +1 -0
- package/dist/{chunk-BHTNFEGZ.cjs → chunk-C75AFGVD.cjs} +11 -11
- package/dist/{chunk-BHTNFEGZ.cjs.map → chunk-C75AFGVD.cjs.map} +1 -1
- package/dist/{chunk-G535KJEG.js → chunk-CCBZZQAE.js} +2 -2
- package/dist/{chunk-G535KJEG.js.map → chunk-CCBZZQAE.js.map} +1 -1
- package/dist/chunk-CKQMXMHR.cjs +219 -0
- package/dist/chunk-CKQMXMHR.cjs.map +1 -0
- package/dist/{chunk-PFUESQTW.cjs → chunk-EJ3ILXX6.cjs} +48 -2
- package/dist/chunk-EJ3ILXX6.cjs.map +1 -0
- package/dist/{chunk-526PMQOA.js → chunk-ENKKJYD3.js} +10 -4
- package/dist/chunk-ENKKJYD3.js.map +1 -0
- package/dist/{chunk-5X2PTP6F.cjs → chunk-ENRIK36Q.cjs} +2 -12
- package/dist/chunk-ENRIK36Q.cjs.map +1 -0
- package/dist/{chunk-3D7V24DG.js → chunk-ERCOHGXD.js} +17 -2
- package/dist/chunk-ERCOHGXD.js.map +1 -0
- package/dist/{chunk-IF532O7C.js → chunk-FD5ZZHEU.js} +3 -12
- package/dist/chunk-FD5ZZHEU.js.map +1 -0
- package/dist/{chunk-TBN7DEHO.js → chunk-G7Z4HJQA.js} +11 -5
- package/dist/chunk-G7Z4HJQA.js.map +1 -0
- package/dist/{chunk-QY25VWBF.js → chunk-GQMUHVE3.js} +142 -6
- package/dist/chunk-GQMUHVE3.js.map +1 -0
- package/dist/chunk-GUG7SNSV.js +1764 -0
- package/dist/chunk-GUG7SNSV.js.map +1 -0
- package/dist/{chunk-UM6BVY2S.cjs → chunk-HIQ5HSZL.cjs} +175 -43
- package/dist/chunk-HIQ5HSZL.cjs.map +1 -0
- package/dist/{chunk-HVQFNJKE.cjs → chunk-HVRVSI2Z.cjs} +104 -86
- package/dist/chunk-HVRVSI2Z.cjs.map +1 -0
- package/dist/{chunk-3LAEG75D.js → chunk-I4GAWIPW.js} +24 -6
- package/dist/chunk-I4GAWIPW.js.map +1 -0
- package/dist/{chunk-PA4VC73I.cjs → chunk-J45BCEZ4.cjs} +33 -27
- package/dist/chunk-J45BCEZ4.cjs.map +1 -0
- package/dist/{chunk-V5PYO44Y.js → chunk-JIPATHVY.js} +1853 -2638
- package/dist/chunk-JIPATHVY.js.map +1 -0
- package/dist/{chunk-YPPPYLSR.js → chunk-JJIXHXFQ.js} +5 -5
- package/dist/{chunk-YPPPYLSR.js.map → chunk-JJIXHXFQ.js.map} +1 -1
- package/dist/chunk-L2TE7PMO.cjs +14 -0
- package/dist/chunk-L2TE7PMO.cjs.map +1 -0
- package/dist/{chunk-B7TLZABL.cjs → chunk-MG6Q3DUO.cjs} +1962 -2746
- package/dist/chunk-MG6Q3DUO.cjs.map +1 -0
- package/dist/{chunk-R3PY4G7J.js → chunk-MVTOCRV2.js} +48 -3
- package/dist/chunk-MVTOCRV2.js.map +1 -0
- package/dist/{chunk-Y7FT4IQT.js → chunk-NKW7LKYU.js} +266 -28
- package/dist/chunk-NKW7LKYU.js.map +1 -0
- package/dist/{chunk-O3ANBHSA.js → chunk-NNQ2TYDF.js} +123 -5
- package/dist/chunk-NNQ2TYDF.js.map +1 -0
- package/dist/{chunk-5F4C26RU.js → chunk-OADDUPT3.js} +4 -4
- package/dist/{chunk-5F4C26RU.js.map → chunk-OADDUPT3.js.map} +1 -1
- package/dist/{chunk-3AFRJYP4.cjs → chunk-OTN6SZOD.cjs} +1868 -393
- package/dist/chunk-OTN6SZOD.cjs.map +1 -0
- package/dist/{chunk-5LI5EPGJ.cjs → chunk-QFTDTX6K.cjs} +40 -3
- package/dist/chunk-QFTDTX6K.cjs.map +1 -0
- package/dist/{chunk-HMOISHXR.js → chunk-RRLHC37V.js} +1530 -57
- package/dist/chunk-RRLHC37V.js.map +1 -0
- package/dist/chunk-SNHVVOJK.cjs +1768 -0
- package/dist/chunk-SNHVVOJK.cjs.map +1 -0
- package/dist/{chunk-HDP7VK3C.cjs → chunk-SRGQ72IR.cjs} +649 -349
- package/dist/chunk-SRGQ72IR.cjs.map +1 -0
- package/dist/{chunk-4B2CNWQU.cjs → chunk-SSV46KFA.cjs} +14 -7
- package/dist/chunk-SSV46KFA.cjs.map +1 -0
- package/dist/{chunk-AJA6LUI7.js → chunk-UO6BUV6K.js} +18 -2
- package/dist/chunk-UO6BUV6K.js.map +1 -0
- package/dist/chunk-WWQEY7BV.js +67 -0
- package/dist/chunk-WWQEY7BV.js.map +1 -0
- package/dist/{chunk-5WVP4YHP.js → chunk-WXEHD6TT.js} +333 -33
- package/dist/chunk-WXEHD6TT.js.map +1 -0
- package/dist/{chunk-47LRVGOT.cjs → chunk-XA4CKRML.cjs} +2 -2
- package/dist/{chunk-47LRVGOT.cjs.map → chunk-XA4CKRML.cjs.map} +1 -1
- package/dist/{chunk-6KFYJ6TD.cjs → chunk-XIYYHA65.cjs} +6 -2
- package/dist/chunk-XIYYHA65.cjs.map +1 -0
- package/dist/{chunk-KBSXGXPM.cjs → chunk-XJGJCF2R.cjs} +6 -6
- package/dist/{chunk-KBSXGXPM.cjs.map → chunk-XJGJCF2R.cjs.map} +1 -1
- package/dist/{chunk-YWQ6V4ZN.cjs → chunk-YTIYVHL7.cjs} +211 -75
- package/dist/chunk-YTIYVHL7.cjs.map +1 -0
- package/dist/{chunk-TMA4RCEN.js → chunk-Z7XGGLI2.js} +3 -3
- package/dist/{chunk-TMA4RCEN.js.map → chunk-Z7XGGLI2.js.map} +1 -1
- package/dist/{chunk-A2N2GFCG.cjs → chunk-ZVTWQLK4.cjs} +10 -10
- package/dist/{chunk-A2N2GFCG.cjs.map → chunk-ZVTWQLK4.cjs.map} +1 -1
- package/dist/{chunk-2XLQPQKI.cjs → chunk-ZXCESUJS.cjs} +15 -9
- package/dist/chunk-ZXCESUJS.cjs.map +1 -0
- package/dist/constants.cjs +5 -5
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +2 -2
- package/dist/engine.cjs +52 -35
- package/dist/engine.d.cts +13 -13
- package/dist/engine.d.ts +13 -13
- package/dist/engine.js +26 -21
- package/dist/errors.cjs +44 -19
- package/dist/errors.d.cts +3 -2
- package/dist/errors.d.ts +3 -2
- package/dist/errors.js +2 -1
- package/dist/format.cjs +19 -169
- package/dist/format.cjs.map +1 -1
- package/dist/format.d.cts +18 -26
- package/dist/format.d.ts +18 -26
- package/dist/format.js +7 -171
- package/dist/format.js.map +1 -1
- package/dist/index.cjs +250 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -74
- package/dist/index.d.ts +110 -74
- package/dist/index.js +228 -23
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +9 -9
- package/dist/language.d.cts +12 -12
- package/dist/language.d.ts +12 -12
- package/dist/language.js +3 -3
- package/dist/lexer.cjs +16 -16
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +5 -5
- package/dist/normalizer.cjs +10 -10
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +4 -4
- package/dist/packages.cjs +45 -36
- package/dist/packages.d.cts +135 -31
- package/dist/packages.d.ts +135 -31
- package/dist/packages.js +14 -13
- package/dist/parser.cjs +16 -16
- package/dist/parser.d.cts +6 -5
- package/dist/parser.d.ts +6 -5
- package/dist/parser.js +6 -6
- package/dist/{pipeline-BEb3hujr.d.cts → pipeline-CtfJtPQc.d.cts} +3 -3
- package/dist/{pipeline-B6k5lCB7.d.ts → pipeline-DCd5M6Gk.d.ts} +3 -3
- package/dist/resolvers.d.cts +3 -3
- package/dist/resolvers.d.ts +3 -3
- package/dist/testing.cjs +478 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +271 -0
- package/dist/testing.d.ts +271 -0
- package/dist/testing.js +470 -0
- package/dist/testing.js.map +1 -0
- package/dist/uom.cjs +16 -16
- package/dist/uom.d.cts +3 -3
- package/dist/uom.d.ts +3 -3
- package/dist/uom.js +6 -6
- package/dist/utilities.cjs +6 -5
- package/dist/utilities.js +2 -1
- package/dist/vm.cjs +34 -34
- package/dist/vm.d.cts +8 -8
- package/dist/vm.d.ts +8 -8
- package/dist/vm.js +9 -9
- package/dist/worker.cjs +493 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +509 -0
- package/dist/worker.d.ts +509 -0
- package/dist/worker.js +484 -0
- package/dist/worker.js.map +1 -0
- package/package.json +21 -1
- package/dist/chunk-2XLQPQKI.cjs.map +0 -1
- package/dist/chunk-3AFRJYP4.cjs.map +0 -1
- package/dist/chunk-3D7V24DG.js.map +0 -1
- package/dist/chunk-3LAEG75D.js.map +0 -1
- package/dist/chunk-4B2CNWQU.cjs.map +0 -1
- package/dist/chunk-526PMQOA.js.map +0 -1
- package/dist/chunk-5KMIY374.cjs.map +0 -1
- package/dist/chunk-5LI5EPGJ.cjs.map +0 -1
- package/dist/chunk-5WVP4YHP.js.map +0 -1
- package/dist/chunk-5X2PTP6F.cjs.map +0 -1
- package/dist/chunk-6KFYJ6TD.cjs.map +0 -1
- package/dist/chunk-6WFMPTGB.cjs.map +0 -1
- package/dist/chunk-AJA6LUI7.js.map +0 -1
- package/dist/chunk-B7TLZABL.cjs.map +0 -1
- package/dist/chunk-GQCOSXMG.js.map +0 -1
- package/dist/chunk-HDP7VK3C.cjs.map +0 -1
- package/dist/chunk-HMOISHXR.js.map +0 -1
- package/dist/chunk-HVQFNJKE.cjs.map +0 -1
- package/dist/chunk-IF532O7C.js.map +0 -1
- package/dist/chunk-JMXUNXQS.cjs.map +0 -1
- package/dist/chunk-KV7UW6T6.js.map +0 -1
- package/dist/chunk-O3ANBHSA.js.map +0 -1
- package/dist/chunk-PA4VC73I.cjs.map +0 -1
- package/dist/chunk-PFUESQTW.cjs.map +0 -1
- package/dist/chunk-QY25VWBF.js.map +0 -1
- package/dist/chunk-R3PY4G7J.js.map +0 -1
- package/dist/chunk-TBN7DEHO.js.map +0 -1
- package/dist/chunk-TY3TLZAW.cjs.map +0 -1
- package/dist/chunk-UM6BVY2S.cjs.map +0 -1
- package/dist/chunk-UQ3UIZJC.js.map +0 -1
- package/dist/chunk-V5PYO44Y.js.map +0 -1
- package/dist/chunk-VB37OC6I.js.map +0 -1
- package/dist/chunk-Y7FT4IQT.js.map +0 -1
- package/dist/chunk-YWQ6V4ZN.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
3
|
+
var chunkXA4CKRML_cjs = require('./chunk-XA4CKRML.cjs');
|
|
4
|
+
var chunk7ZX6B7SY_cjs = require('./chunk-7ZX6B7SY.cjs');
|
|
5
|
+
var chunkZVTWQLK4_cjs = require('./chunk-ZVTWQLK4.cjs');
|
|
6
|
+
var chunkXIYYHA65_cjs = require('./chunk-XIYYHA65.cjs');
|
|
7
|
+
var chunkHIQ5HSZL_cjs = require('./chunk-HIQ5HSZL.cjs');
|
|
8
|
+
var chunk2TZKENDH_cjs = require('./chunk-2TZKENDH.cjs');
|
|
9
|
+
var chunkEJ3ILXX6_cjs = require('./chunk-EJ3ILXX6.cjs');
|
|
10
10
|
var chunkAMOJYLG2_cjs = require('./chunk-AMOJYLG2.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunkB4HBEFTB_cjs = require('./chunk-B4HBEFTB.cjs');
|
|
12
12
|
|
|
13
13
|
// src/vm/DependencyGraph.ts
|
|
14
14
|
var DependencyGraph = class {
|
|
@@ -332,6 +332,47 @@ var ScopeManager = class {
|
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
334
|
|
|
335
|
+
// src/vm/BusinessDays.ts
|
|
336
|
+
var MS_PER_DAY = 864e5;
|
|
337
|
+
function isWeekend(epochMs) {
|
|
338
|
+
const day = new Date(epochMs).getDay();
|
|
339
|
+
return day === 0 || day === 6;
|
|
340
|
+
}
|
|
341
|
+
function isBusinessDay(epochMs, isHoliday) {
|
|
342
|
+
if (isWeekend(epochMs)) return false;
|
|
343
|
+
return isHoliday ? !isHoliday(epochMs) : true;
|
|
344
|
+
}
|
|
345
|
+
function startOfLocalDay(epochMs) {
|
|
346
|
+
const d = new Date(epochMs);
|
|
347
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
348
|
+
}
|
|
349
|
+
function addBusinessDays(startMs, n, isHoliday, maxCalendarSteps) {
|
|
350
|
+
let remaining = Math.trunc(Math.abs(n));
|
|
351
|
+
const direction = n >= 0 ? 1 : -1;
|
|
352
|
+
const date = new Date(startMs);
|
|
353
|
+
let steps = 0;
|
|
354
|
+
while (remaining > 0) {
|
|
355
|
+
date.setDate(date.getDate() + direction);
|
|
356
|
+
steps++;
|
|
357
|
+
if (steps > maxCalendarSteps) return null;
|
|
358
|
+
if (isBusinessDay(date.getTime(), isHoliday)) remaining--;
|
|
359
|
+
}
|
|
360
|
+
return date.getTime();
|
|
361
|
+
}
|
|
362
|
+
function countBusinessDaysBetween(aMs, bMs, isHoliday, maxCalendarSteps) {
|
|
363
|
+
const startDay = startOfLocalDay(Math.min(aMs, bMs));
|
|
364
|
+
const endDay = startOfLocalDay(Math.max(aMs, bMs));
|
|
365
|
+
const spanDays = Math.round((endDay - startDay) / MS_PER_DAY);
|
|
366
|
+
if (spanDays > maxCalendarSteps) return null;
|
|
367
|
+
let count = 0;
|
|
368
|
+
const date = new Date(startDay);
|
|
369
|
+
for (let i = 0; i <= spanDays; i++) {
|
|
370
|
+
if (isBusinessDay(date.getTime(), isHoliday)) count++;
|
|
371
|
+
date.setDate(date.getDate() + 1);
|
|
372
|
+
}
|
|
373
|
+
return count;
|
|
374
|
+
}
|
|
375
|
+
|
|
335
376
|
// src/vm/VMBuiltinArity.ts
|
|
336
377
|
var BUILTIN_ARITY = {
|
|
337
378
|
0: { name: "sqrt", min: 1, max: 1 },
|
|
@@ -342,7 +383,7 @@ var BUILTIN_ARITY = {
|
|
|
342
383
|
5: { name: "log", min: 1, max: 1 },
|
|
343
384
|
6: { name: "ceil", min: 1, max: 1 },
|
|
344
385
|
7: { name: "floor", min: 1, max: 1 },
|
|
345
|
-
8: { name: "round", min: 1, max:
|
|
386
|
+
8: { name: "round", min: 1, max: 2 },
|
|
346
387
|
// min/max compare as many operands as they are given.
|
|
347
388
|
9: { name: "min", min: 1, max: Infinity },
|
|
348
389
|
10: { name: "max", min: 1, max: Infinity },
|
|
@@ -456,7 +497,7 @@ function builtinArityError(index, argCount) {
|
|
|
456
497
|
const arity = BUILTIN_ARITY[index];
|
|
457
498
|
if (arity === void 0) return void 0;
|
|
458
499
|
if (argCount >= arity.min && argCount <= arity.max) return void 0;
|
|
459
|
-
return
|
|
500
|
+
return chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
460
501
|
"BUILTIN_ARITY_MISMATCH",
|
|
461
502
|
`${arity.name}() takes ${expectation(arity)}, but was given ${argCount === 0 ? "none" : plural(argCount)}`,
|
|
462
503
|
{ functionName: arity.name, expectedMin: arity.min, expectedMax: arity.max, actual: argCount }
|
|
@@ -464,7 +505,7 @@ function builtinArityError(index, argCount) {
|
|
|
464
505
|
}
|
|
465
506
|
|
|
466
507
|
// src/vm/VM.ts
|
|
467
|
-
function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunctionRecursionDepth = 50, maxCollectionSize = 1e5, maxAllocatedElements = 2e6, maxFunctionCalls = 1e4, maxDateOffsetYears = 100, minDateOffsetYears = -100, context =
|
|
508
|
+
function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunctionRecursionDepth = 50, maxCollectionSize = 1e5, maxAllocatedElements = 2e6, maxFunctionCalls = 1e4, maxDateOffsetYears = 100, minDateOffsetYears = -100, context = chunk7ZX6B7SY_cjs.defaultEngineContext, holidayPredicate) {
|
|
468
509
|
const stack = [];
|
|
469
510
|
const variables = /* @__PURE__ */ new Map();
|
|
470
511
|
let instructionCount = 0;
|
|
@@ -498,9 +539,15 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
498
539
|
getMinDateOffsetYears() {
|
|
499
540
|
return minDateOffsetYears;
|
|
500
541
|
},
|
|
542
|
+
// False whenever no calendar was configured, which is what makes
|
|
543
|
+
// unconfigured working-day arithmetic weekends-only. See
|
|
544
|
+
// vm/BusinessDays.ts, the only reader.
|
|
545
|
+
isHoliday(epochMs) {
|
|
546
|
+
return holidayPredicate ? holidayPredicate(epochMs) : false;
|
|
547
|
+
},
|
|
501
548
|
pop() {
|
|
502
549
|
if (stack.length === 0) {
|
|
503
|
-
return
|
|
550
|
+
return chunk2TZKENDH_cjs.numberValue(0);
|
|
504
551
|
}
|
|
505
552
|
return stack.pop();
|
|
506
553
|
},
|
|
@@ -548,7 +595,7 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
548
595
|
},
|
|
549
596
|
pushCallFrame(frame) {
|
|
550
597
|
if (callFrames.length >= maxFunctionRecursionDepth) {
|
|
551
|
-
throw
|
|
598
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
552
599
|
"FUNCTION_RECURSION_LIMIT_EXCEEDED",
|
|
553
600
|
`Function call nesting exceeded maximum depth of ${maxFunctionRecursionDepth} (possible infinite recursion, e.g. f(x) = f(x))`,
|
|
554
601
|
{ maxFunctionRecursionDepth }
|
|
@@ -571,6 +618,12 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
571
618
|
hasUserFunction(name) {
|
|
572
619
|
return userFunctions.has(name);
|
|
573
620
|
},
|
|
621
|
+
getVariableEntries() {
|
|
622
|
+
return Array.from(variables.entries());
|
|
623
|
+
},
|
|
624
|
+
getUserFunctionDefs() {
|
|
625
|
+
return Array.from(userFunctions.values());
|
|
626
|
+
},
|
|
574
627
|
defineEquation(variable, factorNames, rhsProgram) {
|
|
575
628
|
equations.set(variable, { variable, factorNames, rhsProgram });
|
|
576
629
|
},
|
|
@@ -625,7 +678,7 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
625
678
|
incrementInstructions(n) {
|
|
626
679
|
instructionCount += n;
|
|
627
680
|
if (instructionCount > maxInstructions) {
|
|
628
|
-
throw
|
|
681
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution("INSTRUCTION_LIMIT_EXCEEDED", `Execution exceeded maximum of ${maxInstructions} instructions`);
|
|
629
682
|
}
|
|
630
683
|
}
|
|
631
684
|
};
|
|
@@ -643,7 +696,7 @@ function matrixPowerCells(m, exponent) {
|
|
|
643
696
|
}
|
|
644
697
|
function safePop(stack) {
|
|
645
698
|
if (stack.length === 0) {
|
|
646
|
-
throw
|
|
699
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.internal({
|
|
647
700
|
code: "STACK_UNDERFLOW",
|
|
648
701
|
message: "Stack underflow: an opcode expected a value on the stack but it was empty",
|
|
649
702
|
expected: "at least one value on the VM stack",
|
|
@@ -655,11 +708,11 @@ function safePop(stack) {
|
|
|
655
708
|
}
|
|
656
709
|
var MALFORMED_BYTECODE_SUGGESTION = "bytecode is caller input on this entry point: rebuild the program with the engine's compiler, or fix the hand-assembled stream";
|
|
657
710
|
function siteName(site) {
|
|
658
|
-
return typeof site === "number" ?
|
|
711
|
+
return typeof site === "number" ? chunkXIYYHA65_cjs.getOpCodeName(site) : site;
|
|
659
712
|
}
|
|
660
713
|
function malformedBytecode(code, site, problem, expected, found, context = {}) {
|
|
661
714
|
const name = siteName(site);
|
|
662
|
-
return
|
|
715
|
+
return chunkB4HBEFTB_cjs.ErrorFactory.validation({
|
|
663
716
|
code,
|
|
664
717
|
message: `Malformed bytecode: ${name} ${problem}`,
|
|
665
718
|
expected,
|
|
@@ -723,7 +776,7 @@ function stringOperand(value, site, role) {
|
|
|
723
776
|
site,
|
|
724
777
|
`expected a ${role ?? "string"} on the stack`,
|
|
725
778
|
role ? `a string value holding the ${role}` : "a string value",
|
|
726
|
-
`a ${
|
|
779
|
+
`a ${chunk2TZKENDH_cjs.ValueType[value.type] ?? "unknown"} value`,
|
|
727
780
|
role ? { role, valueType: value.type } : { valueType: value.type }
|
|
728
781
|
);
|
|
729
782
|
}
|
|
@@ -782,7 +835,7 @@ function invokeFrameBody(params, program, args, vm, pipeline, expression, contex
|
|
|
782
835
|
vm.popCallFrame();
|
|
783
836
|
}
|
|
784
837
|
if (bodyResult.type === "pending") {
|
|
785
|
-
throw
|
|
838
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
786
839
|
"MAP_REDUCE_ASYNC_UNSUPPORTED",
|
|
787
840
|
`map/reduce transform bodies calling an async operation (weather, stocks, currency, ...) aren't supported`
|
|
788
841
|
);
|
|
@@ -794,7 +847,7 @@ function invokeFrameBody(params, program, args, vm, pipeline, expression, contex
|
|
|
794
847
|
}
|
|
795
848
|
function invokeWithBoundUnknown(name, program, vm, pipeline, expression, context, symbolicTolerant) {
|
|
796
849
|
const frame = new Map(vm.getCallFrame());
|
|
797
|
-
frame.set(name,
|
|
850
|
+
frame.set(name, chunk2TZKENDH_cjs.symbolicValue(chunkHIQ5HSZL_cjs.varNode(name)));
|
|
798
851
|
vm.pushCallFrame(frame);
|
|
799
852
|
let bodyResult;
|
|
800
853
|
try {
|
|
@@ -803,7 +856,7 @@ function invokeWithBoundUnknown(name, program, vm, pipeline, expression, context
|
|
|
803
856
|
vm.popCallFrame();
|
|
804
857
|
}
|
|
805
858
|
if (bodyResult.type === "pending") {
|
|
806
|
-
throw
|
|
859
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
807
860
|
"SYMBOLIC_ASYNC_UNSUPPORTED",
|
|
808
861
|
`an algebra verb's expression cannot call an async operation (weather, stocks, currency, ...)`
|
|
809
862
|
);
|
|
@@ -834,31 +887,64 @@ function moneyTimesQuantity(l, r) {
|
|
|
834
887
|
const rightUnit = r.unit;
|
|
835
888
|
if (leftUnit === void 0 || rightUnit === void 0) return null;
|
|
836
889
|
if (leftUnit.includes("/") || rightUnit.includes("/")) return null;
|
|
837
|
-
const leftIsMoney =
|
|
838
|
-
const rightIsMoney =
|
|
890
|
+
const leftIsMoney = chunkHIQ5HSZL_cjs.CURRENCY_DISPLAY[leftUnit.toUpperCase()] !== void 0;
|
|
891
|
+
const rightIsMoney = chunkHIQ5HSZL_cjs.CURRENCY_DISPLAY[rightUnit.toUpperCase()] !== void 0;
|
|
839
892
|
if (leftIsMoney === rightIsMoney) return null;
|
|
840
|
-
return
|
|
893
|
+
return chunk2TZKENDH_cjs.uomValue(l.toNumber() * r.toNumber(), leftIsMoney ? leftUnit : rightUnit);
|
|
841
894
|
}
|
|
842
895
|
function combinePercentage(l, r, sign) {
|
|
843
896
|
if (l.type === 5 /* Percentage */) {
|
|
844
897
|
if (r.type === 6 /* Uom */ && r.unit !== void 0) {
|
|
845
|
-
return
|
|
898
|
+
return chunk7ZX6B7SY_cjs.scaleMoneyByPercent(r, r.unit, l.toNumber(), sign);
|
|
846
899
|
}
|
|
847
900
|
if (r.type !== 5 /* Percentage */ && r.type !== 0 /* Number */) return null;
|
|
848
|
-
return
|
|
901
|
+
return chunk2TZKENDH_cjs.percentageValue(l.toNumber() + sign * r.toNumber());
|
|
849
902
|
}
|
|
850
903
|
if (r.type !== 5 /* Percentage */) return null;
|
|
851
904
|
const factor = 1 + sign * r.toNumber();
|
|
852
|
-
if (l.type === 0 /* Number */)
|
|
853
|
-
|
|
905
|
+
if (l.type === 0 /* Number */) {
|
|
906
|
+
const scaled = l.toNumber() * factor;
|
|
907
|
+
if (l.uncertainty !== void 0) return chunk2TZKENDH_cjs.numberValueUncertain(scaled, Math.abs(l.uncertainty * factor));
|
|
908
|
+
return chunk2TZKENDH_cjs.numberValue(scaled);
|
|
909
|
+
}
|
|
910
|
+
if (l.type === 6 /* Uom */ && l.unit !== void 0) return chunk7ZX6B7SY_cjs.scaleMoneyByPercent(l, l.unit, r.toNumber(), sign);
|
|
911
|
+
return null;
|
|
912
|
+
}
|
|
913
|
+
function multiplyPercentWithUncertainty(l, r) {
|
|
914
|
+
const pct = l.type === 5 /* Percentage */ ? l : r.type === 5 /* Percentage */ ? r : null;
|
|
915
|
+
if (pct === null) return null;
|
|
916
|
+
const other = pct === l ? r : l;
|
|
917
|
+
if (other.type !== 0 /* Number */ || other.uncertainty === void 0) return null;
|
|
918
|
+
const factor = pct.toNumber();
|
|
919
|
+
return chunk2TZKENDH_cjs.numberValueUncertain(other.toNumber() * factor, Math.abs(other.uncertainty * factor));
|
|
920
|
+
}
|
|
921
|
+
function multiplyMoneyByScalarExact(l, r) {
|
|
922
|
+
const money = l.type === 6 /* Uom */ ? l : r;
|
|
923
|
+
const scalar = l.type === 6 /* Uom */ ? r : l;
|
|
924
|
+
if (money.type !== 6 /* Uom */ || money.unit === void 0 || !chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(money.unit)) return null;
|
|
925
|
+
if (scalar.type !== 0 /* Number */ && scalar.type !== 5 /* Percentage */) return null;
|
|
926
|
+
if (scalar.rational !== void 0) return null;
|
|
927
|
+
return chunk7ZX6B7SY_cjs.scaleMoneyExact(money, scalar.toNumber(), money.unit);
|
|
928
|
+
}
|
|
929
|
+
function dividePercentWithUncertainty(l, r) {
|
|
930
|
+
if (r.type === 5 /* Percentage */ && l.type === 0 /* Number */ && l.uncertainty !== void 0) {
|
|
931
|
+
const factor = r.toNumber();
|
|
932
|
+
if (factor === 0) return null;
|
|
933
|
+
return chunk2TZKENDH_cjs.numberValueUncertain(l.toNumber() / factor, Math.abs(l.uncertainty / factor));
|
|
934
|
+
}
|
|
935
|
+
if (l.type === 5 /* Percentage */ && r.type === 0 /* Number */ && r.uncertainty !== void 0) {
|
|
936
|
+
const b = r.toNumber();
|
|
937
|
+
if (b === 0) return null;
|
|
938
|
+
return chunk2TZKENDH_cjs.numberValueUncertain(l.toNumber() / b, Math.abs(l.toNumber() * r.uncertainty / (b * b)));
|
|
939
|
+
}
|
|
854
940
|
return null;
|
|
855
941
|
}
|
|
856
942
|
function extractDurationMs(value) {
|
|
857
943
|
if (value.type === 6 /* Uom */) {
|
|
858
944
|
const unit = value.unit;
|
|
859
|
-
if (unit &&
|
|
945
|
+
if (unit && chunkEJ3ILXX6_cjs.getMeasure(unit) === "time") {
|
|
860
946
|
try {
|
|
861
|
-
return
|
|
947
|
+
return chunkEJ3ILXX6_cjs.convertUnit(value.toNumber(), unit, "ms");
|
|
862
948
|
} catch {
|
|
863
949
|
}
|
|
864
950
|
}
|
|
@@ -867,27 +953,30 @@ function extractDurationMs(value) {
|
|
|
867
953
|
return value.toNumber();
|
|
868
954
|
}
|
|
869
955
|
var WORKDAYS_PER_YEAR = 260;
|
|
870
|
-
function
|
|
871
|
-
|
|
956
|
+
function addBusinessDays2(epochMs, n, vm) {
|
|
957
|
+
const remaining = Math.trunc(Math.abs(n));
|
|
872
958
|
const direction = n >= 0 ? 1 : -1;
|
|
873
959
|
const limitYears = direction > 0 ? vm.getMaxDateOffsetYears() : -vm.getMinDateOffsetYears();
|
|
874
960
|
const limitWorkdays = Math.floor(limitYears * WORKDAYS_PER_YEAR);
|
|
875
961
|
if (remaining > limitWorkdays) {
|
|
876
|
-
throw
|
|
962
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
877
963
|
"DATE_OFFSET_LIMIT_EXCEEDED",
|
|
878
964
|
`A date offset of ${remaining.toLocaleString("en-US")} workdays is about ${Math.round(remaining / WORKDAYS_PER_YEAR).toLocaleString("en-US")} years, past the limit of ${limitYears} years for a workday offset`,
|
|
879
965
|
{ requestedWorkdays: remaining, limitYears, limitWorkdays }
|
|
880
966
|
);
|
|
881
967
|
}
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
968
|
+
const maxCalendarSteps = limitWorkdays * 7 + 7;
|
|
969
|
+
const landed = addBusinessDays(epochMs, n, (ms) => vm.isHoliday(ms), maxCalendarSteps);
|
|
970
|
+
if (landed === null) {
|
|
971
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
972
|
+
"DATE_OFFSET_LIMIT_EXCEEDED",
|
|
973
|
+
`A working-day offset of ${remaining.toLocaleString("en-US")} could not be reached within the ${limitYears}-year limit; the configured holiday calendar leaves too few working days`,
|
|
974
|
+
{ requestedWorkdays: remaining, limitYears, maxCalendarSteps }
|
|
975
|
+
);
|
|
887
976
|
}
|
|
888
|
-
return
|
|
977
|
+
return landed;
|
|
889
978
|
}
|
|
890
|
-
var
|
|
979
|
+
var MS_PER_DAY2 = 864e5;
|
|
891
980
|
var CALENDAR_MONTHS_PER_UNIT = {
|
|
892
981
|
month: 1,
|
|
893
982
|
months: 1,
|
|
@@ -913,8 +1002,8 @@ function addCalendarDays(epochMs, days) {
|
|
|
913
1002
|
const date = new Date(epochMs);
|
|
914
1003
|
date.setDate(date.getDate() + whole);
|
|
915
1004
|
const shifted = date.getTime();
|
|
916
|
-
if (Number.isNaN(shifted)) return epochMs + days *
|
|
917
|
-
return shifted + (days - whole) *
|
|
1005
|
+
if (Number.isNaN(shifted)) return epochMs + days * MS_PER_DAY2;
|
|
1006
|
+
return shifted + (days - whole) * MS_PER_DAY2;
|
|
918
1007
|
}
|
|
919
1008
|
function addCalendarMonths(epochMs, months) {
|
|
920
1009
|
const whole = Math.trunc(months);
|
|
@@ -924,7 +1013,7 @@ function addCalendarMonths(epochMs, months) {
|
|
|
924
1013
|
date.setMonth(date.getMonth() + whole);
|
|
925
1014
|
date.setDate(Math.min(dayOfMonth, daysInMonth(date.getFullYear(), date.getMonth())));
|
|
926
1015
|
const shifted = date.getTime();
|
|
927
|
-
const monthMs =
|
|
1016
|
+
const monthMs = chunkEJ3ILXX6_cjs.convertUnit(1, "month", "ms");
|
|
928
1017
|
if (Number.isNaN(shifted)) return epochMs + months * monthMs;
|
|
929
1018
|
return shifted + (months - whole) * monthMs;
|
|
930
1019
|
}
|
|
@@ -932,13 +1021,13 @@ function shiftDatetime(epochMs, duration, sign, vm) {
|
|
|
932
1021
|
if (duration.type === 6 /* Uom */ && duration.unit !== void 0) {
|
|
933
1022
|
const unit = duration.unit;
|
|
934
1023
|
const amount = sign * duration.toNumber();
|
|
935
|
-
if (
|
|
1024
|
+
if (chunkEJ3ILXX6_cjs.isWorkdayUnit(unit)) return addBusinessDays2(epochMs, amount, vm);
|
|
936
1025
|
const monthsPerUnit = CALENDAR_MONTHS_PER_UNIT[unit];
|
|
937
1026
|
if (monthsPerUnit !== void 0) return addCalendarMonths(epochMs, amount * monthsPerUnit);
|
|
938
|
-
if (
|
|
1027
|
+
if (chunkEJ3ILXX6_cjs.getMeasure(unit) === "time") {
|
|
939
1028
|
let daysPerUnit = 0;
|
|
940
1029
|
try {
|
|
941
|
-
daysPerUnit =
|
|
1030
|
+
daysPerUnit = chunkEJ3ILXX6_cjs.convertUnit(1, unit, "day");
|
|
942
1031
|
} catch {
|
|
943
1032
|
}
|
|
944
1033
|
if (Number.isInteger(daysPerUnit) && daysPerUnit >= 1) {
|
|
@@ -949,34 +1038,35 @@ function shiftDatetime(epochMs, duration, sign, vm) {
|
|
|
949
1038
|
return epochMs + sign * extractDurationMs(duration);
|
|
950
1039
|
}
|
|
951
1040
|
function combineTimecode(tc, r, sign) {
|
|
952
|
-
const fps =
|
|
953
|
-
if (r.type === 6 /* Uom */ &&
|
|
954
|
-
const rFps =
|
|
1041
|
+
const fps = chunk2TZKENDH_cjs.timecodeFps(tc.unit);
|
|
1042
|
+
if (r.type === 6 /* Uom */ && chunk2TZKENDH_cjs.isTimecodeUnit(r.unit)) {
|
|
1043
|
+
const rFps = chunk2TZKENDH_cjs.timecodeFps(r.unit);
|
|
955
1044
|
if (rFps !== fps) {
|
|
956
|
-
return
|
|
1045
|
+
return chunk2TZKENDH_cjs.errorValue(
|
|
957
1046
|
"TIMECODE_FPS_MISMATCH",
|
|
958
1047
|
`Cannot combine timecodes at different frame rates (${fps} fps vs ${rFps} fps)`
|
|
959
1048
|
);
|
|
960
1049
|
}
|
|
961
|
-
return sign === 1 ?
|
|
1050
|
+
return sign === 1 ? chunk2TZKENDH_cjs.uomValue(tc.toNumber() + r.toNumber(), tc.unit) : chunk2TZKENDH_cjs.uomValue(tc.toNumber() - r.toNumber(), "frames");
|
|
962
1051
|
}
|
|
963
1052
|
if (r.type === 6 /* Uom */ && r.unit === "frames") {
|
|
964
|
-
return
|
|
1053
|
+
return chunk2TZKENDH_cjs.uomValue(tc.toNumber() + sign * r.toNumber(), tc.unit);
|
|
965
1054
|
}
|
|
966
|
-
if (r.type === 6 /* Uom */ && r.unit &&
|
|
967
|
-
const seconds =
|
|
968
|
-
return
|
|
1055
|
+
if (r.type === 6 /* Uom */ && r.unit && chunkEJ3ILXX6_cjs.getMeasure(r.unit) === "time") {
|
|
1056
|
+
const seconds = chunkEJ3ILXX6_cjs.convertUnit(r.toNumber(), r.unit, "s");
|
|
1057
|
+
return chunk2TZKENDH_cjs.uomValue(tc.toNumber() + sign * seconds * fps, tc.unit);
|
|
969
1058
|
}
|
|
970
|
-
return
|
|
1059
|
+
return chunk2TZKENDH_cjs.uomValue(tc.toNumber() + sign * r.toNumber(), tc.unit);
|
|
971
1060
|
}
|
|
972
1061
|
function isTruthy(value) {
|
|
973
1062
|
if (value.type === 10 /* Boolean */) return value.value;
|
|
974
1063
|
return value.toNumber() !== 0;
|
|
975
1064
|
}
|
|
976
1065
|
function incompatibleConversionError(fromUnit, toUnit) {
|
|
977
|
-
|
|
1066
|
+
const named = chunk7ZX6B7SY_cjs.describeConversionMismatch(fromUnit, toUnit);
|
|
1067
|
+
return chunk2TZKENDH_cjs.errorValue(
|
|
978
1068
|
"INCOMPATIBLE_UNITS",
|
|
979
|
-
`Cannot convert ${fromUnit} to ${toUnit}: they do not measure the same thing`
|
|
1069
|
+
named ?? `Cannot convert ${fromUnit} to ${toUnit}: they do not measure the same thing`
|
|
980
1070
|
);
|
|
981
1071
|
}
|
|
982
1072
|
var MAX_EXACT_POW_BITS = 65536;
|
|
@@ -1008,32 +1098,32 @@ function bigIntBitLength(value) {
|
|
|
1008
1098
|
return magnitude.toString(16).length * 4;
|
|
1009
1099
|
}
|
|
1010
1100
|
function bigIntShift(l, r, direction) {
|
|
1011
|
-
const value =
|
|
1012
|
-
const shift =
|
|
1013
|
-
if (value === 0n) return
|
|
1101
|
+
const value = chunk7ZX6B7SY_cjs.toBigIntOperand(l);
|
|
1102
|
+
const shift = chunk7ZX6B7SY_cjs.toBigIntOperand(r);
|
|
1103
|
+
if (value === 0n) return chunk2TZKENDH_cjs.bigIntValue(0n);
|
|
1014
1104
|
const grownBits = direction * Number(shift);
|
|
1015
1105
|
if (grownBits <= 0 || bigIntBitLength(value) + grownBits <= MAX_EXACT_SHIFT_BITS) {
|
|
1016
|
-
return
|
|
1106
|
+
return chunk2TZKENDH_cjs.bigIntValue(direction === 1 ? value << shift : value >> shift);
|
|
1017
1107
|
}
|
|
1018
|
-
throw
|
|
1108
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
1019
1109
|
"BIGINT_SHIFT_LIMIT_EXCEEDED",
|
|
1020
1110
|
`Shifting by ${shift} would build an exact integer of about ${(bigIntBitLength(value) + grownBits).toLocaleString("en-US")} bits, past the limit of ${MAX_EXACT_SHIFT_BITS.toLocaleString("en-US")} bits`,
|
|
1021
1111
|
{ shift: String(shift), limitBits: MAX_EXACT_SHIFT_BITS }
|
|
1022
1112
|
);
|
|
1023
1113
|
}
|
|
1024
1114
|
function multiplyRateByMatchingUom(rate, multiplier) {
|
|
1025
|
-
const { numerator, denominator } =
|
|
1026
|
-
const rateMeasure =
|
|
1027
|
-
const multiplierMeasure =
|
|
1115
|
+
const { numerator, denominator } = chunk2TZKENDH_cjs.splitRateUnit(rate.unit);
|
|
1116
|
+
const rateMeasure = chunkEJ3ILXX6_cjs.getMeasure(denominator);
|
|
1117
|
+
const multiplierMeasure = chunkEJ3ILXX6_cjs.getMeasure(multiplier.unit);
|
|
1028
1118
|
if (!rateMeasure || rateMeasure !== multiplierMeasure) {
|
|
1029
|
-
return
|
|
1119
|
+
return chunk2TZKENDH_cjs.errorValue(
|
|
1030
1120
|
"RATE_MUL_MEASURE_MISMATCH",
|
|
1031
1121
|
`Cannot multiply a "${denominator}"-denominated rate by "${multiplier.unit}" \u2014 different measures`
|
|
1032
1122
|
);
|
|
1033
1123
|
}
|
|
1034
|
-
const multiplierInDenominatorUnit =
|
|
1124
|
+
const multiplierInDenominatorUnit = chunkEJ3ILXX6_cjs.convertUnit(multiplier.toNumber(), multiplier.unit, denominator);
|
|
1035
1125
|
const total = rate.toNumber() * multiplierInDenominatorUnit;
|
|
1036
|
-
return numerator ?
|
|
1126
|
+
return numerator ? chunk2TZKENDH_cjs.uomValue(total, numerator) : chunk2TZKENDH_cjs.numberValue(total);
|
|
1037
1127
|
}
|
|
1038
1128
|
function toFractionString(n) {
|
|
1039
1129
|
if (Number.isNaN(n)) return "NaN";
|
|
@@ -1062,6 +1152,9 @@ function toFractionString(n) {
|
|
|
1062
1152
|
const numerator = whole * k1 + h1;
|
|
1063
1153
|
return `${negative ? "-" : ""}${numerator}/${k1}`;
|
|
1064
1154
|
}
|
|
1155
|
+
function rationalToFractionString(r) {
|
|
1156
|
+
return r.d === 1n ? String(r.n) : `${r.n}/${r.d}`;
|
|
1157
|
+
}
|
|
1065
1158
|
function toMultiplierString(value) {
|
|
1066
1159
|
const n = value.toNumber();
|
|
1067
1160
|
const multiple = value.type === 5 /* Percentage */ ? 1 + n : n;
|
|
@@ -1079,7 +1172,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1079
1172
|
if (unrunnable) {
|
|
1080
1173
|
return {
|
|
1081
1174
|
type: "error",
|
|
1082
|
-
error:
|
|
1175
|
+
error: chunkB4HBEFTB_cjs.ErrorFactory.validation({
|
|
1083
1176
|
code: "MALFORMED_BYTECODE_PROGRAM",
|
|
1084
1177
|
message: `Malformed bytecode: ${unrunnable}`,
|
|
1085
1178
|
expected: "a BytecodeProgram with opcodes, numbers and strings",
|
|
@@ -1095,16 +1188,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1095
1188
|
const maxStackDepth = vm.getMaxStackDepth();
|
|
1096
1189
|
const stack = vm.getStack();
|
|
1097
1190
|
const shouldTrace = pipeline?.hasCollectors ?? false;
|
|
1098
|
-
const hasArena =
|
|
1099
|
-
if (opcodes.length === 0) return { type: "value", value:
|
|
1100
|
-
|
|
1191
|
+
const hasArena = chunk2TZKENDH_cjs.isArenaActive();
|
|
1192
|
+
if (opcodes.length === 0) return { type: "value", value: chunk2TZKENDH_cjs.numberValue(0) };
|
|
1193
|
+
chunk2TZKENDH_cjs.beginEvaluation(vm);
|
|
1101
1194
|
try {
|
|
1102
1195
|
while (ip < opcodes.length) {
|
|
1103
1196
|
if (++localInstructionCount > maxInstructions) {
|
|
1104
|
-
throw
|
|
1197
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution("INSTRUCTION_LIMIT_EXCEEDED", `Execution exceeded maximum of ${maxInstructions} instructions`);
|
|
1105
1198
|
}
|
|
1106
1199
|
if (stack.length > maxStackDepth) {
|
|
1107
|
-
throw
|
|
1200
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution("STACK_LIMIT_EXCEEDED", `Execution exceeded maximum stack depth of ${maxStackDepth}`);
|
|
1108
1201
|
}
|
|
1109
1202
|
const op = opcodes[ip++];
|
|
1110
1203
|
if (shouldTrace) {
|
|
@@ -1114,11 +1207,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1114
1207
|
unit: v.unit
|
|
1115
1208
|
}));
|
|
1116
1209
|
pipeline.fireVmStep({
|
|
1117
|
-
type:
|
|
1210
|
+
type: chunkXA4CKRML_cjs.DiagnosticEventType.VmStep,
|
|
1118
1211
|
elapsedNs: 0,
|
|
1119
1212
|
expression: expression ?? "",
|
|
1120
1213
|
opcode: op,
|
|
1121
|
-
opcodeName:
|
|
1214
|
+
opcodeName: chunkXIYYHA65_cjs.getOpCodeName(op),
|
|
1122
1215
|
ip: ip - 1,
|
|
1123
1216
|
stackDepth: stack.length,
|
|
1124
1217
|
instructionNumber: localInstructionCount,
|
|
@@ -1133,7 +1226,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1133
1226
|
break;
|
|
1134
1227
|
case 1 /* HALT */: {
|
|
1135
1228
|
const result = safePop(stack);
|
|
1136
|
-
return { type: "value", value: hasArena ?
|
|
1229
|
+
return { type: "value", value: hasArena ? chunk2TZKENDH_cjs.persistentValue(result) : result };
|
|
1137
1230
|
}
|
|
1138
1231
|
case 3 /* DUP */: {
|
|
1139
1232
|
const top = safePop(stack);
|
|
@@ -1156,19 +1249,24 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1156
1249
|
// `BigInt(undefined)`, and an undefined string sat on the stack until
|
|
1157
1250
|
// a unit or converter name was read off it.
|
|
1158
1251
|
case 10 /* PUSH_NUMBER */:
|
|
1159
|
-
stack.push(
|
|
1252
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(numbers[poolIndex(opcodes, ip++, op, "constant-pool index", numbers.length, "number-pool")]));
|
|
1160
1253
|
break;
|
|
1161
1254
|
case 11 /* PUSH_BIGINT */:
|
|
1162
|
-
stack.push(
|
|
1255
|
+
stack.push(chunk2TZKENDH_cjs.bigIntValue(parseBigIntLiteral(poolString(opcodes, ip++, strings, op, "constant-pool index"), op)));
|
|
1163
1256
|
break;
|
|
1257
|
+
case 16 /* PUSH_DECIMAL */: {
|
|
1258
|
+
const dec = chunkHIQ5HSZL_cjs.decimalFromLiteral(poolString(opcodes, ip++, strings, op, "constant-pool index"));
|
|
1259
|
+
stack.push(chunk2TZKENDH_cjs.numberValueExact(chunkHIQ5HSZL_cjs.decimalToNumber(dec), dec));
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1164
1262
|
case 12 /* PUSH_HEX */:
|
|
1165
|
-
stack.push(
|
|
1263
|
+
stack.push(chunk2TZKENDH_cjs.hexValue(numbers[poolIndex(opcodes, ip++, op, "constant-pool index", numbers.length, "number-pool")]));
|
|
1166
1264
|
break;
|
|
1167
1265
|
case 13 /* PUSH_STRING */:
|
|
1168
|
-
stack.push(
|
|
1266
|
+
stack.push(chunk2TZKENDH_cjs.stringValue(poolString(opcodes, ip++, strings, op, "constant-pool index")));
|
|
1169
1267
|
break;
|
|
1170
1268
|
case 14 /* PUSH_BOOLEAN */:
|
|
1171
|
-
stack.push(
|
|
1269
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(operandByte(opcodes, ip++, op, "boolean operand") === 1));
|
|
1172
1270
|
break;
|
|
1173
1271
|
// ═══════════════════════════════════════════════════════════════
|
|
1174
1272
|
// §3 Arithmetic (OpCode 20–27)
|
|
@@ -1177,101 +1275,170 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1177
1275
|
// ═══════════════════════════════════════════════════════════════
|
|
1178
1276
|
case 20 /* ADD */: {
|
|
1179
1277
|
const r = safePop(stack), l = safePop(stack);
|
|
1180
|
-
const addFault =
|
|
1278
|
+
const addFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1181
1279
|
if (addFault) {
|
|
1182
1280
|
stack.push(addFault);
|
|
1183
1281
|
break;
|
|
1184
1282
|
}
|
|
1283
|
+
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1284
|
+
const uncAdd = chunk7ZX6B7SY_cjs.uncertainOp(l, r, "add");
|
|
1285
|
+
if (uncAdd) {
|
|
1286
|
+
stack.push(uncAdd);
|
|
1287
|
+
break;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1291
|
+
const ratAdd = chunk7ZX6B7SY_cjs.exactRationalOp(l, r, "add");
|
|
1292
|
+
if (ratAdd) {
|
|
1293
|
+
stack.push(ratAdd);
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1185
1297
|
const pctAdd = combinePercentage(l, r, 1);
|
|
1186
1298
|
const ratePeriodAdd = pctAdd === null ? unifyRatePeriods(l, r) : null;
|
|
1187
1299
|
if (pctAdd !== null) {
|
|
1188
1300
|
stack.push(pctAdd);
|
|
1189
1301
|
} else if (ratePeriodAdd !== null) {
|
|
1190
|
-
stack.push(
|
|
1302
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(ratePeriodAdd + r.toNumber(), r.unit));
|
|
1191
1303
|
} else if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1192
|
-
stack.push(
|
|
1304
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.value + r.value));
|
|
1193
1305
|
} else if (l.type === 10 /* Boolean */ && r.type === 10 /* Boolean */) {
|
|
1194
|
-
stack.push(
|
|
1306
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value && r.value));
|
|
1195
1307
|
} else if (l.type === 4 /* Datetime */) {
|
|
1196
1308
|
if (r.type === 4 /* Datetime */) {
|
|
1197
|
-
stack.push(
|
|
1309
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("INVALID_DATETIME_OP", "Cannot add two datetimes together"));
|
|
1198
1310
|
} else {
|
|
1199
|
-
stack.push(
|
|
1311
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(shiftDatetime(l.toNumber(), r, 1, vm)));
|
|
1200
1312
|
}
|
|
1201
|
-
} else if (l.type === 6 /* Uom */ &&
|
|
1313
|
+
} else if (l.type === 6 /* Uom */ && chunk2TZKENDH_cjs.isTimecodeUnit(l.unit)) {
|
|
1202
1314
|
stack.push(combineTimecode(l, r, 1));
|
|
1203
1315
|
} else if (r.type === 4 /* Datetime */) {
|
|
1204
|
-
stack.push(
|
|
1316
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(shiftDatetime(r.toNumber(), l, 1, vm)));
|
|
1205
1317
|
} else {
|
|
1206
|
-
stack.push(
|
|
1318
|
+
stack.push(chunk7ZX6B7SY_cjs.binaryOp(l, r, (a, b) => a + b, (a, b) => a + b, "add"));
|
|
1207
1319
|
}
|
|
1208
1320
|
break;
|
|
1209
1321
|
}
|
|
1210
1322
|
case 21 /* SUB */: {
|
|
1211
1323
|
const r = safePop(stack), l = safePop(stack);
|
|
1212
|
-
const subFault =
|
|
1324
|
+
const subFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1213
1325
|
if (subFault) {
|
|
1214
1326
|
stack.push(subFault);
|
|
1215
1327
|
break;
|
|
1216
1328
|
}
|
|
1329
|
+
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1330
|
+
const uncSub = chunk7ZX6B7SY_cjs.uncertainOp(l, r, "sub");
|
|
1331
|
+
if (uncSub) {
|
|
1332
|
+
stack.push(uncSub);
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1337
|
+
const ratSub = chunk7ZX6B7SY_cjs.exactRationalOp(l, r, "sub");
|
|
1338
|
+
if (ratSub) {
|
|
1339
|
+
stack.push(ratSub);
|
|
1340
|
+
break;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1217
1343
|
const pctSub = combinePercentage(l, r, -1);
|
|
1218
1344
|
const ratePeriodSub = pctSub === null ? unifyRatePeriods(l, r) : null;
|
|
1219
1345
|
if (pctSub !== null) {
|
|
1220
1346
|
stack.push(pctSub);
|
|
1221
1347
|
} else if (ratePeriodSub !== null) {
|
|
1222
|
-
stack.push(
|
|
1348
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(ratePeriodSub - r.toNumber(), r.unit));
|
|
1223
1349
|
} else if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1224
|
-
stack.push(
|
|
1350
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.value - r.value));
|
|
1225
1351
|
} else if (l.type === 4 /* Datetime */) {
|
|
1226
1352
|
if (r.type === 4 /* Datetime */) {
|
|
1227
|
-
stack.push(
|
|
1353
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(l.toNumber() - r.toNumber(), "ms"));
|
|
1228
1354
|
} else {
|
|
1229
|
-
stack.push(
|
|
1355
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(shiftDatetime(l.toNumber(), r, -1, vm)));
|
|
1230
1356
|
}
|
|
1231
|
-
} else if (l.type === 6 /* Uom */ &&
|
|
1357
|
+
} else if (l.type === 6 /* Uom */ && chunk2TZKENDH_cjs.isTimecodeUnit(l.unit)) {
|
|
1232
1358
|
stack.push(combineTimecode(l, r, -1));
|
|
1233
1359
|
} else if (r.type === 4 /* Datetime */) {
|
|
1234
|
-
stack.push(
|
|
1360
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
1235
1361
|
"INVALID_DATETIME_OP",
|
|
1236
1362
|
"Cannot subtract a datetime from a value that is not a datetime"
|
|
1237
1363
|
));
|
|
1238
1364
|
} else {
|
|
1239
|
-
stack.push(
|
|
1365
|
+
stack.push(chunk7ZX6B7SY_cjs.binaryOp(l, r, (a, b) => a - b, (a, b) => a - b, "sub"));
|
|
1240
1366
|
}
|
|
1241
1367
|
break;
|
|
1242
1368
|
}
|
|
1243
1369
|
case 22 /* MUL */: {
|
|
1244
1370
|
const r = safePop(stack), l = safePop(stack);
|
|
1371
|
+
const pctUnc = multiplyPercentWithUncertainty(l, r);
|
|
1372
|
+
if (pctUnc) {
|
|
1373
|
+
stack.push(pctUnc);
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1377
|
+
const uncMul = chunk7ZX6B7SY_cjs.uncertainOp(l, r, "mul");
|
|
1378
|
+
if (uncMul) {
|
|
1379
|
+
stack.push(uncMul);
|
|
1380
|
+
break;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1384
|
+
const ratMul = chunk7ZX6B7SY_cjs.exactRationalOp(l, r, "mul");
|
|
1385
|
+
if (ratMul) {
|
|
1386
|
+
stack.push(ratMul);
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
const moneyScalar = multiplyMoneyByScalarExact(l, r);
|
|
1391
|
+
if (moneyScalar) {
|
|
1392
|
+
stack.push(moneyScalar);
|
|
1393
|
+
break;
|
|
1394
|
+
}
|
|
1245
1395
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1246
|
-
stack.push(
|
|
1396
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.value * r.value));
|
|
1247
1397
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1248
|
-
|
|
1249
|
-
stack.push(
|
|
1250
|
-
} else if (l.type === 6 /* Uom */ &&
|
|
1398
|
+
chunk2TZKENDH_cjs.checkAllocation(matrixProductCells(l.value, r.value), "matrix cells");
|
|
1399
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixMultiply(l.value, r.value));
|
|
1400
|
+
} else if (l.type === 6 /* Uom */ && chunk2TZKENDH_cjs.isRateUnit(l.unit) && r.type === 6 /* Uom */ && r.unit) {
|
|
1251
1401
|
stack.push(multiplyRateByMatchingUom(l, r));
|
|
1252
|
-
} else if (r.type === 6 /* Uom */ &&
|
|
1402
|
+
} else if (r.type === 6 /* Uom */ && chunk2TZKENDH_cjs.isRateUnit(r.unit) && l.type === 6 /* Uom */ && l.unit) {
|
|
1253
1403
|
stack.push(multiplyRateByMatchingUom(r, l));
|
|
1254
1404
|
} else if (moneyTimesQuantity(l, r) !== null) {
|
|
1255
1405
|
stack.push(moneyTimesQuantity(l, r));
|
|
1256
1406
|
} else {
|
|
1257
|
-
stack.push(
|
|
1407
|
+
stack.push(chunk7ZX6B7SY_cjs.binaryOp(l, r, (a, b) => a * b, (a, b) => a * b, "mul"));
|
|
1258
1408
|
}
|
|
1259
1409
|
break;
|
|
1260
1410
|
}
|
|
1261
1411
|
case 23 /* DIV */: {
|
|
1262
1412
|
const r = safePop(stack), l = safePop(stack);
|
|
1413
|
+
const pctDivUnc = dividePercentWithUncertainty(l, r);
|
|
1414
|
+
if (pctDivUnc) {
|
|
1415
|
+
stack.push(pctDivUnc);
|
|
1416
|
+
break;
|
|
1417
|
+
}
|
|
1418
|
+
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1419
|
+
const uncDiv = chunk7ZX6B7SY_cjs.uncertainOp(l, r, "div");
|
|
1420
|
+
if (uncDiv) {
|
|
1421
|
+
stack.push(uncDiv);
|
|
1422
|
+
break;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1263
1425
|
if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1264
|
-
const { lv, rv, sameMeasure } =
|
|
1426
|
+
const { lv, rv, sameMeasure } = chunk7ZX6B7SY_cjs.unifyUom(l, r);
|
|
1265
1427
|
if (sameMeasure) {
|
|
1266
|
-
stack.push(
|
|
1267
|
-
} else if (
|
|
1268
|
-
stack.push(
|
|
1428
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(lv / rv));
|
|
1429
|
+
} else if (chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(l.unit) && chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(r.unit)) {
|
|
1430
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("INCOMPATIBLE_UNITS", `Cannot combine incompatible units: ${l.unit} and ${r.unit}`));
|
|
1269
1431
|
} else {
|
|
1270
|
-
stack.push(
|
|
1432
|
+
stack.push(chunk2TZKENDH_cjs.rateValue(lv / rv, l.unit, r.unit));
|
|
1271
1433
|
}
|
|
1272
1434
|
} else {
|
|
1273
|
-
|
|
1274
|
-
|
|
1435
|
+
const ratDiv = chunk7ZX6B7SY_cjs.exactRationalOp(l, r, "div");
|
|
1436
|
+
if (ratDiv) {
|
|
1437
|
+
stack.push(ratDiv);
|
|
1438
|
+
break;
|
|
1439
|
+
}
|
|
1440
|
+
stack.push(chunk7ZX6B7SY_cjs.binaryOp(l, r, (a, b) => a / b, (a, b) => {
|
|
1441
|
+
if (b === 0n) throw chunk7ZX6B7SY_cjs.bigIntDivisionByZero();
|
|
1275
1442
|
return a / b;
|
|
1276
1443
|
}, "div"));
|
|
1277
1444
|
}
|
|
@@ -1279,8 +1446,8 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1279
1446
|
}
|
|
1280
1447
|
case 24 /* MOD */: {
|
|
1281
1448
|
const r = safePop(stack), l = safePop(stack);
|
|
1282
|
-
stack.push(
|
|
1283
|
-
if (b === 0n) throw
|
|
1449
|
+
stack.push(chunk7ZX6B7SY_cjs.binaryOp(l, r, (a, b) => a % b, (a, b) => {
|
|
1450
|
+
if (b === 0n) throw chunk7ZX6B7SY_cjs.bigIntDivisionByZero();
|
|
1284
1451
|
return a % b;
|
|
1285
1452
|
}));
|
|
1286
1453
|
break;
|
|
@@ -1304,66 +1471,82 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1304
1471
|
break;
|
|
1305
1472
|
}
|
|
1306
1473
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1307
|
-
stack.push(
|
|
1474
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(chunk7ZX6B7SY_cjs.power(l.value, r.value)));
|
|
1308
1475
|
break;
|
|
1309
1476
|
}
|
|
1310
1477
|
if (l.type === 7 /* Matrix */ || r.type === 7 /* Matrix */) {
|
|
1311
1478
|
if (l.type !== 7 /* Matrix */ || r.type !== 0 /* Number */) {
|
|
1312
|
-
stack.push(
|
|
1479
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
1313
1480
|
"MATRIX_POWER_UNSUPPORTED",
|
|
1314
|
-
`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${
|
|
1481
|
+
`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${chunk2TZKENDH_cjs.ValueType[l.type]} ^ ${chunk2TZKENDH_cjs.ValueType[r.type]}" has no matrix reading.`
|
|
1315
1482
|
));
|
|
1316
1483
|
break;
|
|
1317
1484
|
}
|
|
1318
|
-
|
|
1319
|
-
stack.push(
|
|
1485
|
+
chunk2TZKENDH_cjs.checkAllocation(matrixPowerCells(l.value, r.value), "matrix cells");
|
|
1486
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixPower(l.value, r.value));
|
|
1320
1487
|
break;
|
|
1321
1488
|
}
|
|
1322
1489
|
if (l.type === 9 /* Symbolic */ || r.type === 9 /* Symbolic */) {
|
|
1323
|
-
stack.push(
|
|
1490
|
+
stack.push(chunk7ZX6B7SY_cjs.symbolicPow(l, r));
|
|
1324
1491
|
break;
|
|
1325
1492
|
}
|
|
1326
1493
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1327
1494
|
const powBits = exactPowBits(l, r.toNumber());
|
|
1328
1495
|
if (powBits !== null) {
|
|
1329
1496
|
if (powBits > MAX_EXACT_POW_BITS) {
|
|
1330
|
-
throw
|
|
1497
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
1331
1498
|
"BIGINT_POW_LIMIT_EXCEEDED",
|
|
1332
1499
|
`That power would build an exact integer of about ${Math.round(powBits).toLocaleString("en-US")} bits, past the limit of ${MAX_EXACT_POW_BITS.toLocaleString("en-US")} bits`,
|
|
1333
1500
|
{ limitBits: MAX_EXACT_POW_BITS }
|
|
1334
1501
|
);
|
|
1335
1502
|
}
|
|
1336
|
-
stack.push(
|
|
1503
|
+
stack.push(chunk2TZKENDH_cjs.bigIntValue(bigIntPow(chunk7ZX6B7SY_cjs.toBigIntOperand(l), chunk7ZX6B7SY_cjs.toBigIntOperand(r))));
|
|
1337
1504
|
break;
|
|
1338
1505
|
}
|
|
1339
1506
|
}
|
|
1340
|
-
stack.push(
|
|
1507
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(chunk7ZX6B7SY_cjs.power(l.toNumber(), r.toNumber())));
|
|
1341
1508
|
break;
|
|
1342
1509
|
}
|
|
1343
1510
|
case 26 /* NEG */: {
|
|
1344
1511
|
const v = safePop(stack);
|
|
1345
|
-
const negFault =
|
|
1512
|
+
const negFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1346
1513
|
if (negFault) {
|
|
1347
1514
|
stack.push(negFault);
|
|
1348
1515
|
break;
|
|
1349
1516
|
}
|
|
1350
|
-
if (v.type === 2 /* BigInt */) stack.push(
|
|
1351
|
-
else if (v.type === 6 /* Uom */) stack.push(
|
|
1352
|
-
else if (v.type ===
|
|
1353
|
-
else if (v.type ===
|
|
1354
|
-
else stack.push(
|
|
1517
|
+
if (v.type === 2 /* BigInt */) stack.push(chunk2TZKENDH_cjs.bigIntValue(-v.value));
|
|
1518
|
+
else if (v.type === 6 /* Uom */ && v.exact !== void 0) stack.push(chunk2TZKENDH_cjs.uomValueExact(-v.toNumber(), v.unit, chunkHIQ5HSZL_cjs.decimalNegate(v.exact)));
|
|
1519
|
+
else if (v.type === 6 /* Uom */) stack.push(chunk2TZKENDH_cjs.uomValue(-v.toNumber(), v.unit));
|
|
1520
|
+
else if (v.type === 5 /* Percentage */) stack.push(chunk2TZKENDH_cjs.percentageValue(-v.toNumber()));
|
|
1521
|
+
else if (v.type === 9 /* Symbolic */) stack.push(chunk7ZX6B7SY_cjs.symbolicNeg(v));
|
|
1522
|
+
else if (v.type === 0 /* Number */ && v.rational !== void 0) stack.push(chunk2TZKENDH_cjs.numberValueRational(-v.toNumber(), chunkHIQ5HSZL_cjs.rationalNeg(v.rational)));
|
|
1523
|
+
else if (v.type === 0 /* Number */ && v.exact !== void 0) stack.push(chunk2TZKENDH_cjs.numberValueExact(-v.toNumber(), chunkHIQ5HSZL_cjs.decimalNegate(v.exact)));
|
|
1524
|
+
else stack.push(chunk2TZKENDH_cjs.numberValue(-v.toNumber()));
|
|
1355
1525
|
break;
|
|
1356
1526
|
}
|
|
1357
1527
|
case 27 /* POS */: {
|
|
1358
1528
|
const v = safePop(stack);
|
|
1359
|
-
const posFault =
|
|
1529
|
+
const posFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1360
1530
|
if (posFault) {
|
|
1361
1531
|
stack.push(posFault);
|
|
1362
1532
|
break;
|
|
1363
1533
|
}
|
|
1364
|
-
if (v.type === 6 /* Uom */) stack.push(
|
|
1365
|
-
else if (v.type ===
|
|
1366
|
-
else stack.push(
|
|
1534
|
+
if (v.type === 6 /* Uom */ && v.exact !== void 0) stack.push(chunk2TZKENDH_cjs.uomValueExact(v.toNumber(), v.unit, v.exact));
|
|
1535
|
+
else if (v.type === 6 /* Uom */) stack.push(chunk2TZKENDH_cjs.uomValue(v.toNumber(), v.unit));
|
|
1536
|
+
else if (v.type === 5 /* Percentage */) stack.push(chunk2TZKENDH_cjs.percentageValue(v.toNumber()));
|
|
1537
|
+
else if (v.type === 0 /* Number */ && v.rational !== void 0) stack.push(chunk2TZKENDH_cjs.numberValueRational(v.toNumber(), v.rational));
|
|
1538
|
+
else if (v.type === 0 /* Number */ && v.exact !== void 0) stack.push(chunk2TZKENDH_cjs.numberValueExact(v.toNumber(), v.exact));
|
|
1539
|
+
else stack.push(chunk2TZKENDH_cjs.numberValue(v.toNumber()));
|
|
1540
|
+
break;
|
|
1541
|
+
}
|
|
1542
|
+
case 28 /* MAKE_UNCERTAIN */: {
|
|
1543
|
+
const spread = safePop(stack), center = safePop(stack);
|
|
1544
|
+
const uncFault = chunk2TZKENDH_cjs.faultedOperand(center, spread);
|
|
1545
|
+
if (uncFault) {
|
|
1546
|
+
stack.push(uncFault);
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
stack.push(chunk2TZKENDH_cjs.numberValueUncertain(center.toNumber(), Math.abs(spread.toNumber())));
|
|
1367
1550
|
break;
|
|
1368
1551
|
}
|
|
1369
1552
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -1376,7 +1559,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1376
1559
|
// ═══════════════════════════════════════════════════════════════
|
|
1377
1560
|
case 30 /* LSHIFT */: {
|
|
1378
1561
|
const r = safePop(stack), l = safePop(stack);
|
|
1379
|
-
const shiftFault =
|
|
1562
|
+
const shiftFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1380
1563
|
if (shiftFault) {
|
|
1381
1564
|
stack.push(shiftFault);
|
|
1382
1565
|
break;
|
|
@@ -1384,13 +1567,13 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1384
1567
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1385
1568
|
stack.push(bigIntShift(l, r, 1));
|
|
1386
1569
|
} else {
|
|
1387
|
-
stack.push(
|
|
1570
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.toNumber() << r.toNumber()));
|
|
1388
1571
|
}
|
|
1389
1572
|
break;
|
|
1390
1573
|
}
|
|
1391
1574
|
case 31 /* RSHIFT */: {
|
|
1392
1575
|
const r = safePop(stack), l = safePop(stack);
|
|
1393
|
-
const rshiftFault =
|
|
1576
|
+
const rshiftFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1394
1577
|
if (rshiftFault) {
|
|
1395
1578
|
stack.push(rshiftFault);
|
|
1396
1579
|
break;
|
|
@@ -1398,71 +1581,71 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1398
1581
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1399
1582
|
stack.push(bigIntShift(l, r, -1));
|
|
1400
1583
|
} else {
|
|
1401
|
-
stack.push(
|
|
1584
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.toNumber() >> r.toNumber()));
|
|
1402
1585
|
}
|
|
1403
1586
|
break;
|
|
1404
1587
|
}
|
|
1405
1588
|
case 32 /* URSHIFT */: {
|
|
1406
1589
|
const r = safePop(stack), l = safePop(stack);
|
|
1407
|
-
const urshiftFault =
|
|
1590
|
+
const urshiftFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1408
1591
|
if (urshiftFault) {
|
|
1409
1592
|
stack.push(urshiftFault);
|
|
1410
1593
|
break;
|
|
1411
1594
|
}
|
|
1412
|
-
stack.push(
|
|
1595
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.toNumber() >>> r.toNumber()));
|
|
1413
1596
|
break;
|
|
1414
1597
|
}
|
|
1415
1598
|
case 33 /* BIT_AND */: {
|
|
1416
1599
|
const r = safePop(stack), l = safePop(stack);
|
|
1417
|
-
const andFault =
|
|
1600
|
+
const andFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1418
1601
|
if (andFault) {
|
|
1419
1602
|
stack.push(andFault);
|
|
1420
1603
|
break;
|
|
1421
1604
|
}
|
|
1422
1605
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1423
|
-
stack.push(
|
|
1606
|
+
stack.push(chunk2TZKENDH_cjs.bigIntValue(chunk7ZX6B7SY_cjs.toBigIntOperand(l) & chunk7ZX6B7SY_cjs.toBigIntOperand(r)));
|
|
1424
1607
|
} else {
|
|
1425
|
-
stack.push(
|
|
1608
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.toNumber() & r.toNumber()));
|
|
1426
1609
|
}
|
|
1427
1610
|
break;
|
|
1428
1611
|
}
|
|
1429
1612
|
case 34 /* BIT_OR */: {
|
|
1430
1613
|
const r = safePop(stack), l = safePop(stack);
|
|
1431
|
-
const orFault =
|
|
1614
|
+
const orFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1432
1615
|
if (orFault) {
|
|
1433
1616
|
stack.push(orFault);
|
|
1434
1617
|
break;
|
|
1435
1618
|
}
|
|
1436
1619
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1437
|
-
stack.push(
|
|
1620
|
+
stack.push(chunk2TZKENDH_cjs.bigIntValue(chunk7ZX6B7SY_cjs.toBigIntOperand(l) | chunk7ZX6B7SY_cjs.toBigIntOperand(r)));
|
|
1438
1621
|
} else {
|
|
1439
|
-
stack.push(
|
|
1622
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.toNumber() | r.toNumber()));
|
|
1440
1623
|
}
|
|
1441
1624
|
break;
|
|
1442
1625
|
}
|
|
1443
1626
|
case 35 /* BIT_XOR */: {
|
|
1444
1627
|
const r = safePop(stack), l = safePop(stack);
|
|
1445
|
-
const xorFault =
|
|
1628
|
+
const xorFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1446
1629
|
if (xorFault) {
|
|
1447
1630
|
stack.push(xorFault);
|
|
1448
1631
|
break;
|
|
1449
1632
|
}
|
|
1450
1633
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1451
|
-
stack.push(
|
|
1634
|
+
stack.push(chunk2TZKENDH_cjs.bigIntValue(chunk7ZX6B7SY_cjs.toBigIntOperand(l) ^ chunk7ZX6B7SY_cjs.toBigIntOperand(r)));
|
|
1452
1635
|
} else {
|
|
1453
|
-
stack.push(
|
|
1636
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(l.toNumber() ^ r.toNumber()));
|
|
1454
1637
|
}
|
|
1455
1638
|
break;
|
|
1456
1639
|
}
|
|
1457
1640
|
case 36 /* BIT_NOT */: {
|
|
1458
1641
|
const v = safePop(stack);
|
|
1459
|
-
const notFault =
|
|
1642
|
+
const notFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1460
1643
|
if (notFault) {
|
|
1461
1644
|
stack.push(notFault);
|
|
1462
1645
|
break;
|
|
1463
1646
|
}
|
|
1464
|
-
if (v.type === 2 /* BigInt */) stack.push(
|
|
1465
|
-
else stack.push(
|
|
1647
|
+
if (v.type === 2 /* BigInt */) stack.push(chunk2TZKENDH_cjs.bigIntValue(~v.value));
|
|
1648
|
+
else stack.push(chunk2TZKENDH_cjs.numberValue(~v.toNumber()));
|
|
1466
1649
|
break;
|
|
1467
1650
|
}
|
|
1468
1651
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -1493,137 +1676,193 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1493
1676
|
// ═══════════════════════════════════════════════════════════════
|
|
1494
1677
|
case 40 /* EQ */: {
|
|
1495
1678
|
const r = safePop(stack), l = safePop(stack);
|
|
1496
|
-
const eqFault =
|
|
1679
|
+
const eqFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1497
1680
|
if (eqFault) {
|
|
1498
1681
|
stack.push(eqFault);
|
|
1499
1682
|
break;
|
|
1500
1683
|
}
|
|
1684
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1685
|
+
const cmp = chunk7ZX6B7SY_cjs.compareRationalOperands(l, r);
|
|
1686
|
+
if (cmp !== null) {
|
|
1687
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === 0));
|
|
1688
|
+
break;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1501
1691
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1502
|
-
stack.push(
|
|
1692
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value === r.value));
|
|
1503
1693
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1504
|
-
const cmp =
|
|
1505
|
-
stack.push(
|
|
1694
|
+
const cmp = chunk7ZX6B7SY_cjs.compareBigIntOperands(l, r);
|
|
1695
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === null ? l.toNumber() === r.toNumber() : cmp === 0));
|
|
1506
1696
|
} else if (l.type === 3 /* String */ && r.type === 3 /* String */) {
|
|
1507
|
-
stack.push(
|
|
1697
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value === r.value));
|
|
1508
1698
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1509
|
-
const { equal, sameMeasure } =
|
|
1510
|
-
stack.push(
|
|
1699
|
+
const { equal, sameMeasure } = chunk7ZX6B7SY_cjs.compareUom(l, r);
|
|
1700
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(sameMeasure && equal));
|
|
1511
1701
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1512
|
-
stack.push(
|
|
1702
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixCompare(l.value, r.value, (a, b) => a === b));
|
|
1703
|
+
} else if (l.type === 14 /* Colour */ || r.type === 14 /* Colour */) {
|
|
1704
|
+
if (l.type === 14 /* Colour */ && r.type === 14 /* Colour */) {
|
|
1705
|
+
const a = l.value, b = r.value;
|
|
1706
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a));
|
|
1707
|
+
} else {
|
|
1708
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(false));
|
|
1709
|
+
}
|
|
1513
1710
|
} else {
|
|
1514
|
-
stack.push(
|
|
1711
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.toNumber() === r.toNumber()));
|
|
1515
1712
|
}
|
|
1516
1713
|
break;
|
|
1517
1714
|
}
|
|
1518
1715
|
case 41 /* NEQ */: {
|
|
1519
1716
|
const r = safePop(stack), l = safePop(stack);
|
|
1520
|
-
const neqFault =
|
|
1717
|
+
const neqFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1521
1718
|
if (neqFault) {
|
|
1522
1719
|
stack.push(neqFault);
|
|
1523
1720
|
break;
|
|
1524
1721
|
}
|
|
1722
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1723
|
+
const cmp = chunk7ZX6B7SY_cjs.compareRationalOperands(l, r);
|
|
1724
|
+
if (cmp !== null) {
|
|
1725
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp !== 0));
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1525
1729
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1526
|
-
stack.push(
|
|
1730
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value !== r.value));
|
|
1527
1731
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1528
|
-
const cmp =
|
|
1529
|
-
stack.push(
|
|
1732
|
+
const cmp = chunk7ZX6B7SY_cjs.compareBigIntOperands(l, r);
|
|
1733
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === null ? l.toNumber() !== r.toNumber() : cmp !== 0));
|
|
1530
1734
|
} else if (l.type === 3 /* String */ && r.type === 3 /* String */) {
|
|
1531
|
-
stack.push(
|
|
1735
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value !== r.value));
|
|
1532
1736
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1533
|
-
const { equal, sameMeasure } =
|
|
1534
|
-
stack.push(
|
|
1737
|
+
const { equal, sameMeasure } = chunk7ZX6B7SY_cjs.compareUom(l, r);
|
|
1738
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(!sameMeasure || !equal));
|
|
1535
1739
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1536
|
-
stack.push(
|
|
1740
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixCompare(l.value, r.value, (a, b) => a !== b));
|
|
1741
|
+
} else if (l.type === 14 /* Colour */ || r.type === 14 /* Colour */) {
|
|
1742
|
+
if (l.type === 14 /* Colour */ && r.type === 14 /* Colour */) {
|
|
1743
|
+
const a = l.value, b = r.value;
|
|
1744
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(!(a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a)));
|
|
1745
|
+
} else {
|
|
1746
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(true));
|
|
1747
|
+
}
|
|
1537
1748
|
} else {
|
|
1538
|
-
stack.push(
|
|
1749
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.toNumber() !== r.toNumber()));
|
|
1539
1750
|
}
|
|
1540
1751
|
break;
|
|
1541
1752
|
}
|
|
1542
1753
|
case 42 /* LT */: {
|
|
1543
1754
|
const r = safePop(stack), l = safePop(stack);
|
|
1544
|
-
const ltFault =
|
|
1755
|
+
const ltFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1545
1756
|
if (ltFault) {
|
|
1546
1757
|
stack.push(ltFault);
|
|
1547
1758
|
break;
|
|
1548
1759
|
}
|
|
1760
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1761
|
+
const cmp = chunk7ZX6B7SY_cjs.compareRationalOperands(l, r);
|
|
1762
|
+
if (cmp !== null) {
|
|
1763
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp < 0));
|
|
1764
|
+
break;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1549
1767
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1550
|
-
stack.push(
|
|
1768
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value < r.value));
|
|
1551
1769
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1552
|
-
const cmp =
|
|
1553
|
-
stack.push(
|
|
1770
|
+
const cmp = chunk7ZX6B7SY_cjs.compareBigIntOperands(l, r);
|
|
1771
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === null ? l.toNumber() < r.toNumber() : cmp < 0));
|
|
1554
1772
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1555
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1556
|
-
stack.push(sameMeasure ?
|
|
1773
|
+
const { lv, rv, equal, sameMeasure } = chunk7ZX6B7SY_cjs.compareUom(l, r);
|
|
1774
|
+
stack.push(sameMeasure ? chunk2TZKENDH_cjs.boolValue(!equal && lv < rv) : chunk7ZX6B7SY_cjs.incomparableUnitsError(l, r));
|
|
1557
1775
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1558
|
-
stack.push(
|
|
1776
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixCompare(l.value, r.value, (a, b) => a < b));
|
|
1559
1777
|
} else {
|
|
1560
|
-
stack.push(
|
|
1778
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.toNumber() < r.toNumber()));
|
|
1561
1779
|
}
|
|
1562
1780
|
break;
|
|
1563
1781
|
}
|
|
1564
1782
|
case 43 /* LTE */: {
|
|
1565
1783
|
const r = safePop(stack), l = safePop(stack);
|
|
1566
|
-
const lteFault =
|
|
1784
|
+
const lteFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1567
1785
|
if (lteFault) {
|
|
1568
1786
|
stack.push(lteFault);
|
|
1569
1787
|
break;
|
|
1570
1788
|
}
|
|
1789
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1790
|
+
const cmp = chunk7ZX6B7SY_cjs.compareRationalOperands(l, r);
|
|
1791
|
+
if (cmp !== null) {
|
|
1792
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp <= 0));
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1571
1796
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1572
|
-
stack.push(
|
|
1797
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value <= r.value));
|
|
1573
1798
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1574
|
-
const cmp =
|
|
1575
|
-
stack.push(
|
|
1799
|
+
const cmp = chunk7ZX6B7SY_cjs.compareBigIntOperands(l, r);
|
|
1800
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === null ? l.toNumber() <= r.toNumber() : cmp <= 0));
|
|
1576
1801
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1577
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1578
|
-
stack.push(sameMeasure ?
|
|
1802
|
+
const { lv, rv, equal, sameMeasure } = chunk7ZX6B7SY_cjs.compareUom(l, r);
|
|
1803
|
+
stack.push(sameMeasure ? chunk2TZKENDH_cjs.boolValue(equal || lv <= rv) : chunk7ZX6B7SY_cjs.incomparableUnitsError(l, r));
|
|
1579
1804
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1580
|
-
stack.push(
|
|
1805
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixCompare(l.value, r.value, (a, b) => a <= b));
|
|
1581
1806
|
} else {
|
|
1582
|
-
stack.push(
|
|
1807
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.toNumber() <= r.toNumber()));
|
|
1583
1808
|
}
|
|
1584
1809
|
break;
|
|
1585
1810
|
}
|
|
1586
1811
|
case 44 /* GT */: {
|
|
1587
1812
|
const r = safePop(stack), l = safePop(stack);
|
|
1588
|
-
const gtFault =
|
|
1813
|
+
const gtFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1589
1814
|
if (gtFault) {
|
|
1590
1815
|
stack.push(gtFault);
|
|
1591
1816
|
break;
|
|
1592
1817
|
}
|
|
1818
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1819
|
+
const cmp = chunk7ZX6B7SY_cjs.compareRationalOperands(l, r);
|
|
1820
|
+
if (cmp !== null) {
|
|
1821
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp > 0));
|
|
1822
|
+
break;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1593
1825
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1594
|
-
stack.push(
|
|
1826
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value > r.value));
|
|
1595
1827
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1596
|
-
const cmp =
|
|
1597
|
-
stack.push(
|
|
1828
|
+
const cmp = chunk7ZX6B7SY_cjs.compareBigIntOperands(l, r);
|
|
1829
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === null ? l.toNumber() > r.toNumber() : cmp > 0));
|
|
1598
1830
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1599
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1600
|
-
stack.push(sameMeasure ?
|
|
1831
|
+
const { lv, rv, equal, sameMeasure } = chunk7ZX6B7SY_cjs.compareUom(l, r);
|
|
1832
|
+
stack.push(sameMeasure ? chunk2TZKENDH_cjs.boolValue(!equal && lv > rv) : chunk7ZX6B7SY_cjs.incomparableUnitsError(l, r));
|
|
1601
1833
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1602
|
-
stack.push(
|
|
1834
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixCompare(l.value, r.value, (a, b) => a > b));
|
|
1603
1835
|
} else {
|
|
1604
|
-
stack.push(
|
|
1836
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.toNumber() > r.toNumber()));
|
|
1605
1837
|
}
|
|
1606
1838
|
break;
|
|
1607
1839
|
}
|
|
1608
1840
|
case 45 /* GTE */: {
|
|
1609
1841
|
const r = safePop(stack), l = safePop(stack);
|
|
1610
|
-
const gteFault =
|
|
1842
|
+
const gteFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1611
1843
|
if (gteFault) {
|
|
1612
1844
|
stack.push(gteFault);
|
|
1613
1845
|
break;
|
|
1614
1846
|
}
|
|
1847
|
+
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1848
|
+
const cmp = chunk7ZX6B7SY_cjs.compareRationalOperands(l, r);
|
|
1849
|
+
if (cmp !== null) {
|
|
1850
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp >= 0));
|
|
1851
|
+
break;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1615
1854
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1616
|
-
stack.push(
|
|
1855
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.value >= r.value));
|
|
1617
1856
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1618
|
-
const cmp =
|
|
1619
|
-
stack.push(
|
|
1857
|
+
const cmp = chunk7ZX6B7SY_cjs.compareBigIntOperands(l, r);
|
|
1858
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(cmp === null ? l.toNumber() >= r.toNumber() : cmp >= 0));
|
|
1620
1859
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1621
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1622
|
-
stack.push(sameMeasure ?
|
|
1860
|
+
const { lv, rv, equal, sameMeasure } = chunk7ZX6B7SY_cjs.compareUom(l, r);
|
|
1861
|
+
stack.push(sameMeasure ? chunk2TZKENDH_cjs.boolValue(equal || lv >= rv) : chunk7ZX6B7SY_cjs.incomparableUnitsError(l, r));
|
|
1623
1862
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1624
|
-
stack.push(
|
|
1863
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixCompare(l.value, r.value, (a, b) => a >= b));
|
|
1625
1864
|
} else {
|
|
1626
|
-
stack.push(
|
|
1865
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(l.toNumber() >= r.toNumber()));
|
|
1627
1866
|
}
|
|
1628
1867
|
break;
|
|
1629
1868
|
}
|
|
@@ -1638,29 +1877,29 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1638
1877
|
// ═══════════════════════════════════════════════════════════════
|
|
1639
1878
|
case 130 /* LOGICAL_AND */: {
|
|
1640
1879
|
const r = safePop(stack), l = safePop(stack);
|
|
1641
|
-
const andLogicFault =
|
|
1880
|
+
const andLogicFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1642
1881
|
if (andLogicFault) {
|
|
1643
1882
|
stack.push(andLogicFault);
|
|
1644
1883
|
break;
|
|
1645
1884
|
}
|
|
1646
|
-
stack.push(
|
|
1885
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(isTruthy(l) && isTruthy(r)));
|
|
1647
1886
|
break;
|
|
1648
1887
|
}
|
|
1649
1888
|
case 131 /* LOGICAL_OR */: {
|
|
1650
1889
|
const r = safePop(stack), l = safePop(stack);
|
|
1651
|
-
const orLogicFault =
|
|
1890
|
+
const orLogicFault = chunk2TZKENDH_cjs.faultedOperand(l, r);
|
|
1652
1891
|
if (orLogicFault) {
|
|
1653
1892
|
stack.push(orLogicFault);
|
|
1654
1893
|
break;
|
|
1655
1894
|
}
|
|
1656
|
-
stack.push(
|
|
1895
|
+
stack.push(chunk2TZKENDH_cjs.boolValue(isTruthy(l) || isTruthy(r)));
|
|
1657
1896
|
break;
|
|
1658
1897
|
}
|
|
1659
1898
|
case 132 /* SELECT */: {
|
|
1660
1899
|
const elseVal = safePop(stack);
|
|
1661
1900
|
const thenVal = safePop(stack);
|
|
1662
1901
|
const condition = safePop(stack);
|
|
1663
|
-
const conditionFault =
|
|
1902
|
+
const conditionFault = chunk2TZKENDH_cjs.faultedOperand(condition);
|
|
1664
1903
|
if (conditionFault) {
|
|
1665
1904
|
stack.push(conditionFault);
|
|
1666
1905
|
break;
|
|
@@ -1678,11 +1917,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1678
1917
|
for (let i = 0; i < argCount; i++) args.push(safePop(stack));
|
|
1679
1918
|
args.reverse();
|
|
1680
1919
|
const fn = vm.context.pluginFunctions[fnIdx];
|
|
1681
|
-
const pluginArgFault =
|
|
1920
|
+
const pluginArgFault = chunk2TZKENDH_cjs.faultedIn(args);
|
|
1682
1921
|
if (pluginArgFault) {
|
|
1683
1922
|
stack.push(pluginArgFault);
|
|
1684
1923
|
} else if (!fn) {
|
|
1685
|
-
stack.push(
|
|
1924
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(0));
|
|
1686
1925
|
} else {
|
|
1687
1926
|
const result = fn(args, context);
|
|
1688
1927
|
if (result instanceof Promise) {
|
|
@@ -1707,16 +1946,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1707
1946
|
if (arg.type === 9 /* Symbolic */) sawSymbolic = true;
|
|
1708
1947
|
args.push(arg);
|
|
1709
1948
|
}
|
|
1710
|
-
const builtinArgFault =
|
|
1949
|
+
const builtinArgFault = chunk2TZKENDH_cjs.faultedIn(args);
|
|
1711
1950
|
if (builtinArgFault) {
|
|
1712
1951
|
stack.push(builtinArgFault);
|
|
1713
1952
|
break;
|
|
1714
1953
|
}
|
|
1715
|
-
const fn =
|
|
1954
|
+
const fn = chunk7ZX6B7SY_cjs.builtinFunctions[fnIdx];
|
|
1716
1955
|
if (fn) {
|
|
1717
1956
|
const ordered = args.reverse();
|
|
1718
|
-
const routeSymbolically = sawSymbolic && !
|
|
1719
|
-
stack.push(routeSymbolically ?
|
|
1957
|
+
const routeSymbolically = sawSymbolic && !chunk7ZX6B7SY_cjs.SYMBOLIC_NATIVE_BUILTINS.has(fnIdx);
|
|
1958
|
+
stack.push(routeSymbolically ? chunk7ZX6B7SY_cjs.symbolicBuiltin(fnIdx, ordered) : fn(ordered));
|
|
1720
1959
|
}
|
|
1721
1960
|
break;
|
|
1722
1961
|
}
|
|
@@ -1724,7 +1963,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1724
1963
|
const bodyIdx = operandByte(opcodes, ip++, op, "function-body index");
|
|
1725
1964
|
const def = userFunctionBodies?.[bodyIdx];
|
|
1726
1965
|
if (!def) {
|
|
1727
|
-
throw
|
|
1966
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.internal(
|
|
1728
1967
|
"INTERNAL_MISSING_FUNCTION_BODY",
|
|
1729
1968
|
`Internal error: DEFINE_USER_FUNCTION referenced missing body index ${bodyIdx}`,
|
|
1730
1969
|
{ bodyIdx }
|
|
@@ -1741,10 +1980,10 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1741
1980
|
args.reverse();
|
|
1742
1981
|
const fn = vm.getUserFunction(name);
|
|
1743
1982
|
if (!fn) {
|
|
1744
|
-
throw
|
|
1983
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution("UNDEFINED_FUNCTION", `Undefined function: ${name}`, { name });
|
|
1745
1984
|
}
|
|
1746
1985
|
if (argCount !== fn.params.length) {
|
|
1747
|
-
throw
|
|
1986
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
1748
1987
|
"FUNCTION_ARITY_MISMATCH",
|
|
1749
1988
|
`${name} expects ${fn.params.length} argument(s) but got ${argCount}`,
|
|
1750
1989
|
{ name, expected: fn.params.length, actual: argCount }
|
|
@@ -1752,7 +1991,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1752
1991
|
}
|
|
1753
1992
|
const frame = /* @__PURE__ */ new Map();
|
|
1754
1993
|
for (let i = 0; i < fn.params.length; i++) frame.set(fn.params[i], args[i]);
|
|
1755
|
-
|
|
1994
|
+
chunk2TZKENDH_cjs.chargeFunctionCall();
|
|
1756
1995
|
vm.pushCallFrame(frame);
|
|
1757
1996
|
let bodyResult;
|
|
1758
1997
|
try {
|
|
@@ -1761,7 +2000,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1761
2000
|
vm.popCallFrame();
|
|
1762
2001
|
}
|
|
1763
2002
|
if (bodyResult.type === "pending") {
|
|
1764
|
-
throw
|
|
2003
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
1765
2004
|
"USER_FUNCTION_ASYNC_UNSUPPORTED",
|
|
1766
2005
|
`${name}: user-defined functions with async bodies (weather, stocks, currency, ...) aren't supported`,
|
|
1767
2006
|
{ name }
|
|
@@ -1782,9 +2021,9 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1782
2021
|
if (val !== void 0) {
|
|
1783
2022
|
stack.push(val);
|
|
1784
2023
|
} else if (symbolicTolerant) {
|
|
1785
|
-
stack.push(
|
|
2024
|
+
stack.push(chunk2TZKENDH_cjs.symbolicValue(chunkHIQ5HSZL_cjs.varNode(varName)));
|
|
1786
2025
|
} else {
|
|
1787
|
-
throw
|
|
2026
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
|
|
1788
2027
|
"UNDEFINED_VARIABLE",
|
|
1789
2028
|
`Undefined variable: ${varName}`,
|
|
1790
2029
|
{ varName }
|
|
@@ -1795,15 +2034,15 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1795
2034
|
case 61 /* STORE_VAR */: {
|
|
1796
2035
|
const val = safePop(stack);
|
|
1797
2036
|
const varName = poolString(opcodes, ip++, strings, op, "variable-name index");
|
|
1798
|
-
vm.setVar(varName, hasArena ?
|
|
2037
|
+
vm.setVar(varName, hasArena ? chunk2TZKENDH_cjs.persistentValue(val) : val);
|
|
1799
2038
|
stack.push(val);
|
|
1800
2039
|
break;
|
|
1801
2040
|
}
|
|
1802
2041
|
case 62 /* LOAD_GLOBAL_VAR */: {
|
|
1803
2042
|
const varName = poolString(opcodes, ip++, strings, op, "variable-name index");
|
|
1804
|
-
const globalValue =
|
|
2043
|
+
const globalValue = chunk7ZX6B7SY_cjs.sharedGlobalVariableStore.get(varName);
|
|
1805
2044
|
if (globalValue === void 0) {
|
|
1806
|
-
throw
|
|
2045
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.internal({
|
|
1807
2046
|
code: "GLOBAL_VARIABLE_NOT_RESOLVED",
|
|
1808
2047
|
message: `Global variable "${varName}" was read before it resolved`,
|
|
1809
2048
|
expected: `global variable "${varName}" to already be resolved (async preflight should guarantee this)`,
|
|
@@ -1817,7 +2056,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1817
2056
|
case 63 /* STORE_GLOBAL_VAR */: {
|
|
1818
2057
|
const val = safePop(stack);
|
|
1819
2058
|
const varName = poolString(opcodes, ip++, strings, op, "variable-name index");
|
|
1820
|
-
|
|
2059
|
+
chunk7ZX6B7SY_cjs.sharedGlobalVariableStore.set(varName, hasArena ? chunk2TZKENDH_cjs.persistentValue(val) : val);
|
|
1821
2060
|
stack.push(val);
|
|
1822
2061
|
break;
|
|
1823
2062
|
}
|
|
@@ -1830,97 +2069,102 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1830
2069
|
// ═══════════════════════════════════════════════════════════════
|
|
1831
2070
|
case 70 /* TO_NUMBER */: {
|
|
1832
2071
|
const v = safePop(stack);
|
|
1833
|
-
const toNumberFault =
|
|
2072
|
+
const toNumberFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1834
2073
|
if (toNumberFault) {
|
|
1835
2074
|
stack.push(toNumberFault);
|
|
1836
2075
|
break;
|
|
1837
2076
|
}
|
|
1838
|
-
stack.push(
|
|
2077
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(v.toNumber()));
|
|
1839
2078
|
break;
|
|
1840
2079
|
}
|
|
1841
2080
|
case 71 /* TO_HEX */: {
|
|
1842
2081
|
const v = safePop(stack);
|
|
1843
|
-
const toHexFault =
|
|
2082
|
+
const toHexFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1844
2083
|
if (toHexFault) {
|
|
1845
2084
|
stack.push(toHexFault);
|
|
1846
2085
|
break;
|
|
1847
2086
|
}
|
|
1848
|
-
|
|
2087
|
+
if (v.type === 14 /* Colour */) {
|
|
2088
|
+
const c = v.value;
|
|
2089
|
+
stack.push(chunk2TZKENDH_cjs.colourValue({ r: c.r, g: c.g, b: c.b, a: c.a, format: "hex" }));
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
2092
|
+
stack.push(chunk2TZKENDH_cjs.hexValue(v.type === 2 /* BigInt */ ? v.value : v.toNumber()));
|
|
1849
2093
|
break;
|
|
1850
2094
|
}
|
|
1851
2095
|
case 74 /* TO_PERCENTAGE */: {
|
|
1852
2096
|
const v = safePop(stack);
|
|
1853
|
-
const toPercentageFault =
|
|
2097
|
+
const toPercentageFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1854
2098
|
if (toPercentageFault) {
|
|
1855
2099
|
stack.push(toPercentageFault);
|
|
1856
2100
|
break;
|
|
1857
2101
|
}
|
|
1858
|
-
stack.push(
|
|
2102
|
+
stack.push(chunk2TZKENDH_cjs.percentageValue(v.toNumber()));
|
|
1859
2103
|
break;
|
|
1860
2104
|
}
|
|
1861
2105
|
case 140 /* TO_FRACTION */: {
|
|
1862
2106
|
const v = safePop(stack);
|
|
1863
|
-
const toFractionFault =
|
|
2107
|
+
const toFractionFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1864
2108
|
if (toFractionFault) {
|
|
1865
2109
|
stack.push(toFractionFault);
|
|
1866
2110
|
break;
|
|
1867
2111
|
}
|
|
1868
|
-
stack.push(
|
|
2112
|
+
stack.push(chunk2TZKENDH_cjs.stringValue(v.rational !== void 0 ? rationalToFractionString(v.rational) : toFractionString(v.toNumber())));
|
|
1869
2113
|
break;
|
|
1870
2114
|
}
|
|
1871
2115
|
case 141 /* TO_MULTIPLIER */: {
|
|
1872
2116
|
const v = safePop(stack);
|
|
1873
|
-
const toMultiplierFault =
|
|
2117
|
+
const toMultiplierFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1874
2118
|
if (toMultiplierFault) {
|
|
1875
2119
|
stack.push(toMultiplierFault);
|
|
1876
2120
|
break;
|
|
1877
2121
|
}
|
|
1878
|
-
stack.push(
|
|
2122
|
+
stack.push(chunk2TZKENDH_cjs.stringValue(toMultiplierString(v)));
|
|
1879
2123
|
break;
|
|
1880
2124
|
}
|
|
1881
2125
|
case 142 /* TO_SCI */: {
|
|
1882
2126
|
const v = safePop(stack);
|
|
1883
|
-
const toSciFault =
|
|
2127
|
+
const toSciFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1884
2128
|
if (toSciFault) {
|
|
1885
2129
|
stack.push(toSciFault);
|
|
1886
2130
|
break;
|
|
1887
2131
|
}
|
|
1888
|
-
stack.push(
|
|
2132
|
+
stack.push(chunk2TZKENDH_cjs.stringValue(toScientificString(v.toNumber())));
|
|
1889
2133
|
break;
|
|
1890
2134
|
}
|
|
1891
2135
|
// Numeric, like TO_HEX above. A base is a way of writing a number, so
|
|
1892
2136
|
// `(255 as binary) + 1` has to be 256; as a string it was 1.
|
|
1893
2137
|
case 143 /* TO_BINARY */: {
|
|
1894
2138
|
const v = safePop(stack);
|
|
1895
|
-
const toBinaryFault =
|
|
2139
|
+
const toBinaryFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1896
2140
|
if (toBinaryFault) {
|
|
1897
2141
|
stack.push(toBinaryFault);
|
|
1898
2142
|
break;
|
|
1899
2143
|
}
|
|
1900
|
-
stack.push(
|
|
2144
|
+
stack.push(chunk2TZKENDH_cjs.hexValue(v.type === 2 /* BigInt */ ? v.value : v.toNumber(), "bin"));
|
|
1901
2145
|
break;
|
|
1902
2146
|
}
|
|
1903
2147
|
case 144 /* TO_OCTAL */: {
|
|
1904
2148
|
const v = safePop(stack);
|
|
1905
|
-
const toOctalFault =
|
|
2149
|
+
const toOctalFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
1906
2150
|
if (toOctalFault) {
|
|
1907
2151
|
stack.push(toOctalFault);
|
|
1908
2152
|
break;
|
|
1909
2153
|
}
|
|
1910
|
-
stack.push(
|
|
2154
|
+
stack.push(chunk2TZKENDH_cjs.hexValue(v.type === 2 /* BigInt */ ? v.value : v.toNumber(), "oct"));
|
|
1911
2155
|
break;
|
|
1912
2156
|
}
|
|
1913
2157
|
case 145 /* CALL_AS_CONVERTER */: {
|
|
1914
2158
|
const name = stringOperand(safePop(stack), op, "converter name").toLowerCase();
|
|
1915
2159
|
const value = safePop(stack);
|
|
1916
|
-
const converterFault =
|
|
2160
|
+
const converterFault = chunk2TZKENDH_cjs.faultedOperand(value);
|
|
1917
2161
|
if (converterFault) {
|
|
1918
2162
|
stack.push(converterFault);
|
|
1919
2163
|
break;
|
|
1920
2164
|
}
|
|
1921
|
-
const converter =
|
|
2165
|
+
const converter = chunk7ZX6B7SY_cjs.asConverterRegistry.get(name);
|
|
1922
2166
|
if (!converter) {
|
|
1923
|
-
stack.push(
|
|
2167
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("UNKNOWN_AS_CONVERTER", `Unknown converter "as ${name}"`));
|
|
1924
2168
|
} else {
|
|
1925
2169
|
stack.push(converter(value));
|
|
1926
2170
|
}
|
|
@@ -1932,62 +2176,69 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1932
2176
|
case 80 /* UOM_CONVERT */: {
|
|
1933
2177
|
const unit = stringOperand(safePop(stack), op, "unit name");
|
|
1934
2178
|
const operand = safePop(stack);
|
|
1935
|
-
const faulted =
|
|
2179
|
+
const faulted = chunk2TZKENDH_cjs.faultedOperand(operand);
|
|
1936
2180
|
if (faulted) {
|
|
1937
2181
|
stack.push(faulted);
|
|
1938
2182
|
break;
|
|
1939
2183
|
}
|
|
1940
|
-
|
|
2184
|
+
const money = chunk7ZX6B7SY_cjs.moneyExactMagnitude(operand, unit);
|
|
2185
|
+
if (money) stack.push(chunk2TZKENDH_cjs.uomValueExact(operand.toNumber(), unit, money));
|
|
2186
|
+
else stack.push(chunk2TZKENDH_cjs.uomValue(operand.toNumber(), unit));
|
|
1941
2187
|
break;
|
|
1942
2188
|
}
|
|
1943
2189
|
case 81 /* UOM_CONVERT_TO */: {
|
|
1944
2190
|
const toUnit = stringOperand(safePop(stack), op, "target unit name");
|
|
1945
2191
|
const fromUnit = stringOperand(safePop(stack), op, "source unit name");
|
|
1946
2192
|
const operand = safePop(stack);
|
|
1947
|
-
const faulted =
|
|
2193
|
+
const faulted = chunk2TZKENDH_cjs.faultedOperand(operand);
|
|
1948
2194
|
if (faulted) {
|
|
1949
2195
|
stack.push(faulted);
|
|
1950
2196
|
break;
|
|
1951
2197
|
}
|
|
1952
2198
|
const val = operand.toNumber();
|
|
1953
|
-
const measure =
|
|
1954
|
-
const isCurrency =
|
|
1955
|
-
if (measure &&
|
|
1956
|
-
stack.push(
|
|
2199
|
+
const measure = chunkEJ3ILXX6_cjs.getMeasure(fromUnit);
|
|
2200
|
+
const isCurrency = chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(fromUnit) && chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(toUnit);
|
|
2201
|
+
if (measure && chunkEJ3ILXX6_cjs.getMeasure(toUnit) === measure) {
|
|
2202
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(chunkEJ3ILXX6_cjs.convertUnit(val, fromUnit, toUnit), toUnit));
|
|
1957
2203
|
} else if (isCurrency) {
|
|
1958
|
-
const converted =
|
|
2204
|
+
const converted = chunkZVTWQLK4_cjs.sharedCurrencyExchange.convertSync(val, fromUnit, toUnit);
|
|
1959
2205
|
if (converted !== null) {
|
|
1960
|
-
stack.push(
|
|
2206
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(converted, toUnit));
|
|
1961
2207
|
} else {
|
|
1962
|
-
stack.push(
|
|
2208
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("CURRENCY_RATE_UNAVAILABLE", `No exchange rate available for ${fromUnit} to ${toUnit}`));
|
|
1963
2209
|
}
|
|
1964
2210
|
} else {
|
|
1965
|
-
|
|
2211
|
+
const rate = chunkEJ3ILXX6_cjs.convertRate(val, fromUnit, toUnit);
|
|
2212
|
+
if (rate !== null) {
|
|
2213
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(rate, toUnit));
|
|
2214
|
+
} else {
|
|
2215
|
+
stack.push(incompatibleConversionError(fromUnit, toUnit));
|
|
2216
|
+
}
|
|
1966
2217
|
}
|
|
1967
2218
|
break;
|
|
1968
2219
|
}
|
|
1969
2220
|
case 85 /* UOM_POSSIBILITIES */: {
|
|
1970
2221
|
const unit = stringOperand(safePop(stack), op, "unit name");
|
|
1971
|
-
const possibilities =
|
|
1972
|
-
stack.push(
|
|
2222
|
+
const possibilities = chunkEJ3ILXX6_cjs.getConvertiblePossibilities(unit);
|
|
2223
|
+
stack.push(chunk2TZKENDH_cjs.stringValue(possibilities.length > 0 ? possibilities.join(", ") : `No known units for "${unit}"`));
|
|
1973
2224
|
break;
|
|
1974
2225
|
}
|
|
1975
2226
|
case 83 /* UOM_BEST */: {
|
|
1976
2227
|
const unit = stringOperand(safePop(stack), op, "unit name");
|
|
1977
2228
|
const operand = safePop(stack);
|
|
1978
|
-
const faulted =
|
|
2229
|
+
const faulted = chunk2TZKENDH_cjs.faultedOperand(operand);
|
|
1979
2230
|
if (faulted) {
|
|
1980
2231
|
stack.push(faulted);
|
|
1981
2232
|
break;
|
|
1982
2233
|
}
|
|
1983
|
-
const { value, unit: bestUnit } =
|
|
1984
|
-
stack.push(
|
|
2234
|
+
const { value, unit: bestUnit } = chunkEJ3ILXX6_cjs.getBestUnit(operand.toNumber(), unit);
|
|
2235
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(value, bestUnit));
|
|
1985
2236
|
break;
|
|
1986
2237
|
}
|
|
1987
2238
|
case 84 /* UOM_CONVERT_IN */: {
|
|
1988
2239
|
const toUnit = stringOperand(safePop(stack), op, "target unit name");
|
|
1989
2240
|
const left = safePop(stack);
|
|
1990
|
-
const faulted =
|
|
2241
|
+
const faulted = chunk2TZKENDH_cjs.faultedOperand(left);
|
|
1991
2242
|
if (faulted) {
|
|
1992
2243
|
stack.push(faulted);
|
|
1993
2244
|
break;
|
|
@@ -1995,33 +2246,38 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1995
2246
|
if (left.type === 6 /* Uom */) {
|
|
1996
2247
|
const fromUnit = left.unit;
|
|
1997
2248
|
const val = left.toNumber();
|
|
1998
|
-
const measure =
|
|
1999
|
-
const isCurrency =
|
|
2000
|
-
if (measure &&
|
|
2001
|
-
stack.push(
|
|
2249
|
+
const measure = chunkEJ3ILXX6_cjs.getMeasure(fromUnit);
|
|
2250
|
+
const isCurrency = chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(fromUnit) && chunkZVTWQLK4_cjs.sharedCurrencyExchange.isCurrency(toUnit);
|
|
2251
|
+
if (measure && chunkEJ3ILXX6_cjs.getMeasure(toUnit) === measure) {
|
|
2252
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(chunkEJ3ILXX6_cjs.convertUnit(val, fromUnit, toUnit), toUnit));
|
|
2002
2253
|
} else if (isCurrency) {
|
|
2003
|
-
const converted =
|
|
2254
|
+
const converted = chunkZVTWQLK4_cjs.sharedCurrencyExchange.convertSync(val, fromUnit, toUnit);
|
|
2004
2255
|
if (converted !== null) {
|
|
2005
|
-
stack.push(
|
|
2256
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(converted, toUnit));
|
|
2006
2257
|
} else {
|
|
2007
|
-
stack.push(
|
|
2258
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("CURRENCY_RATE_UNAVAILABLE", `No exchange rate available for ${fromUnit} to ${toUnit}`));
|
|
2008
2259
|
}
|
|
2009
2260
|
} else {
|
|
2010
|
-
|
|
2261
|
+
const rate = chunkEJ3ILXX6_cjs.convertRate(val, fromUnit, toUnit);
|
|
2262
|
+
if (rate !== null) {
|
|
2263
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(rate, toUnit));
|
|
2264
|
+
} else {
|
|
2265
|
+
stack.push(incompatibleConversionError(fromUnit, toUnit));
|
|
2266
|
+
}
|
|
2011
2267
|
}
|
|
2012
2268
|
} else {
|
|
2013
|
-
stack.push(
|
|
2269
|
+
stack.push(chunk2TZKENDH_cjs.uomValue(left.toNumber(), toUnit));
|
|
2014
2270
|
}
|
|
2015
2271
|
break;
|
|
2016
2272
|
}
|
|
2017
2273
|
case 82 /* UOM_GET_VALUE */: {
|
|
2018
2274
|
const v = safePop(stack);
|
|
2019
|
-
const getValueFault =
|
|
2275
|
+
const getValueFault = chunk2TZKENDH_cjs.faultedOperand(v);
|
|
2020
2276
|
if (getValueFault) {
|
|
2021
2277
|
stack.push(getValueFault);
|
|
2022
2278
|
break;
|
|
2023
2279
|
}
|
|
2024
|
-
stack.push(
|
|
2280
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(v.toNumber()));
|
|
2025
2281
|
break;
|
|
2026
2282
|
}
|
|
2027
2283
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2031,33 +2287,33 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2031
2287
|
case 110 /* RATE_DIV */: {
|
|
2032
2288
|
const denominatorVal = safePop(stack);
|
|
2033
2289
|
const numeratorVal = safePop(stack);
|
|
2034
|
-
const rateDivFault =
|
|
2290
|
+
const rateDivFault = chunk2TZKENDH_cjs.faultedOperand(numeratorVal, denominatorVal);
|
|
2035
2291
|
if (rateDivFault) {
|
|
2036
2292
|
stack.push(rateDivFault);
|
|
2037
2293
|
break;
|
|
2038
2294
|
}
|
|
2039
2295
|
if (denominatorVal.type !== 6 /* Uom */ || !denominatorVal.unit) {
|
|
2040
|
-
stack.push(
|
|
2296
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("RATE_MISSING_DENOMINATOR_UNIT", 'Cannot build a rate: the right-hand side of "/" has no unit'));
|
|
2041
2297
|
break;
|
|
2042
2298
|
}
|
|
2043
2299
|
const numeratorUnit = numeratorVal.type === 6 /* Uom */ ? numeratorVal.unit ?? "" : "";
|
|
2044
|
-
stack.push(
|
|
2300
|
+
stack.push(chunk2TZKENDH_cjs.rateValue(numeratorVal.toNumber() / denominatorVal.toNumber(), numeratorUnit, denominatorVal.unit));
|
|
2045
2301
|
break;
|
|
2046
2302
|
}
|
|
2047
2303
|
case 111 /* RATE_MUL */: {
|
|
2048
2304
|
const multiplier = safePop(stack);
|
|
2049
2305
|
const rate = safePop(stack);
|
|
2050
|
-
const rateMulFault =
|
|
2306
|
+
const rateMulFault = chunk2TZKENDH_cjs.faultedOperand(rate, multiplier);
|
|
2051
2307
|
if (rateMulFault) {
|
|
2052
2308
|
stack.push(rateMulFault);
|
|
2053
2309
|
break;
|
|
2054
2310
|
}
|
|
2055
|
-
if (rate.type !== 6 /* Uom */ || !
|
|
2056
|
-
stack.push(
|
|
2311
|
+
if (rate.type !== 6 /* Uom */ || !chunk2TZKENDH_cjs.isRateUnit(rate.unit)) {
|
|
2312
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("RATE_MUL_LEFT_NOT_A_RATE", 'Left-hand side of a rate multiplication must be a rate (e.g. "$50/week")'));
|
|
2057
2313
|
break;
|
|
2058
2314
|
}
|
|
2059
2315
|
if (multiplier.type !== 6 /* Uom */ || !multiplier.unit) {
|
|
2060
|
-
stack.push(
|
|
2316
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("RATE_MUL_RIGHT_MISSING_UNIT", "Right-hand side of a rate multiplication must have a unit matching the rate's denominator"));
|
|
2061
2317
|
break;
|
|
2062
2318
|
}
|
|
2063
2319
|
stack.push(multiplyRateByMatchingUom(rate, multiplier));
|
|
@@ -2066,27 +2322,27 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2066
2322
|
case 112 /* RATE_CONVERT */: {
|
|
2067
2323
|
const newDenominatorUnit = stringOperand(safePop(stack), op, "denominator unit name");
|
|
2068
2324
|
const rate = safePop(stack);
|
|
2069
|
-
const rateConvertFault =
|
|
2325
|
+
const rateConvertFault = chunk2TZKENDH_cjs.faultedOperand(rate);
|
|
2070
2326
|
if (rateConvertFault) {
|
|
2071
2327
|
stack.push(rateConvertFault);
|
|
2072
2328
|
break;
|
|
2073
2329
|
}
|
|
2074
|
-
if (rate.type !== 6 /* Uom */ || !
|
|
2075
|
-
stack.push(
|
|
2330
|
+
if (rate.type !== 6 /* Uom */ || !chunk2TZKENDH_cjs.isRateUnit(rate.unit)) {
|
|
2331
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("RATE_CONVERT_NOT_A_RATE", "Cannot convert a non-rate value's denominator"));
|
|
2076
2332
|
break;
|
|
2077
2333
|
}
|
|
2078
|
-
const { numerator, denominator } =
|
|
2079
|
-
const rateMeasure =
|
|
2080
|
-
const targetMeasure =
|
|
2334
|
+
const { numerator, denominator } = chunk2TZKENDH_cjs.splitRateUnit(rate.unit);
|
|
2335
|
+
const rateMeasure = chunkEJ3ILXX6_cjs.getMeasure(denominator);
|
|
2336
|
+
const targetMeasure = chunkEJ3ILXX6_cjs.getMeasure(newDenominatorUnit);
|
|
2081
2337
|
if (!rateMeasure || rateMeasure !== targetMeasure) {
|
|
2082
|
-
stack.push(
|
|
2338
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2083
2339
|
"RATE_CONVERT_MEASURE_MISMATCH",
|
|
2084
2340
|
`Cannot convert a "${denominator}"-denominated rate to "${newDenominatorUnit}" \u2014 different measures`
|
|
2085
2341
|
));
|
|
2086
2342
|
break;
|
|
2087
2343
|
}
|
|
2088
|
-
const factor =
|
|
2089
|
-
stack.push(
|
|
2344
|
+
const factor = chunkEJ3ILXX6_cjs.convertUnit(1, newDenominatorUnit, denominator);
|
|
2345
|
+
stack.push(chunk2TZKENDH_cjs.rateValue(rate.toNumber() * factor, numerator, newDenominatorUnit));
|
|
2090
2346
|
break;
|
|
2091
2347
|
}
|
|
2092
2348
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2094,7 +2350,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2094
2350
|
// ═══════════════════════════════════════════════════════════════
|
|
2095
2351
|
case 120 /* CLOCK_TIME_TODAY */: {
|
|
2096
2352
|
const minutesValue = safePop(stack);
|
|
2097
|
-
const clockFault =
|
|
2353
|
+
const clockFault = chunk2TZKENDH_cjs.faultedOperand(minutesValue);
|
|
2098
2354
|
if (clockFault) {
|
|
2099
2355
|
stack.push(clockFault);
|
|
2100
2356
|
break;
|
|
@@ -2103,43 +2359,87 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2103
2359
|
const now = /* @__PURE__ */ new Date();
|
|
2104
2360
|
const anchored = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
2105
2361
|
anchored.setMinutes(totalMinutes);
|
|
2106
|
-
stack.push(
|
|
2362
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(anchored.getTime()));
|
|
2107
2363
|
break;
|
|
2108
2364
|
}
|
|
2109
2365
|
// ═══════════════════════════════════════════════════════════════
|
|
2110
2366
|
// §9 Datetime (OpCode 90–93)
|
|
2111
2367
|
// ═══════════════════════════════════════════════════════════════
|
|
2112
2368
|
case 90 /* DATE_NOW */:
|
|
2113
|
-
stack.push(
|
|
2369
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(Date.now()));
|
|
2114
2370
|
break;
|
|
2115
2371
|
case 95 /* DATE_LITERAL */:
|
|
2116
|
-
stack.push(
|
|
2372
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(numbers[poolIndex(opcodes, ip++, op, "constant-pool index", numbers.length, "number-pool")]));
|
|
2117
2373
|
break;
|
|
2118
2374
|
case 91 /* DATE_ADD */: {
|
|
2119
2375
|
const durValue = safePop(stack), dtValue = safePop(stack);
|
|
2120
|
-
const dateAddFault =
|
|
2376
|
+
const dateAddFault = chunk2TZKENDH_cjs.faultedOperand(dtValue, durValue);
|
|
2121
2377
|
if (dateAddFault) {
|
|
2122
2378
|
stack.push(dateAddFault);
|
|
2123
2379
|
break;
|
|
2124
2380
|
}
|
|
2125
|
-
stack.push(
|
|
2381
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(shiftDatetime(dtValue.toNumber(), durValue, 1, vm)));
|
|
2126
2382
|
break;
|
|
2127
2383
|
}
|
|
2128
2384
|
case 92 /* DATE_SUB */: {
|
|
2129
2385
|
const durValue = safePop(stack), dtValue = safePop(stack);
|
|
2130
|
-
const dateSubFault =
|
|
2386
|
+
const dateSubFault = chunk2TZKENDH_cjs.faultedOperand(dtValue, durValue);
|
|
2131
2387
|
if (dateSubFault) {
|
|
2132
2388
|
stack.push(dateSubFault);
|
|
2133
2389
|
break;
|
|
2134
2390
|
}
|
|
2135
|
-
stack.push(
|
|
2391
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(shiftDatetime(dtValue.toNumber(), durValue, -1, vm)));
|
|
2392
|
+
break;
|
|
2393
|
+
}
|
|
2394
|
+
case 96 /* DATE_WORKDAY_OFFSET */: {
|
|
2395
|
+
const workdayDirection = operandByte(opcodes, ip++, op, "workday offset direction") === 1 ? -1 : 1;
|
|
2396
|
+
const anchorValue = safePop(stack), countValue = safePop(stack);
|
|
2397
|
+
const offsetFault = chunk2TZKENDH_cjs.faultedOperand(countValue, anchorValue);
|
|
2398
|
+
if (offsetFault) {
|
|
2399
|
+
stack.push(offsetFault);
|
|
2400
|
+
break;
|
|
2401
|
+
}
|
|
2402
|
+
if (anchorValue.type !== 4 /* Datetime */) {
|
|
2403
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2404
|
+
chunkB4HBEFTB_cjs.CoreErrorCodes.WORKDAY_OFFSET_EXPECTED_DATE,
|
|
2405
|
+
`"working days after/before/from" expects a date to count from, got ${chunk2TZKENDH_cjs.ValueType[anchorValue.type] ?? "an unsupported value"}`
|
|
2406
|
+
));
|
|
2407
|
+
break;
|
|
2408
|
+
}
|
|
2409
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(addBusinessDays2(anchorValue.toNumber(), workdayDirection * countValue.toNumber(), vm)));
|
|
2410
|
+
break;
|
|
2411
|
+
}
|
|
2412
|
+
case 97 /* DATE_WORKDAYS_BETWEEN */: {
|
|
2413
|
+
const endValue = safePop(stack), startValue = safePop(stack);
|
|
2414
|
+
const betweenFault = chunk2TZKENDH_cjs.faultedOperand(startValue, endValue);
|
|
2415
|
+
if (betweenFault) {
|
|
2416
|
+
stack.push(betweenFault);
|
|
2417
|
+
break;
|
|
2418
|
+
}
|
|
2419
|
+
if (startValue.type !== 4 /* Datetime */ || endValue.type !== 4 /* Datetime */) {
|
|
2420
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2421
|
+
chunkB4HBEFTB_cjs.CoreErrorCodes.WORKDAYS_BETWEEN_EXPECTED_DATES,
|
|
2422
|
+
`"working days between" expects two dates, got ${chunk2TZKENDH_cjs.ValueType[startValue.type] ?? "an unsupported value"} and ${chunk2TZKENDH_cjs.ValueType[endValue.type] ?? "an unsupported value"}`
|
|
2423
|
+
));
|
|
2424
|
+
break;
|
|
2425
|
+
}
|
|
2426
|
+
const spanLimitDays = Math.ceil((vm.getMaxDateOffsetYears() - vm.getMinDateOffsetYears()) * 366);
|
|
2427
|
+
const workdayCount = countBusinessDaysBetween(startValue.toNumber(), endValue.toNumber(), (ms) => vm.isHoliday(ms), spanLimitDays);
|
|
2428
|
+
if (workdayCount === null) {
|
|
2429
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2430
|
+
chunkB4HBEFTB_cjs.CoreErrorCodes.WORKDAYS_BETWEEN_RANGE_TOO_LARGE,
|
|
2431
|
+
`The two dates are more than ${vm.getMaxDateOffsetYears() - vm.getMinDateOffsetYears()} years apart, past the working-day count's limit`
|
|
2432
|
+
));
|
|
2433
|
+
break;
|
|
2434
|
+
}
|
|
2435
|
+
stack.push(chunk2TZKENDH_cjs.numberValue(workdayCount));
|
|
2136
2436
|
break;
|
|
2137
2437
|
}
|
|
2138
2438
|
case 93 /* DATE_NEXT_WEEKDAY */:
|
|
2139
2439
|
case 94 /* DATE_LAST_WEEKDAY */: {
|
|
2140
2440
|
const targetDayValue = safePop(stack);
|
|
2141
2441
|
const nowValue = safePop(stack);
|
|
2142
|
-
const weekdayFault =
|
|
2442
|
+
const weekdayFault = chunk2TZKENDH_cjs.faultedOperand(nowValue, targetDayValue);
|
|
2143
2443
|
if (weekdayFault) {
|
|
2144
2444
|
stack.push(weekdayFault);
|
|
2145
2445
|
break;
|
|
@@ -2149,7 +2449,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2149
2449
|
const currentDay = new Date(now).getDay();
|
|
2150
2450
|
let diffDays = op === 93 /* DATE_NEXT_WEEKDAY */ ? (targetDay - currentDay + 7) % 7 : (currentDay - targetDay + 7) % 7;
|
|
2151
2451
|
if (diffDays === 0) diffDays = 7;
|
|
2152
|
-
stack.push(
|
|
2452
|
+
stack.push(chunk2TZKENDH_cjs.datetimeValue(addCalendarDays(now, op === 93 /* DATE_NEXT_WEEKDAY */ ? diffDays : -diffDays)));
|
|
2153
2453
|
break;
|
|
2154
2454
|
}
|
|
2155
2455
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2164,116 +2464,116 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2164
2464
|
const rows = operandByte(opcodes, ip++, op, "row count");
|
|
2165
2465
|
const cols = operandByte(opcodes, ip++, op, "column count");
|
|
2166
2466
|
const count = rows * cols;
|
|
2167
|
-
const rowMajor =
|
|
2467
|
+
const rowMajor = chunk2TZKENDH_cjs.checkedArray(count, "matrix cells");
|
|
2168
2468
|
let cellFault = null;
|
|
2169
2469
|
for (let i = count - 1; i >= 0; i--) {
|
|
2170
2470
|
const cellVal = safePop(stack);
|
|
2171
|
-
if (cellFault === null) cellFault =
|
|
2471
|
+
if (cellFault === null) cellFault = chunk2TZKENDH_cjs.faultedOperand(cellVal);
|
|
2172
2472
|
rowMajor[i] = cellVal.type === 10 /* Boolean */ ? cellVal.value : cellVal.type === 9 /* Symbolic */ ? cellVal.value : cellVal.toNumber();
|
|
2173
2473
|
}
|
|
2174
2474
|
if (cellFault) {
|
|
2175
2475
|
stack.push(cellFault);
|
|
2176
2476
|
break;
|
|
2177
2477
|
}
|
|
2178
|
-
stack.push(
|
|
2478
|
+
stack.push(chunk2TZKENDH_cjs.matrixValue(rows, cols, chunkHIQ5HSZL_cjs.rowMajorToColumnMajor(rows, cols, rowMajor)));
|
|
2179
2479
|
break;
|
|
2180
2480
|
}
|
|
2181
2481
|
case 153 /* MAT_INDEX1 */: {
|
|
2182
2482
|
const indexVal = safePop(stack), matrixVal = safePop(stack);
|
|
2183
|
-
const index1Fault =
|
|
2483
|
+
const index1Fault = chunk2TZKENDH_cjs.faultedOperand(matrixVal, indexVal);
|
|
2184
2484
|
if (index1Fault) {
|
|
2185
2485
|
stack.push(index1Fault);
|
|
2186
2486
|
break;
|
|
2187
2487
|
}
|
|
2188
2488
|
if (matrixVal.type !== 7 /* Matrix */) {
|
|
2189
|
-
stack.push(
|
|
2489
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("MATRIX_INDEX_NOT_A_MATRIX", `Cannot index a non-matrix value with "[...]".`));
|
|
2190
2490
|
break;
|
|
2191
2491
|
}
|
|
2192
2492
|
const m = matrixVal.value;
|
|
2193
2493
|
const index = Math.trunc(indexVal.toNumber());
|
|
2194
2494
|
if (index < 0 || index >= m.data.length) {
|
|
2195
|
-
stack.push(
|
|
2495
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2196
2496
|
"MATRIX_INDEX_OUT_OF_BOUNDS",
|
|
2197
2497
|
`Index ${index} is out of bounds for a ${m.rows}x${m.cols} matrix (valid range: 0-${m.data.length - 1}).`
|
|
2198
2498
|
));
|
|
2199
2499
|
break;
|
|
2200
2500
|
}
|
|
2201
|
-
const cell =
|
|
2202
|
-
stack.push(
|
|
2501
|
+
const cell = chunkHIQ5HSZL_cjs.matIndex(m, index);
|
|
2502
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixEntryToValue(cell));
|
|
2203
2503
|
break;
|
|
2204
2504
|
}
|
|
2205
2505
|
case 154 /* MAT_INDEX2 */: {
|
|
2206
2506
|
const colVal = safePop(stack), rowVal = safePop(stack), matrixVal = safePop(stack);
|
|
2207
|
-
const index2Fault =
|
|
2507
|
+
const index2Fault = chunk2TZKENDH_cjs.faultedOperand(matrixVal, rowVal, colVal);
|
|
2208
2508
|
if (index2Fault) {
|
|
2209
2509
|
stack.push(index2Fault);
|
|
2210
2510
|
break;
|
|
2211
2511
|
}
|
|
2212
2512
|
if (matrixVal.type !== 7 /* Matrix */) {
|
|
2213
|
-
stack.push(
|
|
2513
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("MATRIX_INDEX_NOT_A_MATRIX", `Cannot index a non-matrix value with "[...]".`));
|
|
2214
2514
|
break;
|
|
2215
2515
|
}
|
|
2216
2516
|
const m = matrixVal.value;
|
|
2217
2517
|
const row = Math.trunc(rowVal.toNumber());
|
|
2218
2518
|
const col = Math.trunc(colVal.toNumber());
|
|
2219
|
-
if (!
|
|
2220
|
-
stack.push(
|
|
2519
|
+
if (!chunkHIQ5HSZL_cjs.inBounds(m, row, col)) {
|
|
2520
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2221
2521
|
"MATRIX_INDEX_OUT_OF_BOUNDS",
|
|
2222
2522
|
`[${row}, ${col}] is out of bounds for a ${m.rows}x${m.cols} matrix.`
|
|
2223
2523
|
));
|
|
2224
2524
|
break;
|
|
2225
2525
|
}
|
|
2226
|
-
const cell =
|
|
2227
|
-
stack.push(
|
|
2526
|
+
const cell = chunkHIQ5HSZL_cjs.matAt(m, row, col);
|
|
2527
|
+
stack.push(chunkHIQ5HSZL_cjs.matrixEntryToValue(cell));
|
|
2228
2528
|
break;
|
|
2229
2529
|
}
|
|
2230
2530
|
case 156 /* RANGE_NEW */: {
|
|
2231
2531
|
const maxVal = safePop(stack), minVal = safePop(stack);
|
|
2232
|
-
const rangeFault =
|
|
2532
|
+
const rangeFault = chunk2TZKENDH_cjs.faultedOperand(minVal, maxVal);
|
|
2233
2533
|
if (rangeFault) {
|
|
2234
2534
|
stack.push(rangeFault);
|
|
2235
2535
|
break;
|
|
2236
2536
|
}
|
|
2237
2537
|
if (minVal.type !== 0 /* Number */ || maxVal.type !== 0 /* Number */) {
|
|
2238
|
-
stack.push(
|
|
2538
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("INVALID_RANGE_BOUND", `A range's bounds must be plain numbers (e.g. "0:3").`));
|
|
2239
2539
|
break;
|
|
2240
2540
|
}
|
|
2241
2541
|
const min = minVal.value;
|
|
2242
2542
|
const max = maxVal.value;
|
|
2243
2543
|
if (!Number.isInteger(min) || !Number.isInteger(max)) {
|
|
2244
|
-
stack.push(
|
|
2544
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("NON_INTEGER_RANGE_BOUND", `A range's bounds must be whole numbers, got "${min}:${max}".`));
|
|
2245
2545
|
break;
|
|
2246
2546
|
}
|
|
2247
2547
|
if (min > max) {
|
|
2248
|
-
stack.push(
|
|
2548
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2249
2549
|
"DESCENDING_RANGE",
|
|
2250
2550
|
`A range's min (${min}) cannot be greater than its max (${max}) \u2014 did you mean "${max}:${min}"?`
|
|
2251
2551
|
));
|
|
2252
2552
|
break;
|
|
2253
2553
|
}
|
|
2254
|
-
stack.push(
|
|
2554
|
+
stack.push(chunk2TZKENDH_cjs.rangeValue(min, max));
|
|
2255
2555
|
break;
|
|
2256
2556
|
}
|
|
2257
2557
|
case 155 /* MAT_SLICE */: {
|
|
2258
2558
|
const colRangeVal = safePop(stack), rowRangeVal = safePop(stack), matrixVal = safePop(stack);
|
|
2259
|
-
const sliceFault =
|
|
2559
|
+
const sliceFault = chunk2TZKENDH_cjs.faultedOperand(matrixVal, rowRangeVal, colRangeVal);
|
|
2260
2560
|
if (sliceFault) {
|
|
2261
2561
|
stack.push(sliceFault);
|
|
2262
2562
|
break;
|
|
2263
2563
|
}
|
|
2264
2564
|
if (matrixVal.type !== 7 /* Matrix */) {
|
|
2265
|
-
stack.push(
|
|
2565
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("MATRIX_INDEX_NOT_A_MATRIX", `Cannot slice a non-matrix value with "[...]".`));
|
|
2266
2566
|
break;
|
|
2267
2567
|
}
|
|
2268
2568
|
if (rowRangeVal.type !== 8 /* Range */ || colRangeVal.type !== 8 /* Range */) {
|
|
2269
|
-
stack.push(
|
|
2569
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("INVALID_MATRIX_SLICE_BOUND", `Matrix slicing needs range bounds (e.g. "a[0:1, 1:2]").`));
|
|
2270
2570
|
break;
|
|
2271
2571
|
}
|
|
2272
2572
|
const m = matrixVal.value;
|
|
2273
2573
|
const rowRange = rowRangeVal.value;
|
|
2274
2574
|
const colRange = colRangeVal.value;
|
|
2275
2575
|
if (rowRange.min < 0 || rowRange.max >= m.rows || colRange.min < 0 || colRange.max >= m.cols) {
|
|
2276
|
-
stack.push(
|
|
2576
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2277
2577
|
"MATRIX_INDEX_OUT_OF_BOUNDS",
|
|
2278
2578
|
`Slice [${rowRange.min}:${rowRange.max}, ${colRange.min}:${colRange.max}] is out of bounds for a ${m.rows}x${m.cols} matrix.`
|
|
2279
2579
|
));
|
|
@@ -2281,13 +2581,13 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2281
2581
|
}
|
|
2282
2582
|
const newRows = rowRange.max - rowRange.min + 1;
|
|
2283
2583
|
const newCols = colRange.max - colRange.min + 1;
|
|
2284
|
-
const data =
|
|
2584
|
+
const data = chunk2TZKENDH_cjs.checkedArray(newRows * newCols, "matrix cells");
|
|
2285
2585
|
for (let r = 0; r < newRows; r++) {
|
|
2286
2586
|
for (let c = 0; c < newCols; c++) {
|
|
2287
|
-
data[r + c * newRows] =
|
|
2587
|
+
data[r + c * newRows] = chunkHIQ5HSZL_cjs.matAt(m, rowRange.min + r, colRange.min + c);
|
|
2288
2588
|
}
|
|
2289
2589
|
}
|
|
2290
|
-
stack.push(
|
|
2590
|
+
stack.push(chunk2TZKENDH_cjs.matrixValue(newRows, newCols, data));
|
|
2291
2591
|
break;
|
|
2292
2592
|
}
|
|
2293
2593
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2310,7 +2610,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2310
2610
|
if (kind === 0) {
|
|
2311
2611
|
const def = anonymousBodies?.[ref];
|
|
2312
2612
|
if (!def) {
|
|
2313
|
-
throw
|
|
2613
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.internal(
|
|
2314
2614
|
"INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
2315
2615
|
`Internal error: MAP_INVOKE referenced missing anonymous body index ${ref}`,
|
|
2316
2616
|
{ ref }
|
|
@@ -2322,11 +2622,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2322
2622
|
const name = pooledString(strings, ref, op);
|
|
2323
2623
|
const fn = vm.getUserFunction(name);
|
|
2324
2624
|
if (!fn) {
|
|
2325
|
-
stack.push(
|
|
2625
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("UNDEFINED_FUNCTION", `map: undefined function "${name}"`));
|
|
2326
2626
|
break;
|
|
2327
2627
|
}
|
|
2328
2628
|
if (fn.params.length !== collectionCount) {
|
|
2329
|
-
stack.push(
|
|
2629
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2330
2630
|
"FUNCTION_ARITY_MISMATCH",
|
|
2331
2631
|
`map: "${name}" expects ${fn.params.length} argument(s) but ${collectionCount} collection(s) were given`
|
|
2332
2632
|
));
|
|
@@ -2339,16 +2639,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2339
2639
|
const cellArrays = new Array(collectionCount);
|
|
2340
2640
|
let mapEarlyError;
|
|
2341
2641
|
for (let i = 0; i < collectionCount; i++) {
|
|
2342
|
-
const resolved =
|
|
2642
|
+
const resolved = chunkHIQ5HSZL_cjs.collectionToValues(rawCollections[i], vm.getMaxCollectionSize());
|
|
2343
2643
|
if (!Array.isArray(resolved)) {
|
|
2344
2644
|
mapEarlyError = resolved;
|
|
2345
2645
|
break;
|
|
2346
2646
|
}
|
|
2347
|
-
|
|
2647
|
+
chunk2TZKENDH_cjs.chargeAllocation(resolved.length, "collection elements");
|
|
2348
2648
|
if (collectionLength === -1) {
|
|
2349
2649
|
collectionLength = resolved.length;
|
|
2350
2650
|
} else if (resolved.length !== collectionLength) {
|
|
2351
|
-
mapEarlyError =
|
|
2651
|
+
mapEarlyError = chunk2TZKENDH_cjs.errorValue(
|
|
2352
2652
|
"MAP_COLLECTION_LENGTH_MISMATCH",
|
|
2353
2653
|
`map: all collections must have the same length (got ${collectionLength} and ${resolved.length}).`
|
|
2354
2654
|
);
|
|
@@ -2360,13 +2660,13 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2360
2660
|
stack.push(mapEarlyError);
|
|
2361
2661
|
break;
|
|
2362
2662
|
}
|
|
2363
|
-
const resultData =
|
|
2663
|
+
const resultData = chunk2TZKENDH_cjs.checkedArray(collectionLength, "matrix cells");
|
|
2364
2664
|
let mapError;
|
|
2365
2665
|
for (let i = 0; i < collectionLength; i++) {
|
|
2366
2666
|
const args = new Array(collectionCount);
|
|
2367
2667
|
for (let j = 0; j < collectionCount; j++) args[j] = cellArrays[j][i];
|
|
2368
|
-
const resultVal = kind === 1 ?
|
|
2369
|
-
const resultFault =
|
|
2668
|
+
const resultVal = kind === 1 ? chunk7ZX6B7SY_cjs.builtinFunctions[ref]?.(args) ?? chunk2TZKENDH_cjs.errorValue("UNKNOWN_BUILTIN_FUNCTION", `map: unknown builtin function index ${ref}`) : invokeFrameBody(paramNames, program, args, vm, pipeline, expression, context, !!symbolicTolerant);
|
|
2669
|
+
const resultFault = chunk2TZKENDH_cjs.faultedOperand(resultVal);
|
|
2370
2670
|
if (resultFault) {
|
|
2371
2671
|
mapError = resultFault;
|
|
2372
2672
|
break;
|
|
@@ -2380,9 +2680,9 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2380
2680
|
const firstCollection = rawCollections[0];
|
|
2381
2681
|
const sourceShape = firstCollection?.type === 7 /* Matrix */ ? firstCollection.value : void 0;
|
|
2382
2682
|
if (sourceShape && sourceShape.rows * sourceShape.cols === collectionLength) {
|
|
2383
|
-
stack.push(
|
|
2683
|
+
stack.push(chunk2TZKENDH_cjs.matrixValue(sourceShape.rows, sourceShape.cols, resultData));
|
|
2384
2684
|
} else {
|
|
2385
|
-
stack.push(
|
|
2685
|
+
stack.push(chunk2TZKENDH_cjs.matrixValue(1, collectionLength, resultData));
|
|
2386
2686
|
}
|
|
2387
2687
|
break;
|
|
2388
2688
|
}
|
|
@@ -2398,7 +2698,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2398
2698
|
if (kind === 0) {
|
|
2399
2699
|
const def = anonymousBodies?.[ref];
|
|
2400
2700
|
if (!def) {
|
|
2401
|
-
throw
|
|
2701
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.internal(
|
|
2402
2702
|
"INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
2403
2703
|
`Internal error: REDUCE_INVOKE referenced missing anonymous body index ${ref}`,
|
|
2404
2704
|
{ ref }
|
|
@@ -2410,11 +2710,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2410
2710
|
const name = pooledString(strings, ref, op);
|
|
2411
2711
|
const fn = vm.getUserFunction(name);
|
|
2412
2712
|
if (!fn) {
|
|
2413
|
-
stack.push(
|
|
2713
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("UNDEFINED_FUNCTION", `reduce: undefined function "${name}"`));
|
|
2414
2714
|
break;
|
|
2415
2715
|
}
|
|
2416
2716
|
if (fn.params.length !== 2) {
|
|
2417
|
-
stack.push(
|
|
2717
|
+
stack.push(chunk2TZKENDH_cjs.errorValue(
|
|
2418
2718
|
"FUNCTION_ARITY_MISMATCH",
|
|
2419
2719
|
`reduce: "${name}" must take exactly 2 arguments (accumulator, element), got ${fn.params.length}`
|
|
2420
2720
|
));
|
|
@@ -2423,16 +2723,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2423
2723
|
paramNames = fn.params;
|
|
2424
2724
|
program = fn.program;
|
|
2425
2725
|
}
|
|
2426
|
-
const cells =
|
|
2726
|
+
const cells = chunkHIQ5HSZL_cjs.collectionToValues(collectionVal, vm.getMaxCollectionSize());
|
|
2427
2727
|
if (!Array.isArray(cells)) {
|
|
2428
2728
|
stack.push(cells);
|
|
2429
2729
|
break;
|
|
2430
2730
|
}
|
|
2431
|
-
|
|
2731
|
+
chunk2TZKENDH_cjs.chargeAllocation(cells.length, "collection elements");
|
|
2432
2732
|
let acc;
|
|
2433
2733
|
let startIdx;
|
|
2434
2734
|
if (initialVal !== void 0) {
|
|
2435
|
-
const initialFault =
|
|
2735
|
+
const initialFault = chunk2TZKENDH_cjs.faultedOperand(initialVal);
|
|
2436
2736
|
if (initialFault) {
|
|
2437
2737
|
stack.push(initialFault);
|
|
2438
2738
|
break;
|
|
@@ -2441,7 +2741,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2441
2741
|
startIdx = 0;
|
|
2442
2742
|
} else {
|
|
2443
2743
|
if (cells.length === 0) {
|
|
2444
|
-
stack.push(
|
|
2744
|
+
stack.push(chunk2TZKENDH_cjs.errorValue("REDUCE_EMPTY_COLLECTION", `reduce: cannot reduce an empty collection without an initial value.`));
|
|
2445
2745
|
break;
|
|
2446
2746
|
}
|
|
2447
2747
|
acc = cells[0];
|
|
@@ -2450,8 +2750,8 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2450
2750
|
let reduceError;
|
|
2451
2751
|
for (let i = startIdx; i < cells.length; i++) {
|
|
2452
2752
|
const args = [acc, cells[i]];
|
|
2453
|
-
const resultVal = kind === 1 ?
|
|
2454
|
-
const stepFault =
|
|
2753
|
+
const resultVal = kind === 1 ? chunk7ZX6B7SY_cjs.builtinFunctions[ref]?.(args) ?? chunk2TZKENDH_cjs.errorValue("UNKNOWN_BUILTIN_FUNCTION", `reduce: unknown builtin function index ${ref}`) : invokeFrameBody(paramNames, program, args, vm, pipeline, expression, context, !!symbolicTolerant);
|
|
2754
|
+
const stepFault = chunk2TZKENDH_cjs.faultedOperand(resultVal);
|
|
2455
2755
|
if (stepFault) {
|
|
2456
2756
|
reduceError = stepFault;
|
|
2457
2757
|
break;
|
|
@@ -2472,7 +2772,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2472
2772
|
const ref = operandByte(opcodes, ip++, op, "body reference");
|
|
2473
2773
|
const def = anonymousBodies?.[ref];
|
|
2474
2774
|
if (!def) {
|
|
2475
|
-
throw
|
|
2775
|
+
throw chunkB4HBEFTB_cjs.ErrorFactory.internal(
|
|
2476
2776
|
"INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
2477
2777
|
`Internal error: BIND_UNKNOWN referenced missing anonymous body index ${ref}`,
|
|
2478
2778
|
{ ref }
|
|
@@ -2484,11 +2784,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2484
2784
|
}
|
|
2485
2785
|
}
|
|
2486
2786
|
const fallback = safePop(stack);
|
|
2487
|
-
return { type: "value", value: hasArena ?
|
|
2787
|
+
return { type: "value", value: hasArena ? chunk2TZKENDH_cjs.persistentValue(fallback) : fallback };
|
|
2488
2788
|
} catch (e) {
|
|
2489
|
-
return { type: "error", error:
|
|
2789
|
+
return { type: "error", error: chunkB4HBEFTB_cjs.normalizeUnknownError(e) };
|
|
2490
2790
|
} finally {
|
|
2491
|
-
|
|
2791
|
+
chunk2TZKENDH_cjs.endEvaluation();
|
|
2492
2792
|
}
|
|
2493
2793
|
}
|
|
2494
2794
|
|
|
@@ -2496,5 +2796,5 @@ exports.DependencyGraph = DependencyGraph;
|
|
|
2496
2796
|
exports.ScopeManager = ScopeManager;
|
|
2497
2797
|
exports.createVM = createVM;
|
|
2498
2798
|
exports.executeBytecode = executeBytecode;
|
|
2499
|
-
//# sourceMappingURL=chunk-
|
|
2500
|
-
//# sourceMappingURL=chunk-
|
|
2799
|
+
//# sourceMappingURL=chunk-SRGQ72IR.cjs.map
|
|
2800
|
+
//# sourceMappingURL=chunk-SRGQ72IR.cjs.map
|