solve-engine 1.1.1 → 1.2.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/{EngineError-B61GS1jp.d.cts → EngineError-CNA_rHY-.d.cts} +6 -0
- package/dist/{EngineError-B61GS1jp.d.ts → EngineError-CNA_rHY-.d.ts} +6 -0
- package/dist/{Lexer-BOs7euZe.d.cts → Lexer-B4C1qHXu.d.cts} +1 -1
- package/dist/{Lexer-CSI_lwbW.d.ts → Lexer-DKMlj7Sy.d.ts} +1 -1
- package/dist/{PackageCompatibility-B-7rK1TD.d.cts → PackageCompatibility-B6NX9IaN.d.cts} +1 -1
- package/dist/{PackageCompatibility-Dh59eF-X.d.ts → PackageCompatibility-Ceg5XdAp.d.ts} +1 -1
- package/dist/{PackageRegistry-BHWJP83F.d.cts → PackageRegistry-DnJYVw9G.d.cts} +55 -8
- package/dist/{PackageRegistry-_8rDlvxI.d.ts → PackageRegistry-DrCPQNyy.d.ts} +55 -8
- package/dist/{Parselet-BBT8riYh.d.ts → Parselet-Bhf7d0_W.d.ts} +2 -2
- package/dist/{Parselet-BHcgK9S7.d.cts → Parselet-Cv7S7KRt.d.cts} +2 -2
- package/dist/{ScopeManager-CxA24W5n.d.ts → ScopeManager-Bzq87GfA.d.ts} +10 -3
- package/dist/{ScopeManager-8vf02dwj.d.cts → ScopeManager-DRDBVfan.d.cts} +10 -3
- package/dist/{Token-B1hdkedD.d.cts → Token-CbP_OutD.d.cts} +9 -0
- package/dist/{Token-B1hdkedD.d.ts → Token-CbP_OutD.d.ts} +9 -0
- package/dist/{TokenNormalizer-C6VzZgHa.d.ts → TokenNormalizer-DCWdZjGz.d.ts} +1 -1
- package/dist/{TokenNormalizer-DRc1Js1V.d.cts → TokenNormalizer-DnlL7_8c.d.cts} +1 -1
- package/dist/{VMCheckpoints-MK--EBH2.d.ts → VMCheckpoints-C6c17Hbo.d.ts} +2 -2
- package/dist/{VMCheckpoints-ELYqITdF.d.cts → VMCheckpoints-dZxSMGHG.d.cts} +2 -2
- package/dist/{Value-BUi1RA3S.d.cts → Value-DZNQ_PU7.d.cts} +32 -5
- package/dist/{Value-BUi1RA3S.d.ts → Value-DZNQ_PU7.d.ts} +32 -5
- package/dist/{WorkerError-_-RkoQ5P.d.ts → WorkerError-B7t7R2-m.d.ts} +1 -1
- package/dist/{WorkerError-gzmaopj2.d.cts → WorkerError-Djd7GGGa.d.cts} +1 -1
- package/dist/{chunk-SSV46KFA.cjs → chunk-4K5W7EH2.cjs} +6 -6
- package/dist/{chunk-SSV46KFA.cjs.map → chunk-4K5W7EH2.cjs.map} +1 -1
- package/dist/{chunk-267JPOTF.js → chunk-5EFKSKMA.js} +11 -4
- package/dist/chunk-5EFKSKMA.js.map +1 -0
- package/dist/{chunk-536WPM2V.cjs → chunk-7AXJNQMF.cjs} +17 -3
- package/dist/chunk-7AXJNQMF.cjs.map +1 -0
- package/dist/{chunk-LHZ6VOA7.js → chunk-7JM3F4KL.js} +39 -8
- package/dist/chunk-7JM3F4KL.js.map +1 -0
- package/dist/{chunk-N5NNW4VG.cjs → chunk-7USV76HV.cjs} +6 -6
- package/dist/{chunk-N5NNW4VG.cjs.map → chunk-7USV76HV.cjs.map} +1 -1
- package/dist/{chunk-HIQ5HSZL.cjs → chunk-A2DZ5BEJ.cjs} +53 -46
- package/dist/{chunk-HIQ5HSZL.cjs.map → chunk-A2DZ5BEJ.cjs.map} +1 -1
- package/dist/{chunk-CKQMXMHR.cjs → chunk-AKNGX4TZ.cjs} +28 -11
- package/dist/chunk-AKNGX4TZ.cjs.map +1 -0
- package/dist/{chunk-I4GAWIPW.js → chunk-AOH6UR2L.js} +6 -6
- package/dist/{chunk-I4GAWIPW.js.map → chunk-AOH6UR2L.js.map} +1 -1
- package/dist/{chunk-T6ZYQJ63.cjs → chunk-BESTLPRK.cjs} +326 -214
- package/dist/chunk-BESTLPRK.cjs.map +1 -0
- package/dist/{chunk-Z7XGGLI2.js → chunk-BSPXMGIS.js} +3 -3
- package/dist/{chunk-Z7XGGLI2.js.map → chunk-BSPXMGIS.js.map} +1 -1
- package/dist/{chunk-SRGQ72IR.cjs → chunk-C2OMO3WN.cjs} +376 -370
- package/dist/chunk-C2OMO3WN.cjs.map +1 -0
- package/dist/{chunk-GLA4JXBO.js → chunk-CSDQMDU2.js} +4 -4
- package/dist/{chunk-GLA4JXBO.js.map → chunk-CSDQMDU2.js.map} +1 -1
- package/dist/{chunk-7KYSUDQO.js → chunk-F4UB4XIL.js} +4 -4
- package/dist/{chunk-7KYSUDQO.js.map → chunk-F4UB4XIL.js.map} +1 -1
- package/dist/{chunk-WXEHD6TT.js → chunk-FE4RC37D.js} +15 -9
- package/dist/chunk-FE4RC37D.js.map +1 -0
- package/dist/{chunk-7ZX6B7SY.cjs → chunk-FR7RNOPT.cjs} +637 -556
- package/dist/chunk-FR7RNOPT.cjs.map +1 -0
- package/dist/{chunk-QFTDTX6K.cjs → chunk-G2YPPLGX.cjs} +29 -2
- package/dist/chunk-G2YPPLGX.cjs.map +1 -0
- package/dist/{chunk-HVRVSI2Z.cjs → chunk-GDEU72RG.cjs} +86 -86
- package/dist/{chunk-HVRVSI2Z.cjs.map → chunk-GDEU72RG.cjs.map} +1 -1
- package/dist/{chunk-MN3LHRGV.cjs → chunk-HKTQCQ4Z.cjs} +860 -489
- package/dist/chunk-HKTQCQ4Z.cjs.map +1 -0
- package/dist/{chunk-XA4CKRML.cjs → chunk-HWHU642X.cjs} +2 -2
- package/dist/{chunk-XA4CKRML.cjs.map → chunk-HWHU642X.cjs.map} +1 -1
- package/dist/{chunk-CUR2WLI4.cjs → chunk-ICEKS6YC.cjs} +11 -11
- package/dist/{chunk-CUR2WLI4.cjs.map → chunk-ICEKS6YC.cjs.map} +1 -1
- package/dist/{chunk-NNZAEUDW.js → chunk-IJGOFP2J.js} +138 -26
- package/dist/chunk-IJGOFP2J.js.map +1 -0
- package/dist/{chunk-ENKKJYD3.js → chunk-IQJGDZOP.js} +4 -4
- package/dist/{chunk-ENKKJYD3.js.map → chunk-IQJGDZOP.js.map} +1 -1
- package/dist/{chunk-2TZKENDH.cjs → chunk-IT74O4BE.cjs} +15 -7
- package/dist/chunk-IT74O4BE.cjs.map +1 -0
- package/dist/{chunk-ZVTWQLK4.cjs → chunk-KXDQKVNX.cjs} +10 -10
- package/dist/{chunk-ZVTWQLK4.cjs.map → chunk-KXDQKVNX.cjs.map} +1 -1
- package/dist/{chunk-BYJBUL7U.js → chunk-L5YHV6BQ.js} +5 -5
- package/dist/{chunk-BYJBUL7U.js.map → chunk-L5YHV6BQ.js.map} +1 -1
- package/dist/{chunk-E23GZEWL.cjs → chunk-LO7HU5WB.cjs} +8 -8
- package/dist/{chunk-E23GZEWL.cjs.map → chunk-LO7HU5WB.cjs.map} +1 -1
- package/dist/{chunk-UO6BUV6K.js → chunk-LSALB3IN.js} +17 -3
- package/dist/chunk-LSALB3IN.js.map +1 -0
- package/dist/{chunk-J45BCEZ4.cjs → chunk-MI7OTUHL.cjs} +27 -27
- package/dist/{chunk-J45BCEZ4.cjs.map → chunk-MI7OTUHL.cjs.map} +1 -1
- package/dist/{chunk-B4HBEFTB.cjs → chunk-MIGXCBXT.cjs} +8 -2
- package/dist/chunk-MIGXCBXT.cjs.map +1 -0
- package/dist/{chunk-ERCOHGXD.js → chunk-N7OA4WPJ.js} +8 -2
- package/dist/chunk-N7OA4WPJ.js.map +1 -0
- package/dist/{chunk-4D6NIHE2.js → chunk-NAWZATKT.js} +29 -2
- package/dist/chunk-NAWZATKT.js.map +1 -0
- package/dist/{chunk-JG6ZJ2WU.js → chunk-ORM7CHYZ.js} +23 -5
- package/dist/chunk-ORM7CHYZ.js.map +1 -0
- package/dist/{chunk-B7NLZMQ3.cjs → chunk-PCZVMMWU.cjs} +8 -8
- package/dist/{chunk-B7NLZMQ3.cjs.map → chunk-PCZVMMWU.cjs.map} +1 -1
- package/dist/{chunk-DLEBSLF4.js → chunk-RNKDIXDV.js} +4 -4
- package/dist/{chunk-DLEBSLF4.js.map → chunk-RNKDIXDV.js.map} +1 -1
- package/dist/{chunk-YRIKITGF.cjs → chunk-TC6BTUSU.cjs} +55 -24
- package/dist/chunk-TC6BTUSU.cjs.map +1 -0
- package/dist/{chunk-4HQKTMWG.js → chunk-TPOK3UNI.js} +387 -17
- package/dist/chunk-TPOK3UNI.js.map +1 -0
- package/dist/{chunk-CCBZZQAE.js → chunk-UF6JG5SG.js} +2 -2
- package/dist/{chunk-CCBZZQAE.js.map → chunk-UF6JG5SG.js.map} +1 -1
- package/dist/{chunk-NKW7LKYU.js → chunk-WMQRJTAO.js} +88 -7
- package/dist/chunk-WMQRJTAO.js.map +1 -0
- package/dist/{chunk-ZMW6NU2K.cjs → chunk-YJHY7CMN.cjs} +95 -77
- package/dist/chunk-YJHY7CMN.cjs.map +1 -0
- package/dist/{chunk-3OWCDIPN.js → chunk-YNIWOYW6.js} +21 -4
- package/dist/chunk-YNIWOYW6.js.map +1 -0
- package/dist/{chunk-WWQEY7BV.js → chunk-ZN6YYPIW.js} +3 -3
- package/dist/{chunk-WWQEY7BV.js.map → chunk-ZN6YYPIW.js.map} +1 -1
- package/dist/{chunk-NNQ2TYDF.js → chunk-ZNFFTYWH.js} +11 -5
- package/dist/chunk-ZNFFTYWH.js.map +1 -0
- package/dist/constants.cjs +5 -5
- package/dist/constants.js +2 -2
- package/dist/engine.cjs +33 -33
- package/dist/engine.d.cts +27 -11
- package/dist/engine.d.ts +27 -11
- package/dist/engine.js +20 -20
- package/dist/errors.cjs +26 -26
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +2 -2
- package/dist/format.cjs +7 -7
- package/dist/format.d.cts +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/format.js +4 -4
- package/dist/index.cjs +48 -48
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +21 -21
- package/dist/language.cjs +7 -7
- package/dist/language.d.cts +10 -10
- package/dist/language.d.ts +10 -10
- package/dist/language.js +2 -2
- 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 +40 -36
- package/dist/packages.d.cts +37 -11
- package/dist/packages.d.ts +37 -11
- package/dist/packages.js +11 -11
- package/dist/parser.cjs +13 -13
- package/dist/parser.d.cts +4 -4
- package/dist/parser.d.ts +4 -4
- package/dist/parser.js +5 -5
- package/dist/{pipeline-DCd5M6Gk.d.ts → pipeline-D-PS9gVw.d.ts} +3 -3
- package/dist/{pipeline-CtfJtPQc.d.cts → pipeline-DtSBJ8TS.d.cts} +3 -3
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/testing.cjs +26 -26
- package/dist/testing.d.cts +10 -10
- package/dist/testing.d.ts +10 -10
- package/dist/testing.js +19 -19
- package/dist/uom.cjs +8 -8
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +4 -4
- package/dist/vm.cjs +32 -32
- package/dist/vm.d.cts +7 -7
- package/dist/vm.d.ts +7 -7
- package/dist/vm.js +7 -7
- package/dist/worker.cjs +38 -38
- package/dist/worker.d.cts +10 -10
- package/dist/worker.d.ts +10 -10
- package/dist/worker.js +20 -20
- package/package.json +1 -1
- package/dist/chunk-267JPOTF.js.map +0 -1
- package/dist/chunk-2TZKENDH.cjs.map +0 -1
- package/dist/chunk-3OWCDIPN.js.map +0 -1
- package/dist/chunk-4D6NIHE2.js.map +0 -1
- package/dist/chunk-4HQKTMWG.js.map +0 -1
- package/dist/chunk-536WPM2V.cjs.map +0 -1
- package/dist/chunk-7ZX6B7SY.cjs.map +0 -1
- package/dist/chunk-B4HBEFTB.cjs.map +0 -1
- package/dist/chunk-CKQMXMHR.cjs.map +0 -1
- package/dist/chunk-ERCOHGXD.js.map +0 -1
- package/dist/chunk-JG6ZJ2WU.js.map +0 -1
- package/dist/chunk-LHZ6VOA7.js.map +0 -1
- package/dist/chunk-MN3LHRGV.cjs.map +0 -1
- package/dist/chunk-NKW7LKYU.js.map +0 -1
- package/dist/chunk-NNQ2TYDF.js.map +0 -1
- package/dist/chunk-NNZAEUDW.js.map +0 -1
- package/dist/chunk-QFTDTX6K.cjs.map +0 -1
- package/dist/chunk-SRGQ72IR.cjs.map +0 -1
- package/dist/chunk-T6ZYQJ63.cjs.map +0 -1
- package/dist/chunk-UO6BUV6K.js.map +0 -1
- package/dist/chunk-WXEHD6TT.js.map +0 -1
- package/dist/chunk-YRIKITGF.cjs.map +0 -1
- package/dist/chunk-ZMW6NU2K.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkHWHU642X_cjs = require('./chunk-HWHU642X.cjs');
|
|
4
|
+
var chunkFR7RNOPT_cjs = require('./chunk-FR7RNOPT.cjs');
|
|
5
|
+
var chunkKXDQKVNX_cjs = require('./chunk-KXDQKVNX.cjs');
|
|
6
6
|
var chunkXIYYHA65_cjs = require('./chunk-XIYYHA65.cjs');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var chunkA2DZ5BEJ_cjs = require('./chunk-A2DZ5BEJ.cjs');
|
|
8
|
+
var chunkIT74O4BE_cjs = require('./chunk-IT74O4BE.cjs');
|
|
9
9
|
var chunkEJ3ILXX6_cjs = require('./chunk-EJ3ILXX6.cjs');
|
|
10
10
|
var chunkAMOJYLG2_cjs = require('./chunk-AMOJYLG2.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunkMIGXCBXT_cjs = require('./chunk-MIGXCBXT.cjs');
|
|
12
12
|
|
|
13
13
|
// src/vm/DependencyGraph.ts
|
|
14
14
|
var DependencyGraph = class {
|
|
@@ -483,7 +483,10 @@ var BUILTIN_ARITY = {
|
|
|
483
483
|
96: { name: "atRate", min: 2, max: 2 },
|
|
484
484
|
// Not reachable by name, only through `<value> to <n> dp`; see
|
|
485
485
|
// converters/parselets/RoundingParselets.ts.
|
|
486
|
-
97: { name: "roundToPlaces", min: 2, max: 2 }
|
|
486
|
+
97: { name: "roundToPlaces", min: 2, max: 2 },
|
|
487
|
+
98: { name: "splitEach", min: 2, max: 2 },
|
|
488
|
+
99: { name: "savingsGoalPayment", min: 3, max: 3 },
|
|
489
|
+
100: { name: "savingsGoalPeriods", min: 5, max: 5 }
|
|
487
490
|
};
|
|
488
491
|
function plural(count) {
|
|
489
492
|
return count === 1 ? "1 argument" : `${count} arguments`;
|
|
@@ -497,7 +500,7 @@ function builtinArityError(index, argCount) {
|
|
|
497
500
|
const arity = BUILTIN_ARITY[index];
|
|
498
501
|
if (arity === void 0) return void 0;
|
|
499
502
|
if (argCount >= arity.min && argCount <= arity.max) return void 0;
|
|
500
|
-
return
|
|
503
|
+
return chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
501
504
|
"BUILTIN_ARITY_MISMATCH",
|
|
502
505
|
`${arity.name}() takes ${expectation(arity)}, but was given ${argCount === 0 ? "none" : plural(argCount)}`,
|
|
503
506
|
{ functionName: arity.name, expectedMin: arity.min, expectedMax: arity.max, actual: argCount }
|
|
@@ -505,7 +508,7 @@ function builtinArityError(index, argCount) {
|
|
|
505
508
|
}
|
|
506
509
|
|
|
507
510
|
// src/vm/VM.ts
|
|
508
|
-
function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunctionRecursionDepth = 50, maxCollectionSize = 1e5, maxAllocatedElements = 2e6, maxFunctionCalls = 1e4, maxDateOffsetYears = 100, minDateOffsetYears = -100, context =
|
|
511
|
+
function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunctionRecursionDepth = 50, maxCollectionSize = 1e5, maxAllocatedElements = 2e6, maxFunctionCalls = 1e4, maxDateOffsetYears = 100, minDateOffsetYears = -100, context = chunkFR7RNOPT_cjs.defaultEngineContext, holidayPredicate) {
|
|
509
512
|
const stack = [];
|
|
510
513
|
const variables = /* @__PURE__ */ new Map();
|
|
511
514
|
let instructionCount = 0;
|
|
@@ -547,7 +550,7 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
547
550
|
},
|
|
548
551
|
pop() {
|
|
549
552
|
if (stack.length === 0) {
|
|
550
|
-
return
|
|
553
|
+
return chunkIT74O4BE_cjs.numberValue(0);
|
|
551
554
|
}
|
|
552
555
|
return stack.pop();
|
|
553
556
|
},
|
|
@@ -593,9 +596,12 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
593
596
|
setVar(key, val) {
|
|
594
597
|
variables.set(key, val);
|
|
595
598
|
},
|
|
599
|
+
deleteVar(key) {
|
|
600
|
+
variables.delete(key);
|
|
601
|
+
},
|
|
596
602
|
pushCallFrame(frame) {
|
|
597
603
|
if (callFrames.length >= maxFunctionRecursionDepth) {
|
|
598
|
-
throw
|
|
604
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
599
605
|
"FUNCTION_RECURSION_LIMIT_EXCEEDED",
|
|
600
606
|
`Function call nesting exceeded maximum depth of ${maxFunctionRecursionDepth} (possible infinite recursion, e.g. f(x) = f(x))`,
|
|
601
607
|
{ maxFunctionRecursionDepth }
|
|
@@ -678,7 +684,7 @@ function createVM(registry, maxStackDepth = 200, maxInstructions = 5e4, maxFunct
|
|
|
678
684
|
incrementInstructions(n) {
|
|
679
685
|
instructionCount += n;
|
|
680
686
|
if (instructionCount > maxInstructions) {
|
|
681
|
-
throw
|
|
687
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution("INSTRUCTION_LIMIT_EXCEEDED", `Execution exceeded maximum of ${maxInstructions} instructions`);
|
|
682
688
|
}
|
|
683
689
|
}
|
|
684
690
|
};
|
|
@@ -696,7 +702,7 @@ function matrixPowerCells(m, exponent) {
|
|
|
696
702
|
}
|
|
697
703
|
function safePop(stack) {
|
|
698
704
|
if (stack.length === 0) {
|
|
699
|
-
throw
|
|
705
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.internal({
|
|
700
706
|
code: "STACK_UNDERFLOW",
|
|
701
707
|
message: "Stack underflow: an opcode expected a value on the stack but it was empty",
|
|
702
708
|
expected: "at least one value on the VM stack",
|
|
@@ -712,7 +718,7 @@ function siteName(site) {
|
|
|
712
718
|
}
|
|
713
719
|
function malformedBytecode(code, site, problem, expected, found, context = {}) {
|
|
714
720
|
const name = siteName(site);
|
|
715
|
-
return
|
|
721
|
+
return chunkMIGXCBXT_cjs.ErrorFactory.validation({
|
|
716
722
|
code,
|
|
717
723
|
message: `Malformed bytecode: ${name} ${problem}`,
|
|
718
724
|
expected,
|
|
@@ -776,7 +782,7 @@ function stringOperand(value, site, role) {
|
|
|
776
782
|
site,
|
|
777
783
|
`expected a ${role ?? "string"} on the stack`,
|
|
778
784
|
role ? `a string value holding the ${role}` : "a string value",
|
|
779
|
-
`a ${
|
|
785
|
+
`a ${chunkIT74O4BE_cjs.ValueType[value.type] ?? "unknown"} value`,
|
|
780
786
|
role ? { role, valueType: value.type } : { valueType: value.type }
|
|
781
787
|
);
|
|
782
788
|
}
|
|
@@ -835,7 +841,7 @@ function invokeFrameBody(params, program, args, vm, pipeline, expression, contex
|
|
|
835
841
|
vm.popCallFrame();
|
|
836
842
|
}
|
|
837
843
|
if (bodyResult.type === "pending") {
|
|
838
|
-
throw
|
|
844
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
839
845
|
"MAP_REDUCE_ASYNC_UNSUPPORTED",
|
|
840
846
|
`map/reduce transform bodies calling an async operation (weather, stocks, currency, ...) aren't supported`
|
|
841
847
|
);
|
|
@@ -847,7 +853,7 @@ function invokeFrameBody(params, program, args, vm, pipeline, expression, contex
|
|
|
847
853
|
}
|
|
848
854
|
function invokeWithBoundUnknown(name, program, vm, pipeline, expression, context, symbolicTolerant) {
|
|
849
855
|
const frame = new Map(vm.getCallFrame());
|
|
850
|
-
frame.set(name,
|
|
856
|
+
frame.set(name, chunkIT74O4BE_cjs.symbolicValue(chunkA2DZ5BEJ_cjs.varNode(name)));
|
|
851
857
|
vm.pushCallFrame(frame);
|
|
852
858
|
let bodyResult;
|
|
853
859
|
try {
|
|
@@ -856,7 +862,7 @@ function invokeWithBoundUnknown(name, program, vm, pipeline, expression, context
|
|
|
856
862
|
vm.popCallFrame();
|
|
857
863
|
}
|
|
858
864
|
if (bodyResult.type === "pending") {
|
|
859
|
-
throw
|
|
865
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
860
866
|
"SYMBOLIC_ASYNC_UNSUPPORTED",
|
|
861
867
|
`an algebra verb's expression cannot call an async operation (weather, stocks, currency, ...)`
|
|
862
868
|
);
|
|
@@ -887,27 +893,27 @@ function moneyTimesQuantity(l, r) {
|
|
|
887
893
|
const rightUnit = r.unit;
|
|
888
894
|
if (leftUnit === void 0 || rightUnit === void 0) return null;
|
|
889
895
|
if (leftUnit.includes("/") || rightUnit.includes("/")) return null;
|
|
890
|
-
const leftIsMoney =
|
|
891
|
-
const rightIsMoney =
|
|
896
|
+
const leftIsMoney = chunkA2DZ5BEJ_cjs.CURRENCY_DISPLAY[leftUnit.toUpperCase()] !== void 0;
|
|
897
|
+
const rightIsMoney = chunkA2DZ5BEJ_cjs.CURRENCY_DISPLAY[rightUnit.toUpperCase()] !== void 0;
|
|
892
898
|
if (leftIsMoney === rightIsMoney) return null;
|
|
893
|
-
return
|
|
899
|
+
return chunkIT74O4BE_cjs.uomValue(l.toNumber() * r.toNumber(), leftIsMoney ? leftUnit : rightUnit);
|
|
894
900
|
}
|
|
895
901
|
function combinePercentage(l, r, sign) {
|
|
896
902
|
if (l.type === 5 /* Percentage */) {
|
|
897
903
|
if (r.type === 6 /* Uom */ && r.unit !== void 0) {
|
|
898
|
-
return
|
|
904
|
+
return chunkFR7RNOPT_cjs.scaleMoneyByPercent(r, r.unit, l.toNumber(), sign);
|
|
899
905
|
}
|
|
900
906
|
if (r.type !== 5 /* Percentage */ && r.type !== 0 /* Number */) return null;
|
|
901
|
-
return
|
|
907
|
+
return chunkIT74O4BE_cjs.percentageValue(l.toNumber() + sign * r.toNumber());
|
|
902
908
|
}
|
|
903
909
|
if (r.type !== 5 /* Percentage */) return null;
|
|
904
910
|
const factor = 1 + sign * r.toNumber();
|
|
905
911
|
if (l.type === 0 /* Number */) {
|
|
906
912
|
const scaled = l.toNumber() * factor;
|
|
907
|
-
if (l.uncertainty !== void 0) return
|
|
908
|
-
return
|
|
913
|
+
if (l.uncertainty !== void 0) return chunkIT74O4BE_cjs.numberValueUncertain(scaled, Math.abs(l.uncertainty * factor));
|
|
914
|
+
return chunkIT74O4BE_cjs.numberValue(scaled);
|
|
909
915
|
}
|
|
910
|
-
if (l.type === 6 /* Uom */ && l.unit !== void 0) return
|
|
916
|
+
if (l.type === 6 /* Uom */ && l.unit !== void 0) return chunkFR7RNOPT_cjs.scaleMoneyByPercent(l, l.unit, r.toNumber(), sign);
|
|
911
917
|
return null;
|
|
912
918
|
}
|
|
913
919
|
function multiplyPercentWithUncertainty(l, r) {
|
|
@@ -916,26 +922,26 @@ function multiplyPercentWithUncertainty(l, r) {
|
|
|
916
922
|
const other = pct === l ? r : l;
|
|
917
923
|
if (other.type !== 0 /* Number */ || other.uncertainty === void 0) return null;
|
|
918
924
|
const factor = pct.toNumber();
|
|
919
|
-
return
|
|
925
|
+
return chunkIT74O4BE_cjs.numberValueUncertain(other.toNumber() * factor, Math.abs(other.uncertainty * factor));
|
|
920
926
|
}
|
|
921
927
|
function multiplyMoneyByScalarExact(l, r) {
|
|
922
928
|
const money = l.type === 6 /* Uom */ ? l : r;
|
|
923
929
|
const scalar = l.type === 6 /* Uom */ ? r : l;
|
|
924
|
-
if (money.type !== 6 /* Uom */ || money.unit === void 0 || !
|
|
930
|
+
if (money.type !== 6 /* Uom */ || money.unit === void 0 || !chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(money.unit)) return null;
|
|
925
931
|
if (scalar.type !== 0 /* Number */ && scalar.type !== 5 /* Percentage */) return null;
|
|
926
932
|
if (scalar.rational !== void 0) return null;
|
|
927
|
-
return
|
|
933
|
+
return chunkFR7RNOPT_cjs.scaleMoneyExact(money, scalar.toNumber(), money.unit);
|
|
928
934
|
}
|
|
929
935
|
function dividePercentWithUncertainty(l, r) {
|
|
930
936
|
if (r.type === 5 /* Percentage */ && l.type === 0 /* Number */ && l.uncertainty !== void 0) {
|
|
931
937
|
const factor = r.toNumber();
|
|
932
938
|
if (factor === 0) return null;
|
|
933
|
-
return
|
|
939
|
+
return chunkIT74O4BE_cjs.numberValueUncertain(l.toNumber() / factor, Math.abs(l.uncertainty / factor));
|
|
934
940
|
}
|
|
935
941
|
if (l.type === 5 /* Percentage */ && r.type === 0 /* Number */ && r.uncertainty !== void 0) {
|
|
936
942
|
const b = r.toNumber();
|
|
937
943
|
if (b === 0) return null;
|
|
938
|
-
return
|
|
944
|
+
return chunkIT74O4BE_cjs.numberValueUncertain(l.toNumber() / b, Math.abs(l.toNumber() * r.uncertainty / (b * b)));
|
|
939
945
|
}
|
|
940
946
|
return null;
|
|
941
947
|
}
|
|
@@ -959,7 +965,7 @@ function addBusinessDays2(epochMs, n, vm) {
|
|
|
959
965
|
const limitYears = direction > 0 ? vm.getMaxDateOffsetYears() : -vm.getMinDateOffsetYears();
|
|
960
966
|
const limitWorkdays = Math.floor(limitYears * WORKDAYS_PER_YEAR);
|
|
961
967
|
if (remaining > limitWorkdays) {
|
|
962
|
-
throw
|
|
968
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
963
969
|
"DATE_OFFSET_LIMIT_EXCEEDED",
|
|
964
970
|
`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`,
|
|
965
971
|
{ requestedWorkdays: remaining, limitYears, limitWorkdays }
|
|
@@ -968,7 +974,7 @@ function addBusinessDays2(epochMs, n, vm) {
|
|
|
968
974
|
const maxCalendarSteps = limitWorkdays * 7 + 7;
|
|
969
975
|
const landed = addBusinessDays(epochMs, n, (ms) => vm.isHoliday(ms), maxCalendarSteps);
|
|
970
976
|
if (landed === null) {
|
|
971
|
-
throw
|
|
977
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
972
978
|
"DATE_OFFSET_LIMIT_EXCEEDED",
|
|
973
979
|
`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
980
|
{ requestedWorkdays: remaining, limitYears, maxCalendarSteps }
|
|
@@ -1038,33 +1044,33 @@ function shiftDatetime(epochMs, duration, sign, vm) {
|
|
|
1038
1044
|
return epochMs + sign * extractDurationMs(duration);
|
|
1039
1045
|
}
|
|
1040
1046
|
function combineTimecode(tc, r, sign) {
|
|
1041
|
-
const fps =
|
|
1042
|
-
if (r.type === 6 /* Uom */ &&
|
|
1043
|
-
const rFps =
|
|
1047
|
+
const fps = chunkIT74O4BE_cjs.timecodeFps(tc.unit);
|
|
1048
|
+
if (r.type === 6 /* Uom */ && chunkIT74O4BE_cjs.isTimecodeUnit(r.unit)) {
|
|
1049
|
+
const rFps = chunkIT74O4BE_cjs.timecodeFps(r.unit);
|
|
1044
1050
|
if (rFps !== fps) {
|
|
1045
|
-
return
|
|
1051
|
+
return chunkIT74O4BE_cjs.errorValue(
|
|
1046
1052
|
"TIMECODE_FPS_MISMATCH",
|
|
1047
1053
|
`Cannot combine timecodes at different frame rates (${fps} fps vs ${rFps} fps)`
|
|
1048
1054
|
);
|
|
1049
1055
|
}
|
|
1050
|
-
return sign === 1 ?
|
|
1056
|
+
return sign === 1 ? chunkIT74O4BE_cjs.uomValue(tc.toNumber() + r.toNumber(), tc.unit) : chunkIT74O4BE_cjs.uomValue(tc.toNumber() - r.toNumber(), "frames");
|
|
1051
1057
|
}
|
|
1052
1058
|
if (r.type === 6 /* Uom */ && r.unit === "frames") {
|
|
1053
|
-
return
|
|
1059
|
+
return chunkIT74O4BE_cjs.uomValue(tc.toNumber() + sign * r.toNumber(), tc.unit);
|
|
1054
1060
|
}
|
|
1055
1061
|
if (r.type === 6 /* Uom */ && r.unit && chunkEJ3ILXX6_cjs.getMeasure(r.unit) === "time") {
|
|
1056
1062
|
const seconds = chunkEJ3ILXX6_cjs.convertUnit(r.toNumber(), r.unit, "s");
|
|
1057
|
-
return
|
|
1063
|
+
return chunkIT74O4BE_cjs.uomValue(tc.toNumber() + sign * seconds * fps, tc.unit);
|
|
1058
1064
|
}
|
|
1059
|
-
return
|
|
1065
|
+
return chunkIT74O4BE_cjs.uomValue(tc.toNumber() + sign * r.toNumber(), tc.unit);
|
|
1060
1066
|
}
|
|
1061
1067
|
function isTruthy(value) {
|
|
1062
1068
|
if (value.type === 10 /* Boolean */) return value.value;
|
|
1063
1069
|
return value.toNumber() !== 0;
|
|
1064
1070
|
}
|
|
1065
1071
|
function incompatibleConversionError(fromUnit, toUnit) {
|
|
1066
|
-
const named =
|
|
1067
|
-
return
|
|
1072
|
+
const named = chunkFR7RNOPT_cjs.describeConversionMismatch(fromUnit, toUnit);
|
|
1073
|
+
return chunkIT74O4BE_cjs.errorValue(
|
|
1068
1074
|
"INCOMPATIBLE_UNITS",
|
|
1069
1075
|
named ?? `Cannot convert ${fromUnit} to ${toUnit}: they do not measure the same thing`
|
|
1070
1076
|
);
|
|
@@ -1098,32 +1104,32 @@ function bigIntBitLength(value) {
|
|
|
1098
1104
|
return magnitude.toString(16).length * 4;
|
|
1099
1105
|
}
|
|
1100
1106
|
function bigIntShift(l, r, direction) {
|
|
1101
|
-
const value =
|
|
1102
|
-
const shift =
|
|
1103
|
-
if (value === 0n) return
|
|
1107
|
+
const value = chunkFR7RNOPT_cjs.toBigIntOperand(l);
|
|
1108
|
+
const shift = chunkFR7RNOPT_cjs.toBigIntOperand(r);
|
|
1109
|
+
if (value === 0n) return chunkIT74O4BE_cjs.bigIntValue(0n);
|
|
1104
1110
|
const grownBits = direction * Number(shift);
|
|
1105
1111
|
if (grownBits <= 0 || bigIntBitLength(value) + grownBits <= MAX_EXACT_SHIFT_BITS) {
|
|
1106
|
-
return
|
|
1112
|
+
return chunkIT74O4BE_cjs.bigIntValue(direction === 1 ? value << shift : value >> shift);
|
|
1107
1113
|
}
|
|
1108
|
-
throw
|
|
1114
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
1109
1115
|
"BIGINT_SHIFT_LIMIT_EXCEEDED",
|
|
1110
1116
|
`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`,
|
|
1111
1117
|
{ shift: String(shift), limitBits: MAX_EXACT_SHIFT_BITS }
|
|
1112
1118
|
);
|
|
1113
1119
|
}
|
|
1114
1120
|
function multiplyRateByMatchingUom(rate, multiplier) {
|
|
1115
|
-
const { numerator, denominator } =
|
|
1121
|
+
const { numerator, denominator } = chunkIT74O4BE_cjs.splitRateUnit(rate.unit);
|
|
1116
1122
|
const rateMeasure = chunkEJ3ILXX6_cjs.getMeasure(denominator);
|
|
1117
1123
|
const multiplierMeasure = chunkEJ3ILXX6_cjs.getMeasure(multiplier.unit);
|
|
1118
1124
|
if (!rateMeasure || rateMeasure !== multiplierMeasure) {
|
|
1119
|
-
return
|
|
1125
|
+
return chunkIT74O4BE_cjs.errorValue(
|
|
1120
1126
|
"RATE_MUL_MEASURE_MISMATCH",
|
|
1121
1127
|
`Cannot multiply a "${denominator}"-denominated rate by "${multiplier.unit}" \u2014 different measures`
|
|
1122
1128
|
);
|
|
1123
1129
|
}
|
|
1124
1130
|
const multiplierInDenominatorUnit = chunkEJ3ILXX6_cjs.convertUnit(multiplier.toNumber(), multiplier.unit, denominator);
|
|
1125
1131
|
const total = rate.toNumber() * multiplierInDenominatorUnit;
|
|
1126
|
-
return numerator ?
|
|
1132
|
+
return numerator ? chunkIT74O4BE_cjs.uomValue(total, numerator) : chunkIT74O4BE_cjs.numberValue(total);
|
|
1127
1133
|
}
|
|
1128
1134
|
function toFractionString(n) {
|
|
1129
1135
|
if (Number.isNaN(n)) return "NaN";
|
|
@@ -1172,7 +1178,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1172
1178
|
if (unrunnable) {
|
|
1173
1179
|
return {
|
|
1174
1180
|
type: "error",
|
|
1175
|
-
error:
|
|
1181
|
+
error: chunkMIGXCBXT_cjs.ErrorFactory.validation({
|
|
1176
1182
|
code: "MALFORMED_BYTECODE_PROGRAM",
|
|
1177
1183
|
message: `Malformed bytecode: ${unrunnable}`,
|
|
1178
1184
|
expected: "a BytecodeProgram with opcodes, numbers and strings",
|
|
@@ -1188,16 +1194,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1188
1194
|
const maxStackDepth = vm.getMaxStackDepth();
|
|
1189
1195
|
const stack = vm.getStack();
|
|
1190
1196
|
const shouldTrace = pipeline?.hasCollectors ?? false;
|
|
1191
|
-
const hasArena =
|
|
1192
|
-
if (opcodes.length === 0) return { type: "value", value:
|
|
1193
|
-
|
|
1197
|
+
const hasArena = chunkIT74O4BE_cjs.isArenaActive();
|
|
1198
|
+
if (opcodes.length === 0) return { type: "value", value: chunkIT74O4BE_cjs.numberValue(0) };
|
|
1199
|
+
chunkIT74O4BE_cjs.beginEvaluation(vm);
|
|
1194
1200
|
try {
|
|
1195
1201
|
while (ip < opcodes.length) {
|
|
1196
1202
|
if (++localInstructionCount > maxInstructions) {
|
|
1197
|
-
throw
|
|
1203
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution("INSTRUCTION_LIMIT_EXCEEDED", `Execution exceeded maximum of ${maxInstructions} instructions`);
|
|
1198
1204
|
}
|
|
1199
1205
|
if (stack.length > maxStackDepth) {
|
|
1200
|
-
throw
|
|
1206
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution("STACK_LIMIT_EXCEEDED", `Execution exceeded maximum stack depth of ${maxStackDepth}`);
|
|
1201
1207
|
}
|
|
1202
1208
|
const op = opcodes[ip++];
|
|
1203
1209
|
if (shouldTrace) {
|
|
@@ -1207,7 +1213,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1207
1213
|
unit: v.unit
|
|
1208
1214
|
}));
|
|
1209
1215
|
pipeline.fireVmStep({
|
|
1210
|
-
type:
|
|
1216
|
+
type: chunkHWHU642X_cjs.DiagnosticEventType.VmStep,
|
|
1211
1217
|
elapsedNs: 0,
|
|
1212
1218
|
expression: expression ?? "",
|
|
1213
1219
|
opcode: op,
|
|
@@ -1226,7 +1232,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1226
1232
|
break;
|
|
1227
1233
|
case 1 /* HALT */: {
|
|
1228
1234
|
const result = safePop(stack);
|
|
1229
|
-
return { type: "value", value: hasArena ?
|
|
1235
|
+
return { type: "value", value: hasArena ? chunkIT74O4BE_cjs.persistentValue(result) : result };
|
|
1230
1236
|
}
|
|
1231
1237
|
case 3 /* DUP */: {
|
|
1232
1238
|
const top = safePop(stack);
|
|
@@ -1249,24 +1255,24 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1249
1255
|
// `BigInt(undefined)`, and an undefined string sat on the stack until
|
|
1250
1256
|
// a unit or converter name was read off it.
|
|
1251
1257
|
case 10 /* PUSH_NUMBER */:
|
|
1252
|
-
stack.push(
|
|
1258
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(numbers[poolIndex(opcodes, ip++, op, "constant-pool index", numbers.length, "number-pool")]));
|
|
1253
1259
|
break;
|
|
1254
1260
|
case 11 /* PUSH_BIGINT */:
|
|
1255
|
-
stack.push(
|
|
1261
|
+
stack.push(chunkIT74O4BE_cjs.bigIntValue(parseBigIntLiteral(poolString(opcodes, ip++, strings, op, "constant-pool index"), op)));
|
|
1256
1262
|
break;
|
|
1257
1263
|
case 16 /* PUSH_DECIMAL */: {
|
|
1258
|
-
const dec =
|
|
1259
|
-
stack.push(
|
|
1264
|
+
const dec = chunkA2DZ5BEJ_cjs.decimalFromLiteral(poolString(opcodes, ip++, strings, op, "constant-pool index"));
|
|
1265
|
+
stack.push(chunkIT74O4BE_cjs.numberValueExact(chunkA2DZ5BEJ_cjs.decimalToNumber(dec), dec));
|
|
1260
1266
|
break;
|
|
1261
1267
|
}
|
|
1262
1268
|
case 12 /* PUSH_HEX */:
|
|
1263
|
-
stack.push(
|
|
1269
|
+
stack.push(chunkIT74O4BE_cjs.hexValue(numbers[poolIndex(opcodes, ip++, op, "constant-pool index", numbers.length, "number-pool")]));
|
|
1264
1270
|
break;
|
|
1265
1271
|
case 13 /* PUSH_STRING */:
|
|
1266
|
-
stack.push(
|
|
1272
|
+
stack.push(chunkIT74O4BE_cjs.stringValue(poolString(opcodes, ip++, strings, op, "constant-pool index")));
|
|
1267
1273
|
break;
|
|
1268
1274
|
case 14 /* PUSH_BOOLEAN */:
|
|
1269
|
-
stack.push(
|
|
1275
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(operandByte(opcodes, ip++, op, "boolean operand") === 1));
|
|
1270
1276
|
break;
|
|
1271
1277
|
// ═══════════════════════════════════════════════════════════════
|
|
1272
1278
|
// §3 Arithmetic (OpCode 20–27)
|
|
@@ -1275,20 +1281,20 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1275
1281
|
// ═══════════════════════════════════════════════════════════════
|
|
1276
1282
|
case 20 /* ADD */: {
|
|
1277
1283
|
const r = safePop(stack), l = safePop(stack);
|
|
1278
|
-
const addFault =
|
|
1284
|
+
const addFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1279
1285
|
if (addFault) {
|
|
1280
1286
|
stack.push(addFault);
|
|
1281
1287
|
break;
|
|
1282
1288
|
}
|
|
1283
1289
|
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1284
|
-
const uncAdd =
|
|
1290
|
+
const uncAdd = chunkFR7RNOPT_cjs.uncertainOp(l, r, "add");
|
|
1285
1291
|
if (uncAdd) {
|
|
1286
1292
|
stack.push(uncAdd);
|
|
1287
1293
|
break;
|
|
1288
1294
|
}
|
|
1289
1295
|
}
|
|
1290
1296
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1291
|
-
const ratAdd =
|
|
1297
|
+
const ratAdd = chunkFR7RNOPT_cjs.exactRationalOp(l, r, "add");
|
|
1292
1298
|
if (ratAdd) {
|
|
1293
1299
|
stack.push(ratAdd);
|
|
1294
1300
|
break;
|
|
@@ -1299,42 +1305,42 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1299
1305
|
if (pctAdd !== null) {
|
|
1300
1306
|
stack.push(pctAdd);
|
|
1301
1307
|
} else if (ratePeriodAdd !== null) {
|
|
1302
|
-
stack.push(
|
|
1308
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(ratePeriodAdd + r.toNumber(), r.unit));
|
|
1303
1309
|
} else if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1304
|
-
stack.push(
|
|
1310
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.value + r.value));
|
|
1305
1311
|
} else if (l.type === 10 /* Boolean */ && r.type === 10 /* Boolean */) {
|
|
1306
|
-
stack.push(
|
|
1312
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value && r.value));
|
|
1307
1313
|
} else if (l.type === 4 /* Datetime */) {
|
|
1308
1314
|
if (r.type === 4 /* Datetime */) {
|
|
1309
|
-
stack.push(
|
|
1315
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("INVALID_DATETIME_OP", "Cannot add two datetimes together"));
|
|
1310
1316
|
} else {
|
|
1311
|
-
stack.push(
|
|
1317
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(shiftDatetime(l.toNumber(), r, 1, vm)));
|
|
1312
1318
|
}
|
|
1313
|
-
} else if (l.type === 6 /* Uom */ &&
|
|
1319
|
+
} else if (l.type === 6 /* Uom */ && chunkIT74O4BE_cjs.isTimecodeUnit(l.unit)) {
|
|
1314
1320
|
stack.push(combineTimecode(l, r, 1));
|
|
1315
1321
|
} else if (r.type === 4 /* Datetime */) {
|
|
1316
|
-
stack.push(
|
|
1322
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(shiftDatetime(r.toNumber(), l, 1, vm)));
|
|
1317
1323
|
} else {
|
|
1318
|
-
stack.push(
|
|
1324
|
+
stack.push(chunkFR7RNOPT_cjs.binaryOp(l, r, (a, b) => a + b, (a, b) => a + b, "add"));
|
|
1319
1325
|
}
|
|
1320
1326
|
break;
|
|
1321
1327
|
}
|
|
1322
1328
|
case 21 /* SUB */: {
|
|
1323
1329
|
const r = safePop(stack), l = safePop(stack);
|
|
1324
|
-
const subFault =
|
|
1330
|
+
const subFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1325
1331
|
if (subFault) {
|
|
1326
1332
|
stack.push(subFault);
|
|
1327
1333
|
break;
|
|
1328
1334
|
}
|
|
1329
1335
|
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1330
|
-
const uncSub =
|
|
1336
|
+
const uncSub = chunkFR7RNOPT_cjs.uncertainOp(l, r, "sub");
|
|
1331
1337
|
if (uncSub) {
|
|
1332
1338
|
stack.push(uncSub);
|
|
1333
1339
|
break;
|
|
1334
1340
|
}
|
|
1335
1341
|
}
|
|
1336
1342
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1337
|
-
const ratSub =
|
|
1343
|
+
const ratSub = chunkFR7RNOPT_cjs.exactRationalOp(l, r, "sub");
|
|
1338
1344
|
if (ratSub) {
|
|
1339
1345
|
stack.push(ratSub);
|
|
1340
1346
|
break;
|
|
@@ -1345,24 +1351,24 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1345
1351
|
if (pctSub !== null) {
|
|
1346
1352
|
stack.push(pctSub);
|
|
1347
1353
|
} else if (ratePeriodSub !== null) {
|
|
1348
|
-
stack.push(
|
|
1354
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(ratePeriodSub - r.toNumber(), r.unit));
|
|
1349
1355
|
} else if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1350
|
-
stack.push(
|
|
1356
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.value - r.value));
|
|
1351
1357
|
} else if (l.type === 4 /* Datetime */) {
|
|
1352
1358
|
if (r.type === 4 /* Datetime */) {
|
|
1353
|
-
stack.push(
|
|
1359
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(l.toNumber() - r.toNumber(), "ms"));
|
|
1354
1360
|
} else {
|
|
1355
|
-
stack.push(
|
|
1361
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(shiftDatetime(l.toNumber(), r, -1, vm)));
|
|
1356
1362
|
}
|
|
1357
|
-
} else if (l.type === 6 /* Uom */ &&
|
|
1363
|
+
} else if (l.type === 6 /* Uom */ && chunkIT74O4BE_cjs.isTimecodeUnit(l.unit)) {
|
|
1358
1364
|
stack.push(combineTimecode(l, r, -1));
|
|
1359
1365
|
} else if (r.type === 4 /* Datetime */) {
|
|
1360
|
-
stack.push(
|
|
1366
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
1361
1367
|
"INVALID_DATETIME_OP",
|
|
1362
1368
|
"Cannot subtract a datetime from a value that is not a datetime"
|
|
1363
1369
|
));
|
|
1364
1370
|
} else {
|
|
1365
|
-
stack.push(
|
|
1371
|
+
stack.push(chunkFR7RNOPT_cjs.binaryOp(l, r, (a, b) => a - b, (a, b) => a - b, "sub"));
|
|
1366
1372
|
}
|
|
1367
1373
|
break;
|
|
1368
1374
|
}
|
|
@@ -1374,14 +1380,14 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1374
1380
|
break;
|
|
1375
1381
|
}
|
|
1376
1382
|
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1377
|
-
const uncMul =
|
|
1383
|
+
const uncMul = chunkFR7RNOPT_cjs.uncertainOp(l, r, "mul");
|
|
1378
1384
|
if (uncMul) {
|
|
1379
1385
|
stack.push(uncMul);
|
|
1380
1386
|
break;
|
|
1381
1387
|
}
|
|
1382
1388
|
}
|
|
1383
1389
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1384
|
-
const ratMul =
|
|
1390
|
+
const ratMul = chunkFR7RNOPT_cjs.exactRationalOp(l, r, "mul");
|
|
1385
1391
|
if (ratMul) {
|
|
1386
1392
|
stack.push(ratMul);
|
|
1387
1393
|
break;
|
|
@@ -1393,18 +1399,18 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1393
1399
|
break;
|
|
1394
1400
|
}
|
|
1395
1401
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1396
|
-
stack.push(
|
|
1402
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.value * r.value));
|
|
1397
1403
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1398
|
-
|
|
1399
|
-
stack.push(
|
|
1400
|
-
} else if (l.type === 6 /* Uom */ &&
|
|
1404
|
+
chunkIT74O4BE_cjs.checkAllocation(matrixProductCells(l.value, r.value), "matrix cells");
|
|
1405
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixMultiply(l.value, r.value));
|
|
1406
|
+
} else if (l.type === 6 /* Uom */ && chunkIT74O4BE_cjs.isRateUnit(l.unit) && r.type === 6 /* Uom */ && r.unit) {
|
|
1401
1407
|
stack.push(multiplyRateByMatchingUom(l, r));
|
|
1402
|
-
} else if (r.type === 6 /* Uom */ &&
|
|
1408
|
+
} else if (r.type === 6 /* Uom */ && chunkIT74O4BE_cjs.isRateUnit(r.unit) && l.type === 6 /* Uom */ && l.unit) {
|
|
1403
1409
|
stack.push(multiplyRateByMatchingUom(r, l));
|
|
1404
1410
|
} else if (moneyTimesQuantity(l, r) !== null) {
|
|
1405
1411
|
stack.push(moneyTimesQuantity(l, r));
|
|
1406
1412
|
} else {
|
|
1407
|
-
stack.push(
|
|
1413
|
+
stack.push(chunkFR7RNOPT_cjs.binaryOp(l, r, (a, b) => a * b, (a, b) => a * b, "mul"));
|
|
1408
1414
|
}
|
|
1409
1415
|
break;
|
|
1410
1416
|
}
|
|
@@ -1416,29 +1422,29 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1416
1422
|
break;
|
|
1417
1423
|
}
|
|
1418
1424
|
if (l.uncertainty !== void 0 || r.uncertainty !== void 0) {
|
|
1419
|
-
const uncDiv =
|
|
1425
|
+
const uncDiv = chunkFR7RNOPT_cjs.uncertainOp(l, r, "div");
|
|
1420
1426
|
if (uncDiv) {
|
|
1421
1427
|
stack.push(uncDiv);
|
|
1422
1428
|
break;
|
|
1423
1429
|
}
|
|
1424
1430
|
}
|
|
1425
1431
|
if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1426
|
-
const { lv, rv, sameMeasure } =
|
|
1432
|
+
const { lv, rv, sameMeasure } = chunkFR7RNOPT_cjs.unifyUom(l, r);
|
|
1427
1433
|
if (sameMeasure) {
|
|
1428
|
-
stack.push(
|
|
1429
|
-
} else if (
|
|
1430
|
-
stack.push(
|
|
1434
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(lv / rv));
|
|
1435
|
+
} else if (chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(l.unit) && chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(r.unit)) {
|
|
1436
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("INCOMPATIBLE_UNITS", `Cannot combine incompatible units: ${l.unit} and ${r.unit}`));
|
|
1431
1437
|
} else {
|
|
1432
|
-
stack.push(
|
|
1438
|
+
stack.push(chunkIT74O4BE_cjs.rateValue(lv / rv, l.unit, r.unit));
|
|
1433
1439
|
}
|
|
1434
1440
|
} else {
|
|
1435
|
-
const ratDiv =
|
|
1441
|
+
const ratDiv = chunkFR7RNOPT_cjs.exactRationalOp(l, r, "div");
|
|
1436
1442
|
if (ratDiv) {
|
|
1437
1443
|
stack.push(ratDiv);
|
|
1438
1444
|
break;
|
|
1439
1445
|
}
|
|
1440
|
-
stack.push(
|
|
1441
|
-
if (b === 0n) throw
|
|
1446
|
+
stack.push(chunkFR7RNOPT_cjs.binaryOp(l, r, (a, b) => a / b, (a, b) => {
|
|
1447
|
+
if (b === 0n) throw chunkFR7RNOPT_cjs.bigIntDivisionByZero();
|
|
1442
1448
|
return a / b;
|
|
1443
1449
|
}, "div"));
|
|
1444
1450
|
}
|
|
@@ -1446,8 +1452,8 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1446
1452
|
}
|
|
1447
1453
|
case 24 /* MOD */: {
|
|
1448
1454
|
const r = safePop(stack), l = safePop(stack);
|
|
1449
|
-
stack.push(
|
|
1450
|
-
if (b === 0n) throw
|
|
1455
|
+
stack.push(chunkFR7RNOPT_cjs.binaryOp(l, r, (a, b) => a % b, (a, b) => {
|
|
1456
|
+
if (b === 0n) throw chunkFR7RNOPT_cjs.bigIntDivisionByZero();
|
|
1451
1457
|
return a % b;
|
|
1452
1458
|
}));
|
|
1453
1459
|
break;
|
|
@@ -1471,82 +1477,82 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1471
1477
|
break;
|
|
1472
1478
|
}
|
|
1473
1479
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1474
|
-
stack.push(
|
|
1480
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(chunkFR7RNOPT_cjs.power(l.value, r.value)));
|
|
1475
1481
|
break;
|
|
1476
1482
|
}
|
|
1477
1483
|
if (l.type === 7 /* Matrix */ || r.type === 7 /* Matrix */) {
|
|
1478
1484
|
if (l.type !== 7 /* Matrix */ || r.type !== 0 /* Number */) {
|
|
1479
|
-
stack.push(
|
|
1485
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
1480
1486
|
"MATRIX_POWER_UNSUPPORTED",
|
|
1481
|
-
`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${
|
|
1487
|
+
`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${chunkIT74O4BE_cjs.ValueType[l.type]} ^ ${chunkIT74O4BE_cjs.ValueType[r.type]}" has no matrix reading.`
|
|
1482
1488
|
));
|
|
1483
1489
|
break;
|
|
1484
1490
|
}
|
|
1485
|
-
|
|
1486
|
-
stack.push(
|
|
1491
|
+
chunkIT74O4BE_cjs.checkAllocation(matrixPowerCells(l.value, r.value), "matrix cells");
|
|
1492
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixPower(l.value, r.value));
|
|
1487
1493
|
break;
|
|
1488
1494
|
}
|
|
1489
1495
|
if (l.type === 9 /* Symbolic */ || r.type === 9 /* Symbolic */) {
|
|
1490
|
-
stack.push(
|
|
1496
|
+
stack.push(chunkFR7RNOPT_cjs.symbolicPow(l, r));
|
|
1491
1497
|
break;
|
|
1492
1498
|
}
|
|
1493
1499
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1494
1500
|
const powBits = exactPowBits(l, r.toNumber());
|
|
1495
1501
|
if (powBits !== null) {
|
|
1496
1502
|
if (powBits > MAX_EXACT_POW_BITS) {
|
|
1497
|
-
throw
|
|
1503
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
1498
1504
|
"BIGINT_POW_LIMIT_EXCEEDED",
|
|
1499
1505
|
`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`,
|
|
1500
1506
|
{ limitBits: MAX_EXACT_POW_BITS }
|
|
1501
1507
|
);
|
|
1502
1508
|
}
|
|
1503
|
-
stack.push(
|
|
1509
|
+
stack.push(chunkIT74O4BE_cjs.bigIntValue(bigIntPow(chunkFR7RNOPT_cjs.toBigIntOperand(l), chunkFR7RNOPT_cjs.toBigIntOperand(r))));
|
|
1504
1510
|
break;
|
|
1505
1511
|
}
|
|
1506
1512
|
}
|
|
1507
|
-
stack.push(
|
|
1513
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(chunkFR7RNOPT_cjs.power(l.toNumber(), r.toNumber())));
|
|
1508
1514
|
break;
|
|
1509
1515
|
}
|
|
1510
1516
|
case 26 /* NEG */: {
|
|
1511
1517
|
const v = safePop(stack);
|
|
1512
|
-
const negFault =
|
|
1518
|
+
const negFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
1513
1519
|
if (negFault) {
|
|
1514
1520
|
stack.push(negFault);
|
|
1515
1521
|
break;
|
|
1516
1522
|
}
|
|
1517
|
-
if (v.type === 2 /* BigInt */) stack.push(
|
|
1518
|
-
else if (v.type === 6 /* Uom */ && v.exact !== void 0) stack.push(
|
|
1519
|
-
else if (v.type === 6 /* Uom */) stack.push(
|
|
1520
|
-
else if (v.type === 5 /* Percentage */) stack.push(
|
|
1521
|
-
else if (v.type === 9 /* Symbolic */) stack.push(
|
|
1522
|
-
else if (v.type === 0 /* Number */ && v.rational !== void 0) stack.push(
|
|
1523
|
-
else if (v.type === 0 /* Number */ && v.exact !== void 0) stack.push(
|
|
1524
|
-
else stack.push(
|
|
1523
|
+
if (v.type === 2 /* BigInt */) stack.push(chunkIT74O4BE_cjs.bigIntValue(-v.value));
|
|
1524
|
+
else if (v.type === 6 /* Uom */ && v.exact !== void 0) stack.push(chunkIT74O4BE_cjs.uomValueExact(-v.toNumber(), v.unit, chunkA2DZ5BEJ_cjs.decimalNegate(v.exact)));
|
|
1525
|
+
else if (v.type === 6 /* Uom */) stack.push(chunkIT74O4BE_cjs.uomValue(-v.toNumber(), v.unit));
|
|
1526
|
+
else if (v.type === 5 /* Percentage */) stack.push(chunkIT74O4BE_cjs.percentageValue(-v.toNumber()));
|
|
1527
|
+
else if (v.type === 9 /* Symbolic */) stack.push(chunkFR7RNOPT_cjs.symbolicNeg(v));
|
|
1528
|
+
else if (v.type === 0 /* Number */ && v.rational !== void 0) stack.push(chunkIT74O4BE_cjs.numberValueRational(-v.toNumber(), chunkA2DZ5BEJ_cjs.rationalNeg(v.rational)));
|
|
1529
|
+
else if (v.type === 0 /* Number */ && v.exact !== void 0) stack.push(chunkIT74O4BE_cjs.numberValueExact(-v.toNumber(), chunkA2DZ5BEJ_cjs.decimalNegate(v.exact)));
|
|
1530
|
+
else stack.push(chunkIT74O4BE_cjs.numberValue(-v.toNumber()));
|
|
1525
1531
|
break;
|
|
1526
1532
|
}
|
|
1527
1533
|
case 27 /* POS */: {
|
|
1528
1534
|
const v = safePop(stack);
|
|
1529
|
-
const posFault =
|
|
1535
|
+
const posFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
1530
1536
|
if (posFault) {
|
|
1531
1537
|
stack.push(posFault);
|
|
1532
1538
|
break;
|
|
1533
1539
|
}
|
|
1534
|
-
if (v.type === 6 /* Uom */ && v.exact !== void 0) stack.push(
|
|
1535
|
-
else if (v.type === 6 /* Uom */) stack.push(
|
|
1536
|
-
else if (v.type === 5 /* Percentage */) stack.push(
|
|
1537
|
-
else if (v.type === 0 /* Number */ && v.rational !== void 0) stack.push(
|
|
1538
|
-
else if (v.type === 0 /* Number */ && v.exact !== void 0) stack.push(
|
|
1539
|
-
else stack.push(
|
|
1540
|
+
if (v.type === 6 /* Uom */ && v.exact !== void 0) stack.push(chunkIT74O4BE_cjs.uomValueExact(v.toNumber(), v.unit, v.exact));
|
|
1541
|
+
else if (v.type === 6 /* Uom */) stack.push(chunkIT74O4BE_cjs.uomValue(v.toNumber(), v.unit));
|
|
1542
|
+
else if (v.type === 5 /* Percentage */) stack.push(chunkIT74O4BE_cjs.percentageValue(v.toNumber()));
|
|
1543
|
+
else if (v.type === 0 /* Number */ && v.rational !== void 0) stack.push(chunkIT74O4BE_cjs.numberValueRational(v.toNumber(), v.rational));
|
|
1544
|
+
else if (v.type === 0 /* Number */ && v.exact !== void 0) stack.push(chunkIT74O4BE_cjs.numberValueExact(v.toNumber(), v.exact));
|
|
1545
|
+
else stack.push(chunkIT74O4BE_cjs.numberValue(v.toNumber()));
|
|
1540
1546
|
break;
|
|
1541
1547
|
}
|
|
1542
1548
|
case 28 /* MAKE_UNCERTAIN */: {
|
|
1543
1549
|
const spread = safePop(stack), center = safePop(stack);
|
|
1544
|
-
const uncFault =
|
|
1550
|
+
const uncFault = chunkIT74O4BE_cjs.faultedOperand(center, spread);
|
|
1545
1551
|
if (uncFault) {
|
|
1546
1552
|
stack.push(uncFault);
|
|
1547
1553
|
break;
|
|
1548
1554
|
}
|
|
1549
|
-
stack.push(
|
|
1555
|
+
stack.push(chunkIT74O4BE_cjs.numberValueUncertain(center.toNumber(), Math.abs(spread.toNumber())));
|
|
1550
1556
|
break;
|
|
1551
1557
|
}
|
|
1552
1558
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -1559,7 +1565,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1559
1565
|
// ═══════════════════════════════════════════════════════════════
|
|
1560
1566
|
case 30 /* LSHIFT */: {
|
|
1561
1567
|
const r = safePop(stack), l = safePop(stack);
|
|
1562
|
-
const shiftFault =
|
|
1568
|
+
const shiftFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1563
1569
|
if (shiftFault) {
|
|
1564
1570
|
stack.push(shiftFault);
|
|
1565
1571
|
break;
|
|
@@ -1567,13 +1573,13 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1567
1573
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1568
1574
|
stack.push(bigIntShift(l, r, 1));
|
|
1569
1575
|
} else {
|
|
1570
|
-
stack.push(
|
|
1576
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.toNumber() << r.toNumber()));
|
|
1571
1577
|
}
|
|
1572
1578
|
break;
|
|
1573
1579
|
}
|
|
1574
1580
|
case 31 /* RSHIFT */: {
|
|
1575
1581
|
const r = safePop(stack), l = safePop(stack);
|
|
1576
|
-
const rshiftFault =
|
|
1582
|
+
const rshiftFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1577
1583
|
if (rshiftFault) {
|
|
1578
1584
|
stack.push(rshiftFault);
|
|
1579
1585
|
break;
|
|
@@ -1581,71 +1587,71 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1581
1587
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1582
1588
|
stack.push(bigIntShift(l, r, -1));
|
|
1583
1589
|
} else {
|
|
1584
|
-
stack.push(
|
|
1590
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.toNumber() >> r.toNumber()));
|
|
1585
1591
|
}
|
|
1586
1592
|
break;
|
|
1587
1593
|
}
|
|
1588
1594
|
case 32 /* URSHIFT */: {
|
|
1589
1595
|
const r = safePop(stack), l = safePop(stack);
|
|
1590
|
-
const urshiftFault =
|
|
1596
|
+
const urshiftFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1591
1597
|
if (urshiftFault) {
|
|
1592
1598
|
stack.push(urshiftFault);
|
|
1593
1599
|
break;
|
|
1594
1600
|
}
|
|
1595
|
-
stack.push(
|
|
1601
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.toNumber() >>> r.toNumber()));
|
|
1596
1602
|
break;
|
|
1597
1603
|
}
|
|
1598
1604
|
case 33 /* BIT_AND */: {
|
|
1599
1605
|
const r = safePop(stack), l = safePop(stack);
|
|
1600
|
-
const andFault =
|
|
1606
|
+
const andFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1601
1607
|
if (andFault) {
|
|
1602
1608
|
stack.push(andFault);
|
|
1603
1609
|
break;
|
|
1604
1610
|
}
|
|
1605
1611
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1606
|
-
stack.push(
|
|
1612
|
+
stack.push(chunkIT74O4BE_cjs.bigIntValue(chunkFR7RNOPT_cjs.toBigIntOperand(l) & chunkFR7RNOPT_cjs.toBigIntOperand(r)));
|
|
1607
1613
|
} else {
|
|
1608
|
-
stack.push(
|
|
1614
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.toNumber() & r.toNumber()));
|
|
1609
1615
|
}
|
|
1610
1616
|
break;
|
|
1611
1617
|
}
|
|
1612
1618
|
case 34 /* BIT_OR */: {
|
|
1613
1619
|
const r = safePop(stack), l = safePop(stack);
|
|
1614
|
-
const orFault =
|
|
1620
|
+
const orFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1615
1621
|
if (orFault) {
|
|
1616
1622
|
stack.push(orFault);
|
|
1617
1623
|
break;
|
|
1618
1624
|
}
|
|
1619
1625
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1620
|
-
stack.push(
|
|
1626
|
+
stack.push(chunkIT74O4BE_cjs.bigIntValue(chunkFR7RNOPT_cjs.toBigIntOperand(l) | chunkFR7RNOPT_cjs.toBigIntOperand(r)));
|
|
1621
1627
|
} else {
|
|
1622
|
-
stack.push(
|
|
1628
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.toNumber() | r.toNumber()));
|
|
1623
1629
|
}
|
|
1624
1630
|
break;
|
|
1625
1631
|
}
|
|
1626
1632
|
case 35 /* BIT_XOR */: {
|
|
1627
1633
|
const r = safePop(stack), l = safePop(stack);
|
|
1628
|
-
const xorFault =
|
|
1634
|
+
const xorFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1629
1635
|
if (xorFault) {
|
|
1630
1636
|
stack.push(xorFault);
|
|
1631
1637
|
break;
|
|
1632
1638
|
}
|
|
1633
1639
|
if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1634
|
-
stack.push(
|
|
1640
|
+
stack.push(chunkIT74O4BE_cjs.bigIntValue(chunkFR7RNOPT_cjs.toBigIntOperand(l) ^ chunkFR7RNOPT_cjs.toBigIntOperand(r)));
|
|
1635
1641
|
} else {
|
|
1636
|
-
stack.push(
|
|
1642
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(l.toNumber() ^ r.toNumber()));
|
|
1637
1643
|
}
|
|
1638
1644
|
break;
|
|
1639
1645
|
}
|
|
1640
1646
|
case 36 /* BIT_NOT */: {
|
|
1641
1647
|
const v = safePop(stack);
|
|
1642
|
-
const notFault =
|
|
1648
|
+
const notFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
1643
1649
|
if (notFault) {
|
|
1644
1650
|
stack.push(notFault);
|
|
1645
1651
|
break;
|
|
1646
1652
|
}
|
|
1647
|
-
if (v.type === 2 /* BigInt */) stack.push(
|
|
1648
|
-
else stack.push(
|
|
1653
|
+
if (v.type === 2 /* BigInt */) stack.push(chunkIT74O4BE_cjs.bigIntValue(~v.value));
|
|
1654
|
+
else stack.push(chunkIT74O4BE_cjs.numberValue(~v.toNumber()));
|
|
1649
1655
|
break;
|
|
1650
1656
|
}
|
|
1651
1657
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -1676,193 +1682,193 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1676
1682
|
// ═══════════════════════════════════════════════════════════════
|
|
1677
1683
|
case 40 /* EQ */: {
|
|
1678
1684
|
const r = safePop(stack), l = safePop(stack);
|
|
1679
|
-
const eqFault =
|
|
1685
|
+
const eqFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1680
1686
|
if (eqFault) {
|
|
1681
1687
|
stack.push(eqFault);
|
|
1682
1688
|
break;
|
|
1683
1689
|
}
|
|
1684
1690
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1685
|
-
const cmp =
|
|
1691
|
+
const cmp = chunkFR7RNOPT_cjs.compareRationalOperands(l, r);
|
|
1686
1692
|
if (cmp !== null) {
|
|
1687
|
-
stack.push(
|
|
1693
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === 0));
|
|
1688
1694
|
break;
|
|
1689
1695
|
}
|
|
1690
1696
|
}
|
|
1691
1697
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1692
|
-
stack.push(
|
|
1698
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value === r.value));
|
|
1693
1699
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1694
|
-
const cmp =
|
|
1695
|
-
stack.push(
|
|
1700
|
+
const cmp = chunkFR7RNOPT_cjs.compareBigIntOperands(l, r);
|
|
1701
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === null ? l.toNumber() === r.toNumber() : cmp === 0));
|
|
1696
1702
|
} else if (l.type === 3 /* String */ && r.type === 3 /* String */) {
|
|
1697
|
-
stack.push(
|
|
1703
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value === r.value));
|
|
1698
1704
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1699
|
-
const { equal, sameMeasure } =
|
|
1700
|
-
stack.push(
|
|
1705
|
+
const { equal, sameMeasure } = chunkFR7RNOPT_cjs.compareUom(l, r);
|
|
1706
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(sameMeasure && equal));
|
|
1701
1707
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1702
|
-
stack.push(
|
|
1708
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixCompare(l.value, r.value, (a, b) => a === b));
|
|
1703
1709
|
} else if (l.type === 14 /* Colour */ || r.type === 14 /* Colour */) {
|
|
1704
1710
|
if (l.type === 14 /* Colour */ && r.type === 14 /* Colour */) {
|
|
1705
1711
|
const a = l.value, b = r.value;
|
|
1706
|
-
stack.push(
|
|
1712
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a));
|
|
1707
1713
|
} else {
|
|
1708
|
-
stack.push(
|
|
1714
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(false));
|
|
1709
1715
|
}
|
|
1710
1716
|
} else {
|
|
1711
|
-
stack.push(
|
|
1717
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.toNumber() === r.toNumber()));
|
|
1712
1718
|
}
|
|
1713
1719
|
break;
|
|
1714
1720
|
}
|
|
1715
1721
|
case 41 /* NEQ */: {
|
|
1716
1722
|
const r = safePop(stack), l = safePop(stack);
|
|
1717
|
-
const neqFault =
|
|
1723
|
+
const neqFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1718
1724
|
if (neqFault) {
|
|
1719
1725
|
stack.push(neqFault);
|
|
1720
1726
|
break;
|
|
1721
1727
|
}
|
|
1722
1728
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1723
|
-
const cmp =
|
|
1729
|
+
const cmp = chunkFR7RNOPT_cjs.compareRationalOperands(l, r);
|
|
1724
1730
|
if (cmp !== null) {
|
|
1725
|
-
stack.push(
|
|
1731
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp !== 0));
|
|
1726
1732
|
break;
|
|
1727
1733
|
}
|
|
1728
1734
|
}
|
|
1729
1735
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1730
|
-
stack.push(
|
|
1736
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value !== r.value));
|
|
1731
1737
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1732
|
-
const cmp =
|
|
1733
|
-
stack.push(
|
|
1738
|
+
const cmp = chunkFR7RNOPT_cjs.compareBigIntOperands(l, r);
|
|
1739
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === null ? l.toNumber() !== r.toNumber() : cmp !== 0));
|
|
1734
1740
|
} else if (l.type === 3 /* String */ && r.type === 3 /* String */) {
|
|
1735
|
-
stack.push(
|
|
1741
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value !== r.value));
|
|
1736
1742
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1737
|
-
const { equal, sameMeasure } =
|
|
1738
|
-
stack.push(
|
|
1743
|
+
const { equal, sameMeasure } = chunkFR7RNOPT_cjs.compareUom(l, r);
|
|
1744
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(!sameMeasure || !equal));
|
|
1739
1745
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1740
|
-
stack.push(
|
|
1746
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixCompare(l.value, r.value, (a, b) => a !== b));
|
|
1741
1747
|
} else if (l.type === 14 /* Colour */ || r.type === 14 /* Colour */) {
|
|
1742
1748
|
if (l.type === 14 /* Colour */ && r.type === 14 /* Colour */) {
|
|
1743
1749
|
const a = l.value, b = r.value;
|
|
1744
|
-
stack.push(
|
|
1750
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(!(a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a)));
|
|
1745
1751
|
} else {
|
|
1746
|
-
stack.push(
|
|
1752
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(true));
|
|
1747
1753
|
}
|
|
1748
1754
|
} else {
|
|
1749
|
-
stack.push(
|
|
1755
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.toNumber() !== r.toNumber()));
|
|
1750
1756
|
}
|
|
1751
1757
|
break;
|
|
1752
1758
|
}
|
|
1753
1759
|
case 42 /* LT */: {
|
|
1754
1760
|
const r = safePop(stack), l = safePop(stack);
|
|
1755
|
-
const ltFault =
|
|
1761
|
+
const ltFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1756
1762
|
if (ltFault) {
|
|
1757
1763
|
stack.push(ltFault);
|
|
1758
1764
|
break;
|
|
1759
1765
|
}
|
|
1760
1766
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1761
|
-
const cmp =
|
|
1767
|
+
const cmp = chunkFR7RNOPT_cjs.compareRationalOperands(l, r);
|
|
1762
1768
|
if (cmp !== null) {
|
|
1763
|
-
stack.push(
|
|
1769
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp < 0));
|
|
1764
1770
|
break;
|
|
1765
1771
|
}
|
|
1766
1772
|
}
|
|
1767
1773
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1768
|
-
stack.push(
|
|
1774
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value < r.value));
|
|
1769
1775
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1770
|
-
const cmp =
|
|
1771
|
-
stack.push(
|
|
1776
|
+
const cmp = chunkFR7RNOPT_cjs.compareBigIntOperands(l, r);
|
|
1777
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === null ? l.toNumber() < r.toNumber() : cmp < 0));
|
|
1772
1778
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1773
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1774
|
-
stack.push(sameMeasure ?
|
|
1779
|
+
const { lv, rv, equal, sameMeasure } = chunkFR7RNOPT_cjs.compareUom(l, r);
|
|
1780
|
+
stack.push(sameMeasure ? chunkIT74O4BE_cjs.boolValue(!equal && lv < rv) : chunkFR7RNOPT_cjs.incomparableUnitsError(l, r));
|
|
1775
1781
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1776
|
-
stack.push(
|
|
1782
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixCompare(l.value, r.value, (a, b) => a < b));
|
|
1777
1783
|
} else {
|
|
1778
|
-
stack.push(
|
|
1784
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.toNumber() < r.toNumber()));
|
|
1779
1785
|
}
|
|
1780
1786
|
break;
|
|
1781
1787
|
}
|
|
1782
1788
|
case 43 /* LTE */: {
|
|
1783
1789
|
const r = safePop(stack), l = safePop(stack);
|
|
1784
|
-
const lteFault =
|
|
1790
|
+
const lteFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1785
1791
|
if (lteFault) {
|
|
1786
1792
|
stack.push(lteFault);
|
|
1787
1793
|
break;
|
|
1788
1794
|
}
|
|
1789
1795
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1790
|
-
const cmp =
|
|
1796
|
+
const cmp = chunkFR7RNOPT_cjs.compareRationalOperands(l, r);
|
|
1791
1797
|
if (cmp !== null) {
|
|
1792
|
-
stack.push(
|
|
1798
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp <= 0));
|
|
1793
1799
|
break;
|
|
1794
1800
|
}
|
|
1795
1801
|
}
|
|
1796
1802
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1797
|
-
stack.push(
|
|
1803
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value <= r.value));
|
|
1798
1804
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1799
|
-
const cmp =
|
|
1800
|
-
stack.push(
|
|
1805
|
+
const cmp = chunkFR7RNOPT_cjs.compareBigIntOperands(l, r);
|
|
1806
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === null ? l.toNumber() <= r.toNumber() : cmp <= 0));
|
|
1801
1807
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1802
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1803
|
-
stack.push(sameMeasure ?
|
|
1808
|
+
const { lv, rv, equal, sameMeasure } = chunkFR7RNOPT_cjs.compareUom(l, r);
|
|
1809
|
+
stack.push(sameMeasure ? chunkIT74O4BE_cjs.boolValue(equal || lv <= rv) : chunkFR7RNOPT_cjs.incomparableUnitsError(l, r));
|
|
1804
1810
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1805
|
-
stack.push(
|
|
1811
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixCompare(l.value, r.value, (a, b) => a <= b));
|
|
1806
1812
|
} else {
|
|
1807
|
-
stack.push(
|
|
1813
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.toNumber() <= r.toNumber()));
|
|
1808
1814
|
}
|
|
1809
1815
|
break;
|
|
1810
1816
|
}
|
|
1811
1817
|
case 44 /* GT */: {
|
|
1812
1818
|
const r = safePop(stack), l = safePop(stack);
|
|
1813
|
-
const gtFault =
|
|
1819
|
+
const gtFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1814
1820
|
if (gtFault) {
|
|
1815
1821
|
stack.push(gtFault);
|
|
1816
1822
|
break;
|
|
1817
1823
|
}
|
|
1818
1824
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1819
|
-
const cmp =
|
|
1825
|
+
const cmp = chunkFR7RNOPT_cjs.compareRationalOperands(l, r);
|
|
1820
1826
|
if (cmp !== null) {
|
|
1821
|
-
stack.push(
|
|
1827
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp > 0));
|
|
1822
1828
|
break;
|
|
1823
1829
|
}
|
|
1824
1830
|
}
|
|
1825
1831
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1826
|
-
stack.push(
|
|
1832
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value > r.value));
|
|
1827
1833
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1828
|
-
const cmp =
|
|
1829
|
-
stack.push(
|
|
1834
|
+
const cmp = chunkFR7RNOPT_cjs.compareBigIntOperands(l, r);
|
|
1835
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === null ? l.toNumber() > r.toNumber() : cmp > 0));
|
|
1830
1836
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1831
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1832
|
-
stack.push(sameMeasure ?
|
|
1837
|
+
const { lv, rv, equal, sameMeasure } = chunkFR7RNOPT_cjs.compareUom(l, r);
|
|
1838
|
+
stack.push(sameMeasure ? chunkIT74O4BE_cjs.boolValue(!equal && lv > rv) : chunkFR7RNOPT_cjs.incomparableUnitsError(l, r));
|
|
1833
1839
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1834
|
-
stack.push(
|
|
1840
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixCompare(l.value, r.value, (a, b) => a > b));
|
|
1835
1841
|
} else {
|
|
1836
|
-
stack.push(
|
|
1842
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.toNumber() > r.toNumber()));
|
|
1837
1843
|
}
|
|
1838
1844
|
break;
|
|
1839
1845
|
}
|
|
1840
1846
|
case 45 /* GTE */: {
|
|
1841
1847
|
const r = safePop(stack), l = safePop(stack);
|
|
1842
|
-
const gteFault =
|
|
1848
|
+
const gteFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1843
1849
|
if (gteFault) {
|
|
1844
1850
|
stack.push(gteFault);
|
|
1845
1851
|
break;
|
|
1846
1852
|
}
|
|
1847
1853
|
if (l.rational !== void 0 || r.rational !== void 0) {
|
|
1848
|
-
const cmp =
|
|
1854
|
+
const cmp = chunkFR7RNOPT_cjs.compareRationalOperands(l, r);
|
|
1849
1855
|
if (cmp !== null) {
|
|
1850
|
-
stack.push(
|
|
1856
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp >= 0));
|
|
1851
1857
|
break;
|
|
1852
1858
|
}
|
|
1853
1859
|
}
|
|
1854
1860
|
if (l.type === 0 /* Number */ && r.type === 0 /* Number */) {
|
|
1855
|
-
stack.push(
|
|
1861
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.value >= r.value));
|
|
1856
1862
|
} else if (l.type === 2 /* BigInt */ || r.type === 2 /* BigInt */) {
|
|
1857
|
-
const cmp =
|
|
1858
|
-
stack.push(
|
|
1863
|
+
const cmp = chunkFR7RNOPT_cjs.compareBigIntOperands(l, r);
|
|
1864
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(cmp === null ? l.toNumber() >= r.toNumber() : cmp >= 0));
|
|
1859
1865
|
} else if (l.type === 6 /* Uom */ && r.type === 6 /* Uom */) {
|
|
1860
|
-
const { lv, rv, equal, sameMeasure } =
|
|
1861
|
-
stack.push(sameMeasure ?
|
|
1866
|
+
const { lv, rv, equal, sameMeasure } = chunkFR7RNOPT_cjs.compareUom(l, r);
|
|
1867
|
+
stack.push(sameMeasure ? chunkIT74O4BE_cjs.boolValue(equal || lv >= rv) : chunkFR7RNOPT_cjs.incomparableUnitsError(l, r));
|
|
1862
1868
|
} else if (l.type === 7 /* Matrix */ && r.type === 7 /* Matrix */) {
|
|
1863
|
-
stack.push(
|
|
1869
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixCompare(l.value, r.value, (a, b) => a >= b));
|
|
1864
1870
|
} else {
|
|
1865
|
-
stack.push(
|
|
1871
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(l.toNumber() >= r.toNumber()));
|
|
1866
1872
|
}
|
|
1867
1873
|
break;
|
|
1868
1874
|
}
|
|
@@ -1877,29 +1883,29 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1877
1883
|
// ═══════════════════════════════════════════════════════════════
|
|
1878
1884
|
case 130 /* LOGICAL_AND */: {
|
|
1879
1885
|
const r = safePop(stack), l = safePop(stack);
|
|
1880
|
-
const andLogicFault =
|
|
1886
|
+
const andLogicFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1881
1887
|
if (andLogicFault) {
|
|
1882
1888
|
stack.push(andLogicFault);
|
|
1883
1889
|
break;
|
|
1884
1890
|
}
|
|
1885
|
-
stack.push(
|
|
1891
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(isTruthy(l) && isTruthy(r)));
|
|
1886
1892
|
break;
|
|
1887
1893
|
}
|
|
1888
1894
|
case 131 /* LOGICAL_OR */: {
|
|
1889
1895
|
const r = safePop(stack), l = safePop(stack);
|
|
1890
|
-
const orLogicFault =
|
|
1896
|
+
const orLogicFault = chunkIT74O4BE_cjs.faultedOperand(l, r);
|
|
1891
1897
|
if (orLogicFault) {
|
|
1892
1898
|
stack.push(orLogicFault);
|
|
1893
1899
|
break;
|
|
1894
1900
|
}
|
|
1895
|
-
stack.push(
|
|
1901
|
+
stack.push(chunkIT74O4BE_cjs.boolValue(isTruthy(l) || isTruthy(r)));
|
|
1896
1902
|
break;
|
|
1897
1903
|
}
|
|
1898
1904
|
case 132 /* SELECT */: {
|
|
1899
1905
|
const elseVal = safePop(stack);
|
|
1900
1906
|
const thenVal = safePop(stack);
|
|
1901
1907
|
const condition = safePop(stack);
|
|
1902
|
-
const conditionFault =
|
|
1908
|
+
const conditionFault = chunkIT74O4BE_cjs.faultedOperand(condition);
|
|
1903
1909
|
if (conditionFault) {
|
|
1904
1910
|
stack.push(conditionFault);
|
|
1905
1911
|
break;
|
|
@@ -1917,11 +1923,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1917
1923
|
for (let i = 0; i < argCount; i++) args.push(safePop(stack));
|
|
1918
1924
|
args.reverse();
|
|
1919
1925
|
const fn = vm.context.pluginFunctions[fnIdx];
|
|
1920
|
-
const pluginArgFault =
|
|
1926
|
+
const pluginArgFault = chunkIT74O4BE_cjs.faultedIn(args);
|
|
1921
1927
|
if (pluginArgFault) {
|
|
1922
1928
|
stack.push(pluginArgFault);
|
|
1923
1929
|
} else if (!fn) {
|
|
1924
|
-
stack.push(
|
|
1930
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(0));
|
|
1925
1931
|
} else {
|
|
1926
1932
|
const result = fn(args, context);
|
|
1927
1933
|
if (result instanceof Promise) {
|
|
@@ -1946,16 +1952,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1946
1952
|
if (arg.type === 9 /* Symbolic */) sawSymbolic = true;
|
|
1947
1953
|
args.push(arg);
|
|
1948
1954
|
}
|
|
1949
|
-
const builtinArgFault =
|
|
1955
|
+
const builtinArgFault = chunkIT74O4BE_cjs.faultedIn(args);
|
|
1950
1956
|
if (builtinArgFault) {
|
|
1951
1957
|
stack.push(builtinArgFault);
|
|
1952
1958
|
break;
|
|
1953
1959
|
}
|
|
1954
|
-
const fn =
|
|
1960
|
+
const fn = chunkFR7RNOPT_cjs.builtinFunctions[fnIdx];
|
|
1955
1961
|
if (fn) {
|
|
1956
1962
|
const ordered = args.reverse();
|
|
1957
|
-
const routeSymbolically = sawSymbolic && !
|
|
1958
|
-
stack.push(routeSymbolically ?
|
|
1963
|
+
const routeSymbolically = sawSymbolic && !chunkFR7RNOPT_cjs.SYMBOLIC_NATIVE_BUILTINS.has(fnIdx);
|
|
1964
|
+
stack.push(routeSymbolically ? chunkFR7RNOPT_cjs.symbolicBuiltin(fnIdx, ordered) : fn(ordered));
|
|
1959
1965
|
}
|
|
1960
1966
|
break;
|
|
1961
1967
|
}
|
|
@@ -1963,7 +1969,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1963
1969
|
const bodyIdx = operandByte(opcodes, ip++, op, "function-body index");
|
|
1964
1970
|
const def = userFunctionBodies?.[bodyIdx];
|
|
1965
1971
|
if (!def) {
|
|
1966
|
-
throw
|
|
1972
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.internal(
|
|
1967
1973
|
"INTERNAL_MISSING_FUNCTION_BODY",
|
|
1968
1974
|
`Internal error: DEFINE_USER_FUNCTION referenced missing body index ${bodyIdx}`,
|
|
1969
1975
|
{ bodyIdx }
|
|
@@ -1980,10 +1986,10 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1980
1986
|
args.reverse();
|
|
1981
1987
|
const fn = vm.getUserFunction(name);
|
|
1982
1988
|
if (!fn) {
|
|
1983
|
-
throw
|
|
1989
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution("UNDEFINED_FUNCTION", `Undefined function: ${name}`, { name });
|
|
1984
1990
|
}
|
|
1985
1991
|
if (argCount !== fn.params.length) {
|
|
1986
|
-
throw
|
|
1992
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
1987
1993
|
"FUNCTION_ARITY_MISMATCH",
|
|
1988
1994
|
`${name} expects ${fn.params.length} argument(s) but got ${argCount}`,
|
|
1989
1995
|
{ name, expected: fn.params.length, actual: argCount }
|
|
@@ -1991,7 +1997,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
1991
1997
|
}
|
|
1992
1998
|
const frame = /* @__PURE__ */ new Map();
|
|
1993
1999
|
for (let i = 0; i < fn.params.length; i++) frame.set(fn.params[i], args[i]);
|
|
1994
|
-
|
|
2000
|
+
chunkIT74O4BE_cjs.chargeFunctionCall();
|
|
1995
2001
|
vm.pushCallFrame(frame);
|
|
1996
2002
|
let bodyResult;
|
|
1997
2003
|
try {
|
|
@@ -2000,7 +2006,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2000
2006
|
vm.popCallFrame();
|
|
2001
2007
|
}
|
|
2002
2008
|
if (bodyResult.type === "pending") {
|
|
2003
|
-
throw
|
|
2009
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
2004
2010
|
"USER_FUNCTION_ASYNC_UNSUPPORTED",
|
|
2005
2011
|
`${name}: user-defined functions with async bodies (weather, stocks, currency, ...) aren't supported`,
|
|
2006
2012
|
{ name }
|
|
@@ -2021,9 +2027,9 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2021
2027
|
if (val !== void 0) {
|
|
2022
2028
|
stack.push(val);
|
|
2023
2029
|
} else if (symbolicTolerant) {
|
|
2024
|
-
stack.push(
|
|
2030
|
+
stack.push(chunkIT74O4BE_cjs.symbolicValue(chunkA2DZ5BEJ_cjs.varNode(varName)));
|
|
2025
2031
|
} else {
|
|
2026
|
-
throw
|
|
2032
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
|
|
2027
2033
|
"UNDEFINED_VARIABLE",
|
|
2028
2034
|
`Undefined variable: ${varName}`,
|
|
2029
2035
|
{ varName }
|
|
@@ -2034,15 +2040,15 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2034
2040
|
case 61 /* STORE_VAR */: {
|
|
2035
2041
|
const val = safePop(stack);
|
|
2036
2042
|
const varName = poolString(opcodes, ip++, strings, op, "variable-name index");
|
|
2037
|
-
vm.setVar(varName, hasArena ?
|
|
2043
|
+
vm.setVar(varName, hasArena ? chunkIT74O4BE_cjs.persistentValue(val) : val);
|
|
2038
2044
|
stack.push(val);
|
|
2039
2045
|
break;
|
|
2040
2046
|
}
|
|
2041
2047
|
case 62 /* LOAD_GLOBAL_VAR */: {
|
|
2042
2048
|
const varName = poolString(opcodes, ip++, strings, op, "variable-name index");
|
|
2043
|
-
const globalValue =
|
|
2049
|
+
const globalValue = chunkFR7RNOPT_cjs.sharedGlobalVariableStore.get(varName);
|
|
2044
2050
|
if (globalValue === void 0) {
|
|
2045
|
-
throw
|
|
2051
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.internal({
|
|
2046
2052
|
code: "GLOBAL_VARIABLE_NOT_RESOLVED",
|
|
2047
2053
|
message: `Global variable "${varName}" was read before it resolved`,
|
|
2048
2054
|
expected: `global variable "${varName}" to already be resolved (async preflight should guarantee this)`,
|
|
@@ -2056,7 +2062,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2056
2062
|
case 63 /* STORE_GLOBAL_VAR */: {
|
|
2057
2063
|
const val = safePop(stack);
|
|
2058
2064
|
const varName = poolString(opcodes, ip++, strings, op, "variable-name index");
|
|
2059
|
-
|
|
2065
|
+
chunkFR7RNOPT_cjs.sharedGlobalVariableStore.set(varName, hasArena ? chunkIT74O4BE_cjs.persistentValue(val) : val);
|
|
2060
2066
|
stack.push(val);
|
|
2061
2067
|
break;
|
|
2062
2068
|
}
|
|
@@ -2069,102 +2075,102 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2069
2075
|
// ═══════════════════════════════════════════════════════════════
|
|
2070
2076
|
case 70 /* TO_NUMBER */: {
|
|
2071
2077
|
const v = safePop(stack);
|
|
2072
|
-
const toNumberFault =
|
|
2078
|
+
const toNumberFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2073
2079
|
if (toNumberFault) {
|
|
2074
2080
|
stack.push(toNumberFault);
|
|
2075
2081
|
break;
|
|
2076
2082
|
}
|
|
2077
|
-
stack.push(
|
|
2083
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(v.toNumber()));
|
|
2078
2084
|
break;
|
|
2079
2085
|
}
|
|
2080
2086
|
case 71 /* TO_HEX */: {
|
|
2081
2087
|
const v = safePop(stack);
|
|
2082
|
-
const toHexFault =
|
|
2088
|
+
const toHexFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2083
2089
|
if (toHexFault) {
|
|
2084
2090
|
stack.push(toHexFault);
|
|
2085
2091
|
break;
|
|
2086
2092
|
}
|
|
2087
2093
|
if (v.type === 14 /* Colour */) {
|
|
2088
2094
|
const c = v.value;
|
|
2089
|
-
stack.push(
|
|
2095
|
+
stack.push(chunkIT74O4BE_cjs.colourValue({ r: c.r, g: c.g, b: c.b, a: c.a, format: "hex" }));
|
|
2090
2096
|
break;
|
|
2091
2097
|
}
|
|
2092
|
-
stack.push(
|
|
2098
|
+
stack.push(chunkIT74O4BE_cjs.hexValue(v.type === 2 /* BigInt */ ? v.value : v.toNumber()));
|
|
2093
2099
|
break;
|
|
2094
2100
|
}
|
|
2095
2101
|
case 74 /* TO_PERCENTAGE */: {
|
|
2096
2102
|
const v = safePop(stack);
|
|
2097
|
-
const toPercentageFault =
|
|
2103
|
+
const toPercentageFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2098
2104
|
if (toPercentageFault) {
|
|
2099
2105
|
stack.push(toPercentageFault);
|
|
2100
2106
|
break;
|
|
2101
2107
|
}
|
|
2102
|
-
stack.push(
|
|
2108
|
+
stack.push(chunkIT74O4BE_cjs.percentageValue(v.toNumber()));
|
|
2103
2109
|
break;
|
|
2104
2110
|
}
|
|
2105
2111
|
case 140 /* TO_FRACTION */: {
|
|
2106
2112
|
const v = safePop(stack);
|
|
2107
|
-
const toFractionFault =
|
|
2113
|
+
const toFractionFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2108
2114
|
if (toFractionFault) {
|
|
2109
2115
|
stack.push(toFractionFault);
|
|
2110
2116
|
break;
|
|
2111
2117
|
}
|
|
2112
|
-
stack.push(
|
|
2118
|
+
stack.push(chunkIT74O4BE_cjs.stringValue(v.rational !== void 0 ? rationalToFractionString(v.rational) : toFractionString(v.toNumber())));
|
|
2113
2119
|
break;
|
|
2114
2120
|
}
|
|
2115
2121
|
case 141 /* TO_MULTIPLIER */: {
|
|
2116
2122
|
const v = safePop(stack);
|
|
2117
|
-
const toMultiplierFault =
|
|
2123
|
+
const toMultiplierFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2118
2124
|
if (toMultiplierFault) {
|
|
2119
2125
|
stack.push(toMultiplierFault);
|
|
2120
2126
|
break;
|
|
2121
2127
|
}
|
|
2122
|
-
stack.push(
|
|
2128
|
+
stack.push(chunkIT74O4BE_cjs.stringValue(toMultiplierString(v)));
|
|
2123
2129
|
break;
|
|
2124
2130
|
}
|
|
2125
2131
|
case 142 /* TO_SCI */: {
|
|
2126
2132
|
const v = safePop(stack);
|
|
2127
|
-
const toSciFault =
|
|
2133
|
+
const toSciFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2128
2134
|
if (toSciFault) {
|
|
2129
2135
|
stack.push(toSciFault);
|
|
2130
2136
|
break;
|
|
2131
2137
|
}
|
|
2132
|
-
stack.push(
|
|
2138
|
+
stack.push(chunkIT74O4BE_cjs.stringValue(toScientificString(v.toNumber())));
|
|
2133
2139
|
break;
|
|
2134
2140
|
}
|
|
2135
2141
|
// Numeric, like TO_HEX above. A base is a way of writing a number, so
|
|
2136
2142
|
// `(255 as binary) + 1` has to be 256; as a string it was 1.
|
|
2137
2143
|
case 143 /* TO_BINARY */: {
|
|
2138
2144
|
const v = safePop(stack);
|
|
2139
|
-
const toBinaryFault =
|
|
2145
|
+
const toBinaryFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2140
2146
|
if (toBinaryFault) {
|
|
2141
2147
|
stack.push(toBinaryFault);
|
|
2142
2148
|
break;
|
|
2143
2149
|
}
|
|
2144
|
-
stack.push(
|
|
2150
|
+
stack.push(chunkIT74O4BE_cjs.hexValue(v.type === 2 /* BigInt */ ? v.value : v.toNumber(), "bin"));
|
|
2145
2151
|
break;
|
|
2146
2152
|
}
|
|
2147
2153
|
case 144 /* TO_OCTAL */: {
|
|
2148
2154
|
const v = safePop(stack);
|
|
2149
|
-
const toOctalFault =
|
|
2155
|
+
const toOctalFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2150
2156
|
if (toOctalFault) {
|
|
2151
2157
|
stack.push(toOctalFault);
|
|
2152
2158
|
break;
|
|
2153
2159
|
}
|
|
2154
|
-
stack.push(
|
|
2160
|
+
stack.push(chunkIT74O4BE_cjs.hexValue(v.type === 2 /* BigInt */ ? v.value : v.toNumber(), "oct"));
|
|
2155
2161
|
break;
|
|
2156
2162
|
}
|
|
2157
2163
|
case 145 /* CALL_AS_CONVERTER */: {
|
|
2158
2164
|
const name = stringOperand(safePop(stack), op, "converter name").toLowerCase();
|
|
2159
2165
|
const value = safePop(stack);
|
|
2160
|
-
const converterFault =
|
|
2166
|
+
const converterFault = chunkIT74O4BE_cjs.faultedOperand(value);
|
|
2161
2167
|
if (converterFault) {
|
|
2162
2168
|
stack.push(converterFault);
|
|
2163
2169
|
break;
|
|
2164
2170
|
}
|
|
2165
|
-
const converter =
|
|
2171
|
+
const converter = chunkFR7RNOPT_cjs.asConverterRegistry.get(name);
|
|
2166
2172
|
if (!converter) {
|
|
2167
|
-
stack.push(
|
|
2173
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("UNKNOWN_AS_CONVERTER", `Unknown converter "as ${name}"`));
|
|
2168
2174
|
} else {
|
|
2169
2175
|
stack.push(converter(value));
|
|
2170
2176
|
}
|
|
@@ -2176,41 +2182,41 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2176
2182
|
case 80 /* UOM_CONVERT */: {
|
|
2177
2183
|
const unit = stringOperand(safePop(stack), op, "unit name");
|
|
2178
2184
|
const operand = safePop(stack);
|
|
2179
|
-
const faulted =
|
|
2185
|
+
const faulted = chunkIT74O4BE_cjs.faultedOperand(operand);
|
|
2180
2186
|
if (faulted) {
|
|
2181
2187
|
stack.push(faulted);
|
|
2182
2188
|
break;
|
|
2183
2189
|
}
|
|
2184
|
-
const money =
|
|
2185
|
-
if (money) stack.push(
|
|
2186
|
-
else stack.push(
|
|
2190
|
+
const money = chunkFR7RNOPT_cjs.moneyExactMagnitude(operand, unit);
|
|
2191
|
+
if (money) stack.push(chunkIT74O4BE_cjs.uomValueExact(operand.toNumber(), unit, money));
|
|
2192
|
+
else stack.push(chunkIT74O4BE_cjs.uomValue(operand.toNumber(), unit));
|
|
2187
2193
|
break;
|
|
2188
2194
|
}
|
|
2189
2195
|
case 81 /* UOM_CONVERT_TO */: {
|
|
2190
2196
|
const toUnit = stringOperand(safePop(stack), op, "target unit name");
|
|
2191
2197
|
const fromUnit = stringOperand(safePop(stack), op, "source unit name");
|
|
2192
2198
|
const operand = safePop(stack);
|
|
2193
|
-
const faulted =
|
|
2199
|
+
const faulted = chunkIT74O4BE_cjs.faultedOperand(operand);
|
|
2194
2200
|
if (faulted) {
|
|
2195
2201
|
stack.push(faulted);
|
|
2196
2202
|
break;
|
|
2197
2203
|
}
|
|
2198
2204
|
const val = operand.toNumber();
|
|
2199
2205
|
const measure = chunkEJ3ILXX6_cjs.getMeasure(fromUnit);
|
|
2200
|
-
const isCurrency =
|
|
2206
|
+
const isCurrency = chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(fromUnit) && chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(toUnit);
|
|
2201
2207
|
if (measure && chunkEJ3ILXX6_cjs.getMeasure(toUnit) === measure) {
|
|
2202
|
-
stack.push(
|
|
2208
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(chunkEJ3ILXX6_cjs.convertUnit(val, fromUnit, toUnit), toUnit));
|
|
2203
2209
|
} else if (isCurrency) {
|
|
2204
|
-
const converted =
|
|
2210
|
+
const converted = chunkKXDQKVNX_cjs.sharedCurrencyExchange.convertSync(val, fromUnit, toUnit);
|
|
2205
2211
|
if (converted !== null) {
|
|
2206
|
-
stack.push(
|
|
2212
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(converted, toUnit));
|
|
2207
2213
|
} else {
|
|
2208
|
-
stack.push(
|
|
2214
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("CURRENCY_RATE_UNAVAILABLE", `No exchange rate available for ${fromUnit} to ${toUnit}`));
|
|
2209
2215
|
}
|
|
2210
2216
|
} else {
|
|
2211
2217
|
const rate = chunkEJ3ILXX6_cjs.convertRate(val, fromUnit, toUnit);
|
|
2212
2218
|
if (rate !== null) {
|
|
2213
|
-
stack.push(
|
|
2219
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(rate, toUnit));
|
|
2214
2220
|
} else {
|
|
2215
2221
|
stack.push(incompatibleConversionError(fromUnit, toUnit));
|
|
2216
2222
|
}
|
|
@@ -2220,25 +2226,25 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2220
2226
|
case 85 /* UOM_POSSIBILITIES */: {
|
|
2221
2227
|
const unit = stringOperand(safePop(stack), op, "unit name");
|
|
2222
2228
|
const possibilities = chunkEJ3ILXX6_cjs.getConvertiblePossibilities(unit);
|
|
2223
|
-
stack.push(
|
|
2229
|
+
stack.push(chunkIT74O4BE_cjs.stringValue(possibilities.length > 0 ? possibilities.join(", ") : `No known units for "${unit}"`));
|
|
2224
2230
|
break;
|
|
2225
2231
|
}
|
|
2226
2232
|
case 83 /* UOM_BEST */: {
|
|
2227
2233
|
const unit = stringOperand(safePop(stack), op, "unit name");
|
|
2228
2234
|
const operand = safePop(stack);
|
|
2229
|
-
const faulted =
|
|
2235
|
+
const faulted = chunkIT74O4BE_cjs.faultedOperand(operand);
|
|
2230
2236
|
if (faulted) {
|
|
2231
2237
|
stack.push(faulted);
|
|
2232
2238
|
break;
|
|
2233
2239
|
}
|
|
2234
2240
|
const { value, unit: bestUnit } = chunkEJ3ILXX6_cjs.getBestUnit(operand.toNumber(), unit);
|
|
2235
|
-
stack.push(
|
|
2241
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(value, bestUnit));
|
|
2236
2242
|
break;
|
|
2237
2243
|
}
|
|
2238
2244
|
case 84 /* UOM_CONVERT_IN */: {
|
|
2239
2245
|
const toUnit = stringOperand(safePop(stack), op, "target unit name");
|
|
2240
2246
|
const left = safePop(stack);
|
|
2241
|
-
const faulted =
|
|
2247
|
+
const faulted = chunkIT74O4BE_cjs.faultedOperand(left);
|
|
2242
2248
|
if (faulted) {
|
|
2243
2249
|
stack.push(faulted);
|
|
2244
2250
|
break;
|
|
@@ -2247,37 +2253,37 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2247
2253
|
const fromUnit = left.unit;
|
|
2248
2254
|
const val = left.toNumber();
|
|
2249
2255
|
const measure = chunkEJ3ILXX6_cjs.getMeasure(fromUnit);
|
|
2250
|
-
const isCurrency =
|
|
2256
|
+
const isCurrency = chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(fromUnit) && chunkKXDQKVNX_cjs.sharedCurrencyExchange.isCurrency(toUnit);
|
|
2251
2257
|
if (measure && chunkEJ3ILXX6_cjs.getMeasure(toUnit) === measure) {
|
|
2252
|
-
stack.push(
|
|
2258
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(chunkEJ3ILXX6_cjs.convertUnit(val, fromUnit, toUnit), toUnit));
|
|
2253
2259
|
} else if (isCurrency) {
|
|
2254
|
-
const converted =
|
|
2260
|
+
const converted = chunkKXDQKVNX_cjs.sharedCurrencyExchange.convertSync(val, fromUnit, toUnit);
|
|
2255
2261
|
if (converted !== null) {
|
|
2256
|
-
stack.push(
|
|
2262
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(converted, toUnit));
|
|
2257
2263
|
} else {
|
|
2258
|
-
stack.push(
|
|
2264
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("CURRENCY_RATE_UNAVAILABLE", `No exchange rate available for ${fromUnit} to ${toUnit}`));
|
|
2259
2265
|
}
|
|
2260
2266
|
} else {
|
|
2261
2267
|
const rate = chunkEJ3ILXX6_cjs.convertRate(val, fromUnit, toUnit);
|
|
2262
2268
|
if (rate !== null) {
|
|
2263
|
-
stack.push(
|
|
2269
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(rate, toUnit));
|
|
2264
2270
|
} else {
|
|
2265
2271
|
stack.push(incompatibleConversionError(fromUnit, toUnit));
|
|
2266
2272
|
}
|
|
2267
2273
|
}
|
|
2268
2274
|
} else {
|
|
2269
|
-
stack.push(
|
|
2275
|
+
stack.push(chunkIT74O4BE_cjs.uomValue(left.toNumber(), toUnit));
|
|
2270
2276
|
}
|
|
2271
2277
|
break;
|
|
2272
2278
|
}
|
|
2273
2279
|
case 82 /* UOM_GET_VALUE */: {
|
|
2274
2280
|
const v = safePop(stack);
|
|
2275
|
-
const getValueFault =
|
|
2281
|
+
const getValueFault = chunkIT74O4BE_cjs.faultedOperand(v);
|
|
2276
2282
|
if (getValueFault) {
|
|
2277
2283
|
stack.push(getValueFault);
|
|
2278
2284
|
break;
|
|
2279
2285
|
}
|
|
2280
|
-
stack.push(
|
|
2286
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(v.toNumber()));
|
|
2281
2287
|
break;
|
|
2282
2288
|
}
|
|
2283
2289
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2287,33 +2293,33 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2287
2293
|
case 110 /* RATE_DIV */: {
|
|
2288
2294
|
const denominatorVal = safePop(stack);
|
|
2289
2295
|
const numeratorVal = safePop(stack);
|
|
2290
|
-
const rateDivFault =
|
|
2296
|
+
const rateDivFault = chunkIT74O4BE_cjs.faultedOperand(numeratorVal, denominatorVal);
|
|
2291
2297
|
if (rateDivFault) {
|
|
2292
2298
|
stack.push(rateDivFault);
|
|
2293
2299
|
break;
|
|
2294
2300
|
}
|
|
2295
2301
|
if (denominatorVal.type !== 6 /* Uom */ || !denominatorVal.unit) {
|
|
2296
|
-
stack.push(
|
|
2302
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("RATE_MISSING_DENOMINATOR_UNIT", 'Cannot build a rate: the right-hand side of "/" has no unit'));
|
|
2297
2303
|
break;
|
|
2298
2304
|
}
|
|
2299
2305
|
const numeratorUnit = numeratorVal.type === 6 /* Uom */ ? numeratorVal.unit ?? "" : "";
|
|
2300
|
-
stack.push(
|
|
2306
|
+
stack.push(chunkIT74O4BE_cjs.rateValue(numeratorVal.toNumber() / denominatorVal.toNumber(), numeratorUnit, denominatorVal.unit));
|
|
2301
2307
|
break;
|
|
2302
2308
|
}
|
|
2303
2309
|
case 111 /* RATE_MUL */: {
|
|
2304
2310
|
const multiplier = safePop(stack);
|
|
2305
2311
|
const rate = safePop(stack);
|
|
2306
|
-
const rateMulFault =
|
|
2312
|
+
const rateMulFault = chunkIT74O4BE_cjs.faultedOperand(rate, multiplier);
|
|
2307
2313
|
if (rateMulFault) {
|
|
2308
2314
|
stack.push(rateMulFault);
|
|
2309
2315
|
break;
|
|
2310
2316
|
}
|
|
2311
|
-
if (rate.type !== 6 /* Uom */ || !
|
|
2312
|
-
stack.push(
|
|
2317
|
+
if (rate.type !== 6 /* Uom */ || !chunkIT74O4BE_cjs.isRateUnit(rate.unit)) {
|
|
2318
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("RATE_MUL_LEFT_NOT_A_RATE", 'Left-hand side of a rate multiplication must be a rate (e.g. "$50/week")'));
|
|
2313
2319
|
break;
|
|
2314
2320
|
}
|
|
2315
2321
|
if (multiplier.type !== 6 /* Uom */ || !multiplier.unit) {
|
|
2316
|
-
stack.push(
|
|
2322
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("RATE_MUL_RIGHT_MISSING_UNIT", "Right-hand side of a rate multiplication must have a unit matching the rate's denominator"));
|
|
2317
2323
|
break;
|
|
2318
2324
|
}
|
|
2319
2325
|
stack.push(multiplyRateByMatchingUom(rate, multiplier));
|
|
@@ -2322,27 +2328,27 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2322
2328
|
case 112 /* RATE_CONVERT */: {
|
|
2323
2329
|
const newDenominatorUnit = stringOperand(safePop(stack), op, "denominator unit name");
|
|
2324
2330
|
const rate = safePop(stack);
|
|
2325
|
-
const rateConvertFault =
|
|
2331
|
+
const rateConvertFault = chunkIT74O4BE_cjs.faultedOperand(rate);
|
|
2326
2332
|
if (rateConvertFault) {
|
|
2327
2333
|
stack.push(rateConvertFault);
|
|
2328
2334
|
break;
|
|
2329
2335
|
}
|
|
2330
|
-
if (rate.type !== 6 /* Uom */ || !
|
|
2331
|
-
stack.push(
|
|
2336
|
+
if (rate.type !== 6 /* Uom */ || !chunkIT74O4BE_cjs.isRateUnit(rate.unit)) {
|
|
2337
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("RATE_CONVERT_NOT_A_RATE", "Cannot convert a non-rate value's denominator"));
|
|
2332
2338
|
break;
|
|
2333
2339
|
}
|
|
2334
|
-
const { numerator, denominator } =
|
|
2340
|
+
const { numerator, denominator } = chunkIT74O4BE_cjs.splitRateUnit(rate.unit);
|
|
2335
2341
|
const rateMeasure = chunkEJ3ILXX6_cjs.getMeasure(denominator);
|
|
2336
2342
|
const targetMeasure = chunkEJ3ILXX6_cjs.getMeasure(newDenominatorUnit);
|
|
2337
2343
|
if (!rateMeasure || rateMeasure !== targetMeasure) {
|
|
2338
|
-
stack.push(
|
|
2344
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2339
2345
|
"RATE_CONVERT_MEASURE_MISMATCH",
|
|
2340
2346
|
`Cannot convert a "${denominator}"-denominated rate to "${newDenominatorUnit}" \u2014 different measures`
|
|
2341
2347
|
));
|
|
2342
2348
|
break;
|
|
2343
2349
|
}
|
|
2344
2350
|
const factor = chunkEJ3ILXX6_cjs.convertUnit(1, newDenominatorUnit, denominator);
|
|
2345
|
-
stack.push(
|
|
2351
|
+
stack.push(chunkIT74O4BE_cjs.rateValue(rate.toNumber() * factor, numerator, newDenominatorUnit));
|
|
2346
2352
|
break;
|
|
2347
2353
|
}
|
|
2348
2354
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2350,7 +2356,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2350
2356
|
// ═══════════════════════════════════════════════════════════════
|
|
2351
2357
|
case 120 /* CLOCK_TIME_TODAY */: {
|
|
2352
2358
|
const minutesValue = safePop(stack);
|
|
2353
|
-
const clockFault =
|
|
2359
|
+
const clockFault = chunkIT74O4BE_cjs.faultedOperand(minutesValue);
|
|
2354
2360
|
if (clockFault) {
|
|
2355
2361
|
stack.push(clockFault);
|
|
2356
2362
|
break;
|
|
@@ -2359,87 +2365,87 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2359
2365
|
const now = /* @__PURE__ */ new Date();
|
|
2360
2366
|
const anchored = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
2361
2367
|
anchored.setMinutes(totalMinutes);
|
|
2362
|
-
stack.push(
|
|
2368
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(anchored.getTime()));
|
|
2363
2369
|
break;
|
|
2364
2370
|
}
|
|
2365
2371
|
// ═══════════════════════════════════════════════════════════════
|
|
2366
2372
|
// §9 Datetime (OpCode 90–93)
|
|
2367
2373
|
// ═══════════════════════════════════════════════════════════════
|
|
2368
2374
|
case 90 /* DATE_NOW */:
|
|
2369
|
-
stack.push(
|
|
2375
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(Date.now()));
|
|
2370
2376
|
break;
|
|
2371
2377
|
case 95 /* DATE_LITERAL */:
|
|
2372
|
-
stack.push(
|
|
2378
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(numbers[poolIndex(opcodes, ip++, op, "constant-pool index", numbers.length, "number-pool")]));
|
|
2373
2379
|
break;
|
|
2374
2380
|
case 91 /* DATE_ADD */: {
|
|
2375
2381
|
const durValue = safePop(stack), dtValue = safePop(stack);
|
|
2376
|
-
const dateAddFault =
|
|
2382
|
+
const dateAddFault = chunkIT74O4BE_cjs.faultedOperand(dtValue, durValue);
|
|
2377
2383
|
if (dateAddFault) {
|
|
2378
2384
|
stack.push(dateAddFault);
|
|
2379
2385
|
break;
|
|
2380
2386
|
}
|
|
2381
|
-
stack.push(
|
|
2387
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(shiftDatetime(dtValue.toNumber(), durValue, 1, vm)));
|
|
2382
2388
|
break;
|
|
2383
2389
|
}
|
|
2384
2390
|
case 92 /* DATE_SUB */: {
|
|
2385
2391
|
const durValue = safePop(stack), dtValue = safePop(stack);
|
|
2386
|
-
const dateSubFault =
|
|
2392
|
+
const dateSubFault = chunkIT74O4BE_cjs.faultedOperand(dtValue, durValue);
|
|
2387
2393
|
if (dateSubFault) {
|
|
2388
2394
|
stack.push(dateSubFault);
|
|
2389
2395
|
break;
|
|
2390
2396
|
}
|
|
2391
|
-
stack.push(
|
|
2397
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(shiftDatetime(dtValue.toNumber(), durValue, -1, vm)));
|
|
2392
2398
|
break;
|
|
2393
2399
|
}
|
|
2394
2400
|
case 96 /* DATE_WORKDAY_OFFSET */: {
|
|
2395
2401
|
const workdayDirection = operandByte(opcodes, ip++, op, "workday offset direction") === 1 ? -1 : 1;
|
|
2396
2402
|
const anchorValue = safePop(stack), countValue = safePop(stack);
|
|
2397
|
-
const offsetFault =
|
|
2403
|
+
const offsetFault = chunkIT74O4BE_cjs.faultedOperand(countValue, anchorValue);
|
|
2398
2404
|
if (offsetFault) {
|
|
2399
2405
|
stack.push(offsetFault);
|
|
2400
2406
|
break;
|
|
2401
2407
|
}
|
|
2402
2408
|
if (anchorValue.type !== 4 /* Datetime */) {
|
|
2403
|
-
stack.push(
|
|
2404
|
-
|
|
2405
|
-
`"working days after/before/from" expects a date to count from, got ${
|
|
2409
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2410
|
+
chunkMIGXCBXT_cjs.CoreErrorCodes.WORKDAY_OFFSET_EXPECTED_DATE,
|
|
2411
|
+
`"working days after/before/from" expects a date to count from, got ${chunkIT74O4BE_cjs.ValueType[anchorValue.type] ?? "an unsupported value"}`
|
|
2406
2412
|
));
|
|
2407
2413
|
break;
|
|
2408
2414
|
}
|
|
2409
|
-
stack.push(
|
|
2415
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(addBusinessDays2(anchorValue.toNumber(), workdayDirection * countValue.toNumber(), vm)));
|
|
2410
2416
|
break;
|
|
2411
2417
|
}
|
|
2412
2418
|
case 97 /* DATE_WORKDAYS_BETWEEN */: {
|
|
2413
2419
|
const endValue = safePop(stack), startValue = safePop(stack);
|
|
2414
|
-
const betweenFault =
|
|
2420
|
+
const betweenFault = chunkIT74O4BE_cjs.faultedOperand(startValue, endValue);
|
|
2415
2421
|
if (betweenFault) {
|
|
2416
2422
|
stack.push(betweenFault);
|
|
2417
2423
|
break;
|
|
2418
2424
|
}
|
|
2419
2425
|
if (startValue.type !== 4 /* Datetime */ || endValue.type !== 4 /* Datetime */) {
|
|
2420
|
-
stack.push(
|
|
2421
|
-
|
|
2422
|
-
`"working days between" expects two dates, got ${
|
|
2426
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2427
|
+
chunkMIGXCBXT_cjs.CoreErrorCodes.WORKDAYS_BETWEEN_EXPECTED_DATES,
|
|
2428
|
+
`"working days between" expects two dates, got ${chunkIT74O4BE_cjs.ValueType[startValue.type] ?? "an unsupported value"} and ${chunkIT74O4BE_cjs.ValueType[endValue.type] ?? "an unsupported value"}`
|
|
2423
2429
|
));
|
|
2424
2430
|
break;
|
|
2425
2431
|
}
|
|
2426
2432
|
const spanLimitDays = Math.ceil((vm.getMaxDateOffsetYears() - vm.getMinDateOffsetYears()) * 366);
|
|
2427
2433
|
const workdayCount = countBusinessDaysBetween(startValue.toNumber(), endValue.toNumber(), (ms) => vm.isHoliday(ms), spanLimitDays);
|
|
2428
2434
|
if (workdayCount === null) {
|
|
2429
|
-
stack.push(
|
|
2430
|
-
|
|
2435
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2436
|
+
chunkMIGXCBXT_cjs.CoreErrorCodes.WORKDAYS_BETWEEN_RANGE_TOO_LARGE,
|
|
2431
2437
|
`The two dates are more than ${vm.getMaxDateOffsetYears() - vm.getMinDateOffsetYears()} years apart, past the working-day count's limit`
|
|
2432
2438
|
));
|
|
2433
2439
|
break;
|
|
2434
2440
|
}
|
|
2435
|
-
stack.push(
|
|
2441
|
+
stack.push(chunkIT74O4BE_cjs.numberValue(workdayCount));
|
|
2436
2442
|
break;
|
|
2437
2443
|
}
|
|
2438
2444
|
case 93 /* DATE_NEXT_WEEKDAY */:
|
|
2439
2445
|
case 94 /* DATE_LAST_WEEKDAY */: {
|
|
2440
2446
|
const targetDayValue = safePop(stack);
|
|
2441
2447
|
const nowValue = safePop(stack);
|
|
2442
|
-
const weekdayFault =
|
|
2448
|
+
const weekdayFault = chunkIT74O4BE_cjs.faultedOperand(nowValue, targetDayValue);
|
|
2443
2449
|
if (weekdayFault) {
|
|
2444
2450
|
stack.push(weekdayFault);
|
|
2445
2451
|
break;
|
|
@@ -2449,7 +2455,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2449
2455
|
const currentDay = new Date(now).getDay();
|
|
2450
2456
|
let diffDays = op === 93 /* DATE_NEXT_WEEKDAY */ ? (targetDay - currentDay + 7) % 7 : (currentDay - targetDay + 7) % 7;
|
|
2451
2457
|
if (diffDays === 0) diffDays = 7;
|
|
2452
|
-
stack.push(
|
|
2458
|
+
stack.push(chunkIT74O4BE_cjs.datetimeValue(addCalendarDays(now, op === 93 /* DATE_NEXT_WEEKDAY */ ? diffDays : -diffDays)));
|
|
2453
2459
|
break;
|
|
2454
2460
|
}
|
|
2455
2461
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2464,116 +2470,116 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2464
2470
|
const rows = operandByte(opcodes, ip++, op, "row count");
|
|
2465
2471
|
const cols = operandByte(opcodes, ip++, op, "column count");
|
|
2466
2472
|
const count = rows * cols;
|
|
2467
|
-
const rowMajor =
|
|
2473
|
+
const rowMajor = chunkIT74O4BE_cjs.checkedArray(count, "matrix cells");
|
|
2468
2474
|
let cellFault = null;
|
|
2469
2475
|
for (let i = count - 1; i >= 0; i--) {
|
|
2470
2476
|
const cellVal = safePop(stack);
|
|
2471
|
-
if (cellFault === null) cellFault =
|
|
2477
|
+
if (cellFault === null) cellFault = chunkIT74O4BE_cjs.faultedOperand(cellVal);
|
|
2472
2478
|
rowMajor[i] = cellVal.type === 10 /* Boolean */ ? cellVal.value : cellVal.type === 9 /* Symbolic */ ? cellVal.value : cellVal.toNumber();
|
|
2473
2479
|
}
|
|
2474
2480
|
if (cellFault) {
|
|
2475
2481
|
stack.push(cellFault);
|
|
2476
2482
|
break;
|
|
2477
2483
|
}
|
|
2478
|
-
stack.push(
|
|
2484
|
+
stack.push(chunkIT74O4BE_cjs.matrixValue(rows, cols, chunkA2DZ5BEJ_cjs.rowMajorToColumnMajor(rows, cols, rowMajor)));
|
|
2479
2485
|
break;
|
|
2480
2486
|
}
|
|
2481
2487
|
case 153 /* MAT_INDEX1 */: {
|
|
2482
2488
|
const indexVal = safePop(stack), matrixVal = safePop(stack);
|
|
2483
|
-
const index1Fault =
|
|
2489
|
+
const index1Fault = chunkIT74O4BE_cjs.faultedOperand(matrixVal, indexVal);
|
|
2484
2490
|
if (index1Fault) {
|
|
2485
2491
|
stack.push(index1Fault);
|
|
2486
2492
|
break;
|
|
2487
2493
|
}
|
|
2488
2494
|
if (matrixVal.type !== 7 /* Matrix */) {
|
|
2489
|
-
stack.push(
|
|
2495
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("MATRIX_INDEX_NOT_A_MATRIX", `Cannot index a non-matrix value with "[...]".`));
|
|
2490
2496
|
break;
|
|
2491
2497
|
}
|
|
2492
2498
|
const m = matrixVal.value;
|
|
2493
2499
|
const index = Math.trunc(indexVal.toNumber());
|
|
2494
2500
|
if (index < 0 || index >= m.data.length) {
|
|
2495
|
-
stack.push(
|
|
2501
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2496
2502
|
"MATRIX_INDEX_OUT_OF_BOUNDS",
|
|
2497
2503
|
`Index ${index} is out of bounds for a ${m.rows}x${m.cols} matrix (valid range: 0-${m.data.length - 1}).`
|
|
2498
2504
|
));
|
|
2499
2505
|
break;
|
|
2500
2506
|
}
|
|
2501
|
-
const cell =
|
|
2502
|
-
stack.push(
|
|
2507
|
+
const cell = chunkA2DZ5BEJ_cjs.matIndex(m, index);
|
|
2508
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixEntryToValue(cell));
|
|
2503
2509
|
break;
|
|
2504
2510
|
}
|
|
2505
2511
|
case 154 /* MAT_INDEX2 */: {
|
|
2506
2512
|
const colVal = safePop(stack), rowVal = safePop(stack), matrixVal = safePop(stack);
|
|
2507
|
-
const index2Fault =
|
|
2513
|
+
const index2Fault = chunkIT74O4BE_cjs.faultedOperand(matrixVal, rowVal, colVal);
|
|
2508
2514
|
if (index2Fault) {
|
|
2509
2515
|
stack.push(index2Fault);
|
|
2510
2516
|
break;
|
|
2511
2517
|
}
|
|
2512
2518
|
if (matrixVal.type !== 7 /* Matrix */) {
|
|
2513
|
-
stack.push(
|
|
2519
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("MATRIX_INDEX_NOT_A_MATRIX", `Cannot index a non-matrix value with "[...]".`));
|
|
2514
2520
|
break;
|
|
2515
2521
|
}
|
|
2516
2522
|
const m = matrixVal.value;
|
|
2517
2523
|
const row = Math.trunc(rowVal.toNumber());
|
|
2518
2524
|
const col = Math.trunc(colVal.toNumber());
|
|
2519
|
-
if (!
|
|
2520
|
-
stack.push(
|
|
2525
|
+
if (!chunkA2DZ5BEJ_cjs.inBounds(m, row, col)) {
|
|
2526
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2521
2527
|
"MATRIX_INDEX_OUT_OF_BOUNDS",
|
|
2522
2528
|
`[${row}, ${col}] is out of bounds for a ${m.rows}x${m.cols} matrix.`
|
|
2523
2529
|
));
|
|
2524
2530
|
break;
|
|
2525
2531
|
}
|
|
2526
|
-
const cell =
|
|
2527
|
-
stack.push(
|
|
2532
|
+
const cell = chunkA2DZ5BEJ_cjs.matAt(m, row, col);
|
|
2533
|
+
stack.push(chunkA2DZ5BEJ_cjs.matrixEntryToValue(cell));
|
|
2528
2534
|
break;
|
|
2529
2535
|
}
|
|
2530
2536
|
case 156 /* RANGE_NEW */: {
|
|
2531
2537
|
const maxVal = safePop(stack), minVal = safePop(stack);
|
|
2532
|
-
const rangeFault =
|
|
2538
|
+
const rangeFault = chunkIT74O4BE_cjs.faultedOperand(minVal, maxVal);
|
|
2533
2539
|
if (rangeFault) {
|
|
2534
2540
|
stack.push(rangeFault);
|
|
2535
2541
|
break;
|
|
2536
2542
|
}
|
|
2537
2543
|
if (minVal.type !== 0 /* Number */ || maxVal.type !== 0 /* Number */) {
|
|
2538
|
-
stack.push(
|
|
2544
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("INVALID_RANGE_BOUND", `A range's bounds must be plain numbers (e.g. "0:3").`));
|
|
2539
2545
|
break;
|
|
2540
2546
|
}
|
|
2541
2547
|
const min = minVal.value;
|
|
2542
2548
|
const max = maxVal.value;
|
|
2543
2549
|
if (!Number.isInteger(min) || !Number.isInteger(max)) {
|
|
2544
|
-
stack.push(
|
|
2550
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("NON_INTEGER_RANGE_BOUND", `A range's bounds must be whole numbers, got "${min}:${max}".`));
|
|
2545
2551
|
break;
|
|
2546
2552
|
}
|
|
2547
2553
|
if (min > max) {
|
|
2548
|
-
stack.push(
|
|
2554
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2549
2555
|
"DESCENDING_RANGE",
|
|
2550
2556
|
`A range's min (${min}) cannot be greater than its max (${max}) \u2014 did you mean "${max}:${min}"?`
|
|
2551
2557
|
));
|
|
2552
2558
|
break;
|
|
2553
2559
|
}
|
|
2554
|
-
stack.push(
|
|
2560
|
+
stack.push(chunkIT74O4BE_cjs.rangeValue(min, max));
|
|
2555
2561
|
break;
|
|
2556
2562
|
}
|
|
2557
2563
|
case 155 /* MAT_SLICE */: {
|
|
2558
2564
|
const colRangeVal = safePop(stack), rowRangeVal = safePop(stack), matrixVal = safePop(stack);
|
|
2559
|
-
const sliceFault =
|
|
2565
|
+
const sliceFault = chunkIT74O4BE_cjs.faultedOperand(matrixVal, rowRangeVal, colRangeVal);
|
|
2560
2566
|
if (sliceFault) {
|
|
2561
2567
|
stack.push(sliceFault);
|
|
2562
2568
|
break;
|
|
2563
2569
|
}
|
|
2564
2570
|
if (matrixVal.type !== 7 /* Matrix */) {
|
|
2565
|
-
stack.push(
|
|
2571
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("MATRIX_INDEX_NOT_A_MATRIX", `Cannot slice a non-matrix value with "[...]".`));
|
|
2566
2572
|
break;
|
|
2567
2573
|
}
|
|
2568
2574
|
if (rowRangeVal.type !== 8 /* Range */ || colRangeVal.type !== 8 /* Range */) {
|
|
2569
|
-
stack.push(
|
|
2575
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("INVALID_MATRIX_SLICE_BOUND", `Matrix slicing needs range bounds (e.g. "a[0:1, 1:2]").`));
|
|
2570
2576
|
break;
|
|
2571
2577
|
}
|
|
2572
2578
|
const m = matrixVal.value;
|
|
2573
2579
|
const rowRange = rowRangeVal.value;
|
|
2574
2580
|
const colRange = colRangeVal.value;
|
|
2575
2581
|
if (rowRange.min < 0 || rowRange.max >= m.rows || colRange.min < 0 || colRange.max >= m.cols) {
|
|
2576
|
-
stack.push(
|
|
2582
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2577
2583
|
"MATRIX_INDEX_OUT_OF_BOUNDS",
|
|
2578
2584
|
`Slice [${rowRange.min}:${rowRange.max}, ${colRange.min}:${colRange.max}] is out of bounds for a ${m.rows}x${m.cols} matrix.`
|
|
2579
2585
|
));
|
|
@@ -2581,13 +2587,13 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2581
2587
|
}
|
|
2582
2588
|
const newRows = rowRange.max - rowRange.min + 1;
|
|
2583
2589
|
const newCols = colRange.max - colRange.min + 1;
|
|
2584
|
-
const data =
|
|
2590
|
+
const data = chunkIT74O4BE_cjs.checkedArray(newRows * newCols, "matrix cells");
|
|
2585
2591
|
for (let r = 0; r < newRows; r++) {
|
|
2586
2592
|
for (let c = 0; c < newCols; c++) {
|
|
2587
|
-
data[r + c * newRows] =
|
|
2593
|
+
data[r + c * newRows] = chunkA2DZ5BEJ_cjs.matAt(m, rowRange.min + r, colRange.min + c);
|
|
2588
2594
|
}
|
|
2589
2595
|
}
|
|
2590
|
-
stack.push(
|
|
2596
|
+
stack.push(chunkIT74O4BE_cjs.matrixValue(newRows, newCols, data));
|
|
2591
2597
|
break;
|
|
2592
2598
|
}
|
|
2593
2599
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -2610,7 +2616,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2610
2616
|
if (kind === 0) {
|
|
2611
2617
|
const def = anonymousBodies?.[ref];
|
|
2612
2618
|
if (!def) {
|
|
2613
|
-
throw
|
|
2619
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.internal(
|
|
2614
2620
|
"INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
2615
2621
|
`Internal error: MAP_INVOKE referenced missing anonymous body index ${ref}`,
|
|
2616
2622
|
{ ref }
|
|
@@ -2622,11 +2628,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2622
2628
|
const name = pooledString(strings, ref, op);
|
|
2623
2629
|
const fn = vm.getUserFunction(name);
|
|
2624
2630
|
if (!fn) {
|
|
2625
|
-
stack.push(
|
|
2631
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("UNDEFINED_FUNCTION", `map: undefined function "${name}"`));
|
|
2626
2632
|
break;
|
|
2627
2633
|
}
|
|
2628
2634
|
if (fn.params.length !== collectionCount) {
|
|
2629
|
-
stack.push(
|
|
2635
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2630
2636
|
"FUNCTION_ARITY_MISMATCH",
|
|
2631
2637
|
`map: "${name}" expects ${fn.params.length} argument(s) but ${collectionCount} collection(s) were given`
|
|
2632
2638
|
));
|
|
@@ -2639,16 +2645,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2639
2645
|
const cellArrays = new Array(collectionCount);
|
|
2640
2646
|
let mapEarlyError;
|
|
2641
2647
|
for (let i = 0; i < collectionCount; i++) {
|
|
2642
|
-
const resolved =
|
|
2648
|
+
const resolved = chunkA2DZ5BEJ_cjs.collectionToValues(rawCollections[i], vm.getMaxCollectionSize());
|
|
2643
2649
|
if (!Array.isArray(resolved)) {
|
|
2644
2650
|
mapEarlyError = resolved;
|
|
2645
2651
|
break;
|
|
2646
2652
|
}
|
|
2647
|
-
|
|
2653
|
+
chunkIT74O4BE_cjs.chargeAllocation(resolved.length, "collection elements");
|
|
2648
2654
|
if (collectionLength === -1) {
|
|
2649
2655
|
collectionLength = resolved.length;
|
|
2650
2656
|
} else if (resolved.length !== collectionLength) {
|
|
2651
|
-
mapEarlyError =
|
|
2657
|
+
mapEarlyError = chunkIT74O4BE_cjs.errorValue(
|
|
2652
2658
|
"MAP_COLLECTION_LENGTH_MISMATCH",
|
|
2653
2659
|
`map: all collections must have the same length (got ${collectionLength} and ${resolved.length}).`
|
|
2654
2660
|
);
|
|
@@ -2660,13 +2666,13 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2660
2666
|
stack.push(mapEarlyError);
|
|
2661
2667
|
break;
|
|
2662
2668
|
}
|
|
2663
|
-
const resultData =
|
|
2669
|
+
const resultData = chunkIT74O4BE_cjs.checkedArray(collectionLength, "matrix cells");
|
|
2664
2670
|
let mapError;
|
|
2665
2671
|
for (let i = 0; i < collectionLength; i++) {
|
|
2666
2672
|
const args = new Array(collectionCount);
|
|
2667
2673
|
for (let j = 0; j < collectionCount; j++) args[j] = cellArrays[j][i];
|
|
2668
|
-
const resultVal = kind === 1 ?
|
|
2669
|
-
const resultFault =
|
|
2674
|
+
const resultVal = kind === 1 ? chunkFR7RNOPT_cjs.builtinFunctions[ref]?.(args) ?? chunkIT74O4BE_cjs.errorValue("UNKNOWN_BUILTIN_FUNCTION", `map: unknown builtin function index ${ref}`) : invokeFrameBody(paramNames, program, args, vm, pipeline, expression, context, !!symbolicTolerant);
|
|
2675
|
+
const resultFault = chunkIT74O4BE_cjs.faultedOperand(resultVal);
|
|
2670
2676
|
if (resultFault) {
|
|
2671
2677
|
mapError = resultFault;
|
|
2672
2678
|
break;
|
|
@@ -2680,9 +2686,9 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2680
2686
|
const firstCollection = rawCollections[0];
|
|
2681
2687
|
const sourceShape = firstCollection?.type === 7 /* Matrix */ ? firstCollection.value : void 0;
|
|
2682
2688
|
if (sourceShape && sourceShape.rows * sourceShape.cols === collectionLength) {
|
|
2683
|
-
stack.push(
|
|
2689
|
+
stack.push(chunkIT74O4BE_cjs.matrixValue(sourceShape.rows, sourceShape.cols, resultData));
|
|
2684
2690
|
} else {
|
|
2685
|
-
stack.push(
|
|
2691
|
+
stack.push(chunkIT74O4BE_cjs.matrixValue(1, collectionLength, resultData));
|
|
2686
2692
|
}
|
|
2687
2693
|
break;
|
|
2688
2694
|
}
|
|
@@ -2698,7 +2704,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2698
2704
|
if (kind === 0) {
|
|
2699
2705
|
const def = anonymousBodies?.[ref];
|
|
2700
2706
|
if (!def) {
|
|
2701
|
-
throw
|
|
2707
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.internal(
|
|
2702
2708
|
"INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
2703
2709
|
`Internal error: REDUCE_INVOKE referenced missing anonymous body index ${ref}`,
|
|
2704
2710
|
{ ref }
|
|
@@ -2710,11 +2716,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2710
2716
|
const name = pooledString(strings, ref, op);
|
|
2711
2717
|
const fn = vm.getUserFunction(name);
|
|
2712
2718
|
if (!fn) {
|
|
2713
|
-
stack.push(
|
|
2719
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("UNDEFINED_FUNCTION", `reduce: undefined function "${name}"`));
|
|
2714
2720
|
break;
|
|
2715
2721
|
}
|
|
2716
2722
|
if (fn.params.length !== 2) {
|
|
2717
|
-
stack.push(
|
|
2723
|
+
stack.push(chunkIT74O4BE_cjs.errorValue(
|
|
2718
2724
|
"FUNCTION_ARITY_MISMATCH",
|
|
2719
2725
|
`reduce: "${name}" must take exactly 2 arguments (accumulator, element), got ${fn.params.length}`
|
|
2720
2726
|
));
|
|
@@ -2723,16 +2729,16 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2723
2729
|
paramNames = fn.params;
|
|
2724
2730
|
program = fn.program;
|
|
2725
2731
|
}
|
|
2726
|
-
const cells =
|
|
2732
|
+
const cells = chunkA2DZ5BEJ_cjs.collectionToValues(collectionVal, vm.getMaxCollectionSize());
|
|
2727
2733
|
if (!Array.isArray(cells)) {
|
|
2728
2734
|
stack.push(cells);
|
|
2729
2735
|
break;
|
|
2730
2736
|
}
|
|
2731
|
-
|
|
2737
|
+
chunkIT74O4BE_cjs.chargeAllocation(cells.length, "collection elements");
|
|
2732
2738
|
let acc;
|
|
2733
2739
|
let startIdx;
|
|
2734
2740
|
if (initialVal !== void 0) {
|
|
2735
|
-
const initialFault =
|
|
2741
|
+
const initialFault = chunkIT74O4BE_cjs.faultedOperand(initialVal);
|
|
2736
2742
|
if (initialFault) {
|
|
2737
2743
|
stack.push(initialFault);
|
|
2738
2744
|
break;
|
|
@@ -2741,7 +2747,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2741
2747
|
startIdx = 0;
|
|
2742
2748
|
} else {
|
|
2743
2749
|
if (cells.length === 0) {
|
|
2744
|
-
stack.push(
|
|
2750
|
+
stack.push(chunkIT74O4BE_cjs.errorValue("REDUCE_EMPTY_COLLECTION", `reduce: cannot reduce an empty collection without an initial value.`));
|
|
2745
2751
|
break;
|
|
2746
2752
|
}
|
|
2747
2753
|
acc = cells[0];
|
|
@@ -2750,8 +2756,8 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2750
2756
|
let reduceError;
|
|
2751
2757
|
for (let i = startIdx; i < cells.length; i++) {
|
|
2752
2758
|
const args = [acc, cells[i]];
|
|
2753
|
-
const resultVal = kind === 1 ?
|
|
2754
|
-
const stepFault =
|
|
2759
|
+
const resultVal = kind === 1 ? chunkFR7RNOPT_cjs.builtinFunctions[ref]?.(args) ?? chunkIT74O4BE_cjs.errorValue("UNKNOWN_BUILTIN_FUNCTION", `reduce: unknown builtin function index ${ref}`) : invokeFrameBody(paramNames, program, args, vm, pipeline, expression, context, !!symbolicTolerant);
|
|
2760
|
+
const stepFault = chunkIT74O4BE_cjs.faultedOperand(resultVal);
|
|
2755
2761
|
if (stepFault) {
|
|
2756
2762
|
reduceError = stepFault;
|
|
2757
2763
|
break;
|
|
@@ -2772,7 +2778,7 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2772
2778
|
const ref = operandByte(opcodes, ip++, op, "body reference");
|
|
2773
2779
|
const def = anonymousBodies?.[ref];
|
|
2774
2780
|
if (!def) {
|
|
2775
|
-
throw
|
|
2781
|
+
throw chunkMIGXCBXT_cjs.ErrorFactory.internal(
|
|
2776
2782
|
"INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
2777
2783
|
`Internal error: BIND_UNKNOWN referenced missing anonymous body index ${ref}`,
|
|
2778
2784
|
{ ref }
|
|
@@ -2784,11 +2790,11 @@ function executeBytecode(bytecode, vm, pipeline, expression, context, symbolicTo
|
|
|
2784
2790
|
}
|
|
2785
2791
|
}
|
|
2786
2792
|
const fallback = safePop(stack);
|
|
2787
|
-
return { type: "value", value: hasArena ?
|
|
2793
|
+
return { type: "value", value: hasArena ? chunkIT74O4BE_cjs.persistentValue(fallback) : fallback };
|
|
2788
2794
|
} catch (e) {
|
|
2789
|
-
return { type: "error", error:
|
|
2795
|
+
return { type: "error", error: chunkMIGXCBXT_cjs.normalizeUnknownError(e) };
|
|
2790
2796
|
} finally {
|
|
2791
|
-
|
|
2797
|
+
chunkIT74O4BE_cjs.endEvaluation();
|
|
2792
2798
|
}
|
|
2793
2799
|
}
|
|
2794
2800
|
|
|
@@ -2796,5 +2802,5 @@ exports.DependencyGraph = DependencyGraph;
|
|
|
2796
2802
|
exports.ScopeManager = ScopeManager;
|
|
2797
2803
|
exports.createVM = createVM;
|
|
2798
2804
|
exports.executeBytecode = executeBytecode;
|
|
2799
|
-
//# sourceMappingURL=chunk-
|
|
2800
|
-
//# sourceMappingURL=chunk-
|
|
2805
|
+
//# sourceMappingURL=chunk-C2OMO3WN.cjs.map
|
|
2806
|
+
//# sourceMappingURL=chunk-C2OMO3WN.cjs.map
|