@neocompose/cli 0.87.1 → 0.88.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/CHANGELOG.md +18 -0
- package/README.md +14 -0
- package/dist/neo-runtime.mjs +3789 -1141
- package/dist/test-worker.mjs +2450 -116
- package/package.json +1 -1
- package/skills/neocompose-cli/SKILL.md +95 -279
- package/skills/neocompose-cli/references/cli-development.md +101 -117
- package/skills/neocompose-cli/references/declarations/annotations-and-storage.md +112 -0
- package/skills/neocompose-cli/references/declarations/constructors.md +164 -0
- package/skills/neocompose-cli/references/declarations/declarations.md +103 -0
- package/skills/neocompose-cli/references/declarations/initializers.md +100 -0
- package/skills/neocompose-cli/references/declarations/member-kinds.md +107 -0
- package/skills/neocompose-cli/references/declarations/overloads.md +50 -0
- package/skills/neocompose-cli/references/dialogues.md +145 -0
- package/skills/neocompose-cli/references/neoscript/collections.md +98 -0
- package/skills/neocompose-cli/references/neoscript/control-flow.md +123 -0
- package/skills/neocompose-cli/references/neoscript/delegates-and-listeners.md +107 -0
- package/skills/neocompose-cli/references/neoscript/math-and-random.md +114 -0
- package/skills/neocompose-cli/references/neoscript/neoscript.md +112 -0
- package/skills/neocompose-cli/references/neoscript/strings.md +47 -0
- package/skills/neocompose-cli/references/neoscript/testing-and-migrations.md +73 -0
- package/skills/neocompose-cli/references/neoscript/types-and-narrowing.md +111 -0
- package/skills/neocompose-cli/references/sync/branches-and-history.md +69 -0
- package/skills/neocompose-cli/references/sync/conflicts-and-recovery.md +68 -0
- package/skills/neocompose-cli/references/sync/sync.md +96 -0
- package/skills/neocompose-cli/references/sync/unity-export.md +47 -0
- package/skills/neocompose-cli/references/values/defaults-and-localization.md +86 -0
- package/skills/neocompose-cli/references/values/files.md +71 -0
- package/skills/neocompose-cli/references/values/identities.md +97 -0
- package/skills/neocompose-cli/references/values/references.md +151 -0
- package/skills/neocompose-cli/references/values/values.md +110 -0
- package/skills/neocompose-cli/references/world/animation.md +133 -0
- package/skills/neocompose-cli/references/world/grids-and-cell-patterns.md +55 -0
- package/skills/neocompose-cli/references/world/variants.md +112 -0
- package/skills/neocompose-cli/references/world/world.md +105 -0
- package/skills/neocompose-cli/references/animation-and-world-authoring.md +0 -582
- package/skills/neocompose-cli/references/commands-and-sync.md +0 -408
- package/skills/neocompose-cli/references/declarations-and-construction.md +0 -773
- package/skills/neocompose-cli/references/neoscript.md +0 -990
- package/skills/neocompose-cli/references/values-identities-and-references.md +0 -421
package/dist/test-worker.mjs
CHANGED
|
@@ -879,6 +879,55 @@ var require_ignore = __commonJS({
|
|
|
879
879
|
// src/test-worker.ts
|
|
880
880
|
import { parentPort } from "node:worker_threads";
|
|
881
881
|
|
|
882
|
+
// src/workspace-lock.ts
|
|
883
|
+
import { join } from "node:path";
|
|
884
|
+
|
|
885
|
+
// src/ui.ts
|
|
886
|
+
var colorEnabled = process.stdout.isTTY === true && process.env.NO_COLOR === void 0 && process.env.TERM !== "dumb";
|
|
887
|
+
function paint(open, close) {
|
|
888
|
+
if (!colorEnabled) return (text) => text;
|
|
889
|
+
return (text) => `\x1B[${open}m${text}\x1B[${close}m`;
|
|
890
|
+
}
|
|
891
|
+
var color = {
|
|
892
|
+
bold: paint(1, 22),
|
|
893
|
+
dim: paint(2, 22),
|
|
894
|
+
red: paint(31, 39),
|
|
895
|
+
green: paint(32, 39),
|
|
896
|
+
yellow: paint(33, 39),
|
|
897
|
+
blue: paint(34, 39),
|
|
898
|
+
magenta: paint(35, 39),
|
|
899
|
+
cyan: paint(36, 39)
|
|
900
|
+
};
|
|
901
|
+
var sym = {
|
|
902
|
+
ok: color.green("\u2714"),
|
|
903
|
+
fail: color.red("\u2716"),
|
|
904
|
+
warn: color.yellow("\u25B2"),
|
|
905
|
+
info: color.cyan("\u25CF"),
|
|
906
|
+
arrow: color.dim("\u2192"),
|
|
907
|
+
branch: color.magenta("\u2387"),
|
|
908
|
+
tag: color.cyan("\u2301"),
|
|
909
|
+
pointer: color.cyan("\u276F")
|
|
910
|
+
};
|
|
911
|
+
var CHANGE_KIND_COLOR = {
|
|
912
|
+
create: color.green,
|
|
913
|
+
update: color.yellow,
|
|
914
|
+
delete: color.red
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
// src/workspace-lock.ts
|
|
918
|
+
var LOCK_FILE = join(".neo", "workspace.lock");
|
|
919
|
+
|
|
920
|
+
// src/export-state.ts
|
|
921
|
+
import { join as join2 } from "node:path";
|
|
922
|
+
|
|
923
|
+
// ../packages/manifest/src/value-comparison.ts
|
|
924
|
+
function isObjectRecord(value) {
|
|
925
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// src/export-state.ts
|
|
929
|
+
var EXPORT_STATE_FILE = join2(".neo", "export.json");
|
|
930
|
+
|
|
882
931
|
// ../node_modules/uuid/dist-node/regex.js
|
|
883
932
|
var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
884
933
|
|
|
@@ -2627,6 +2676,86 @@ var NEOSCRIPT_BUILTIN_TYPE_SYMBOLS = [
|
|
|
2627
2676
|
["x"],
|
|
2628
2677
|
"Returns the square root. Accepts int or float and returns float; does not accept decimal."
|
|
2629
2678
|
),
|
|
2679
|
+
mathFunction(
|
|
2680
|
+
"Pow",
|
|
2681
|
+
["x", "y"],
|
|
2682
|
+
"Returns x raised to y. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2683
|
+
),
|
|
2684
|
+
mathFunction(
|
|
2685
|
+
"Exp",
|
|
2686
|
+
["x"],
|
|
2687
|
+
"Returns e raised to x. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2688
|
+
),
|
|
2689
|
+
mathFunction(
|
|
2690
|
+
"Log",
|
|
2691
|
+
["x"],
|
|
2692
|
+
"Returns the natural logarithm. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2693
|
+
),
|
|
2694
|
+
mathFunction(
|
|
2695
|
+
"Log10",
|
|
2696
|
+
["x"],
|
|
2697
|
+
"Returns the base-10 logarithm. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2698
|
+
),
|
|
2699
|
+
mathFunction(
|
|
2700
|
+
"Sin",
|
|
2701
|
+
["x"],
|
|
2702
|
+
"Returns the sine of an angle in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2703
|
+
),
|
|
2704
|
+
mathFunction(
|
|
2705
|
+
"Cos",
|
|
2706
|
+
["x"],
|
|
2707
|
+
"Returns the cosine of an angle in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2708
|
+
),
|
|
2709
|
+
mathFunction(
|
|
2710
|
+
"Tan",
|
|
2711
|
+
["x"],
|
|
2712
|
+
"Returns the tangent of an angle in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2713
|
+
),
|
|
2714
|
+
mathFunction(
|
|
2715
|
+
"Asin",
|
|
2716
|
+
["x"],
|
|
2717
|
+
"Returns the inverse sine in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2718
|
+
),
|
|
2719
|
+
mathFunction(
|
|
2720
|
+
"Acos",
|
|
2721
|
+
["x"],
|
|
2722
|
+
"Returns the inverse cosine in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2723
|
+
),
|
|
2724
|
+
mathFunction(
|
|
2725
|
+
"Atan",
|
|
2726
|
+
["x"],
|
|
2727
|
+
"Returns the inverse tangent in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2728
|
+
),
|
|
2729
|
+
mathFunction(
|
|
2730
|
+
"Atan2",
|
|
2731
|
+
["y", "x"],
|
|
2732
|
+
"Returns the signed angle of x,y in radians. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2733
|
+
),
|
|
2734
|
+
mathFunction(
|
|
2735
|
+
"Lerp",
|
|
2736
|
+
["a", "b", "t"],
|
|
2737
|
+
"Interpolates from a to b with t clamped to [0,1]. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2738
|
+
),
|
|
2739
|
+
mathFunction(
|
|
2740
|
+
"InverseLerp",
|
|
2741
|
+
["a", "b", "value"],
|
|
2742
|
+
"Returns the clamped normalized position of value between a and b; equal endpoints return zero. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2743
|
+
),
|
|
2744
|
+
mathFunction(
|
|
2745
|
+
"MoveTowards",
|
|
2746
|
+
["current", "target", "maxDelta"],
|
|
2747
|
+
"Moves toward target by maxDelta. A negative maxDelta moves away. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2748
|
+
),
|
|
2749
|
+
mathFunction(
|
|
2750
|
+
"Repeat",
|
|
2751
|
+
["t", "length"],
|
|
2752
|
+
"Wraps t using a finite positive length. Negative t wraps with floor. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2753
|
+
),
|
|
2754
|
+
mathFunction(
|
|
2755
|
+
"PingPong",
|
|
2756
|
+
["t", "length"],
|
|
2757
|
+
"Reflects t between zero and a finite positive length. Accepts int or float, rounds inputs to float32, and returns float."
|
|
2758
|
+
),
|
|
2630
2759
|
{
|
|
2631
2760
|
...property(
|
|
2632
2761
|
"Math",
|
|
@@ -3815,29 +3944,58 @@ function isNSFunctionDecimalOp(value) {
|
|
|
3815
3944
|
const digits = info.digitsPointer;
|
|
3816
3945
|
return digits === void 0 || isNSPointer(digits);
|
|
3817
3946
|
}
|
|
3818
|
-
var
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3947
|
+
var NS_MATH_OP_ARITIES = {
|
|
3948
|
+
min: 2,
|
|
3949
|
+
max: 2,
|
|
3950
|
+
clamp: 3,
|
|
3951
|
+
round: 1,
|
|
3952
|
+
floor: 1,
|
|
3953
|
+
ceiling: 1,
|
|
3954
|
+
truncate: 1,
|
|
3955
|
+
abs: 1,
|
|
3956
|
+
sign: 1,
|
|
3957
|
+
sqrt: 1,
|
|
3958
|
+
pow: 2,
|
|
3959
|
+
exp: 1,
|
|
3960
|
+
log: 1,
|
|
3961
|
+
log10: 1,
|
|
3962
|
+
sin: 1,
|
|
3963
|
+
cos: 1,
|
|
3964
|
+
tan: 1,
|
|
3965
|
+
asin: 1,
|
|
3966
|
+
acos: 1,
|
|
3967
|
+
atan: 1,
|
|
3968
|
+
atan2: 2,
|
|
3969
|
+
lerp: 3,
|
|
3970
|
+
inverselerp: 3,
|
|
3971
|
+
movetowards: 3,
|
|
3972
|
+
repeat: 2,
|
|
3973
|
+
pingpong: 2
|
|
3974
|
+
};
|
|
3830
3975
|
function isNSFunctionMathOp(value) {
|
|
3831
3976
|
const v = value;
|
|
3832
3977
|
if (v?.type !== "mathOp" /* mathOp */) return false;
|
|
3833
3978
|
const info = v.info;
|
|
3834
3979
|
if (typeof info !== "object" || info === null) return false;
|
|
3835
|
-
if (!
|
|
3980
|
+
if (!Object.hasOwn(NS_MATH_OP_ARITIES, info.op)) return false;
|
|
3836
3981
|
const args = info.argPointers;
|
|
3837
3982
|
if (!Array.isArray(args)) return false;
|
|
3983
|
+
if (args.length !== NS_MATH_OP_ARITIES[info.op]) return false;
|
|
3838
3984
|
if (!args.every(isNSPointer)) return false;
|
|
3839
3985
|
const decimal = info.decimal;
|
|
3840
|
-
|
|
3986
|
+
if (decimal === void 0) return true;
|
|
3987
|
+
if (decimal !== true) return false;
|
|
3988
|
+
return [
|
|
3989
|
+
"min",
|
|
3990
|
+
"max",
|
|
3991
|
+
"clamp",
|
|
3992
|
+
"round",
|
|
3993
|
+
"floor",
|
|
3994
|
+
"ceiling",
|
|
3995
|
+
"truncate",
|
|
3996
|
+
"abs",
|
|
3997
|
+
"sign"
|
|
3998
|
+
].includes(info.op);
|
|
3841
3999
|
}
|
|
3842
4000
|
var NS_TEXT_STRING_OPS = [
|
|
3843
4001
|
"length",
|
|
@@ -4177,7 +4335,8 @@ function isNSInstructionFor(value) {
|
|
|
4177
4335
|
if (instruction?.type !== "for" /* for */) return false;
|
|
4178
4336
|
if (!isNSVariable(instruction.initializer)) return false;
|
|
4179
4337
|
if (!isNSBooleanExpression(instruction.condition)) return false;
|
|
4180
|
-
if (!isNSInstructionAssign(instruction.iterator)
|
|
4338
|
+
if (!isNSInstructionAssign(instruction.iterator) && !isNSInstructionFunctionCall(instruction.iterator))
|
|
4339
|
+
return false;
|
|
4181
4340
|
return isNSInstructions(instruction.instructions);
|
|
4182
4341
|
}
|
|
4183
4342
|
function isNSInstructionForEach(value) {
|
|
@@ -16495,11 +16654,6 @@ function referenceReadTypeInfo(reference) {
|
|
|
16495
16654
|
};
|
|
16496
16655
|
}
|
|
16497
16656
|
|
|
16498
|
-
// ../packages/manifest/src/value-comparison.ts
|
|
16499
|
-
function isObjectRecord(value) {
|
|
16500
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16501
|
-
}
|
|
16502
|
-
|
|
16503
16657
|
// ../packages/neoscript-runtime/src/values/canonical-json.ts
|
|
16504
16658
|
function canonicalJsonStringify(value) {
|
|
16505
16659
|
return JSON.stringify(toCanonicalJsonValue(value));
|
|
@@ -17937,6 +18091,7 @@ var NSGetterRuntimeError = class _NSGetterRuntimeError extends Error {
|
|
|
17937
18091
|
node: { writable: true, value: void 0 },
|
|
17938
18092
|
callerNode: { writable: true, value: void 0 },
|
|
17939
18093
|
initializerValueId: { writable: true, value: void 0 },
|
|
18094
|
+
provisionalRandomFailure: { writable: true, value: void 0 },
|
|
17940
18095
|
sourceOwnerId: { writable: true, value: void 0 },
|
|
17941
18096
|
attachedValueId: { writable: true, value: void 0 }
|
|
17942
18097
|
});
|
|
@@ -17961,6 +18116,1894 @@ var UncompiledInitializerRuntimeError = class extends NSGetterRuntimeError {
|
|
|
17961
18116
|
valueId;
|
|
17962
18117
|
};
|
|
17963
18118
|
|
|
18119
|
+
// ../packages/neoscript-language/src/random-contract.ts
|
|
18120
|
+
var NEO_RANDOM_IDS = {
|
|
18121
|
+
class: "system_75b4633d-65d0-5da1-ac09-e7c2de0cd102",
|
|
18122
|
+
constructor: "system_62be2a68-1c61-5be7-ac2e-13fa8e77eb26",
|
|
18123
|
+
Value: "system_135e16a9-1996-5e5b-9c2a-730b2896a2cd",
|
|
18124
|
+
RangeInt: "system_60709cd5-8924-5a8c-93e5-482c1e678cdb",
|
|
18125
|
+
RangeFloat: "system_5b15f87c-3ea4-57d8-9156-f12366b73b3b",
|
|
18126
|
+
Seed: "system_e4f25ff7-8b23-5c07-8bcc-6e112fd75575",
|
|
18127
|
+
GetSeed: "system_9d442bde-25e8-51af-baab-08e99947edcd",
|
|
18128
|
+
SetSeed: "system_1eea1de7-5a9b-55e6-8d59-5d27f829d4db",
|
|
18129
|
+
ValidateSeed: "system_a99e8b1e-c2c8-5a49-8497-a4ac9260702c"
|
|
18130
|
+
};
|
|
18131
|
+
var NEO_RANDOM_NATIVE_MEMBER_IDS = /* @__PURE__ */ new Set([
|
|
18132
|
+
NEO_RANDOM_IDS.Value,
|
|
18133
|
+
NEO_RANDOM_IDS.RangeInt,
|
|
18134
|
+
NEO_RANDOM_IDS.RangeFloat,
|
|
18135
|
+
NEO_RANDOM_IDS.GetSeed,
|
|
18136
|
+
NEO_RANDOM_IDS.SetSeed,
|
|
18137
|
+
NEO_RANDOM_IDS.ValidateSeed
|
|
18138
|
+
]);
|
|
18139
|
+
function isNeoRandomSharedMethod(classId, memberId) {
|
|
18140
|
+
return classId === NEO_RANDOM_IDS.class && (memberId === NEO_RANDOM_IDS.Value || memberId === NEO_RANDOM_IDS.RangeInt || memberId === NEO_RANDOM_IDS.RangeFloat);
|
|
18141
|
+
}
|
|
18142
|
+
|
|
18143
|
+
// ../packages/neoscript-runtime/src/neoscript/NeoRandom.ts
|
|
18144
|
+
function argumentError(message) {
|
|
18145
|
+
throw new NSGetterRuntimeError(message, {
|
|
18146
|
+
errorClassId: NEO_ERROR_CLASS_IDS.NeoArgumentError
|
|
18147
|
+
});
|
|
18148
|
+
}
|
|
18149
|
+
function entropySeed() {
|
|
18150
|
+
if (typeof globalThis.crypto?.getRandomValues === "function") {
|
|
18151
|
+
return globalThis.crypto.getRandomValues(new Uint32Array(1))[0];
|
|
18152
|
+
}
|
|
18153
|
+
return Math.floor(Math.random() * 4294967296);
|
|
18154
|
+
}
|
|
18155
|
+
function validateRandomSeed(seed) {
|
|
18156
|
+
if (!Number.isSafeInteger(seed))
|
|
18157
|
+
argumentError("NeoRandom seed must be a safe integer.");
|
|
18158
|
+
}
|
|
18159
|
+
var NeoRandom = class _NeoRandom {
|
|
18160
|
+
constructor(seed = entropySeed(), onSeedWrite) {
|
|
18161
|
+
this.onSeedWrite = onSeedWrite;
|
|
18162
|
+
if (typeof seed === "string") {
|
|
18163
|
+
this.identity = seed;
|
|
18164
|
+
this.contentScope = true;
|
|
18165
|
+
} else this.resetSeed(seed);
|
|
18166
|
+
}
|
|
18167
|
+
onSeedWrite;
|
|
18168
|
+
x = 0;
|
|
18169
|
+
y = 0;
|
|
18170
|
+
z = 0;
|
|
18171
|
+
w = 0;
|
|
18172
|
+
identity;
|
|
18173
|
+
assignedSeed = 0;
|
|
18174
|
+
instances;
|
|
18175
|
+
contentScope = false;
|
|
18176
|
+
/** Monotonic draws, including isolated content evaluations; used by diagnostics. */
|
|
18177
|
+
draws = 0;
|
|
18178
|
+
get drawCount() {
|
|
18179
|
+
return this.draws;
|
|
18180
|
+
}
|
|
18181
|
+
get seed() {
|
|
18182
|
+
this.initializeIdentity();
|
|
18183
|
+
return this.assignedSeed;
|
|
18184
|
+
}
|
|
18185
|
+
set seed(seed) {
|
|
18186
|
+
this.resetSeed(seed);
|
|
18187
|
+
this.noteSeedWrite(NEO_RANDOM_IDS.Seed);
|
|
18188
|
+
}
|
|
18189
|
+
resetSeed(seed) {
|
|
18190
|
+
validateRandomSeed(seed);
|
|
18191
|
+
this.assignedSeed = seed;
|
|
18192
|
+
this.identity = void 0;
|
|
18193
|
+
this.x = seed >>> 0;
|
|
18194
|
+
this.y = Math.imul(1812433253, this.x ^ this.x >>> 30) + 1 >>> 0;
|
|
18195
|
+
this.z = Math.imul(1812433253, this.y ^ this.y >>> 30) + 2 >>> 0;
|
|
18196
|
+
this.w = Math.imul(1812433253, this.z ^ this.z >>> 30) + 3 >>> 0;
|
|
18197
|
+
}
|
|
18198
|
+
/** Install a lazy content seed, preserving even an uninitialized caller frame. */
|
|
18199
|
+
withIdentity(identity2, evaluate) {
|
|
18200
|
+
const pending = this.identity;
|
|
18201
|
+
const seed = this.assignedSeed;
|
|
18202
|
+
const instances = this.instances;
|
|
18203
|
+
const contentScope = this.contentScope;
|
|
18204
|
+
this.instances = void 0;
|
|
18205
|
+
this.contentScope = true;
|
|
18206
|
+
const x = this.x, y = this.y, z = this.z, w = this.w;
|
|
18207
|
+
this.identity = identity2;
|
|
18208
|
+
try {
|
|
18209
|
+
return evaluate();
|
|
18210
|
+
} finally {
|
|
18211
|
+
this.identity = pending;
|
|
18212
|
+
this.assignedSeed = seed;
|
|
18213
|
+
this.instances = instances;
|
|
18214
|
+
this.contentScope = contentScope;
|
|
18215
|
+
this.x = x;
|
|
18216
|
+
this.y = y;
|
|
18217
|
+
this.z = z;
|
|
18218
|
+
this.w = w;
|
|
18219
|
+
}
|
|
18220
|
+
}
|
|
18221
|
+
/** Reuse idle content-replay storage without hashing until the first draw. */
|
|
18222
|
+
deferIdentity(identity2) {
|
|
18223
|
+
this.identity = identity2;
|
|
18224
|
+
this.instances = void 0;
|
|
18225
|
+
this.contentScope = true;
|
|
18226
|
+
}
|
|
18227
|
+
/** Instance lookup retains discarded transient objects only weakly. */
|
|
18228
|
+
findInstance(value, storedId) {
|
|
18229
|
+
const streams = this.instances;
|
|
18230
|
+
if (streams === void 0) return void 0;
|
|
18231
|
+
if (storedId !== void 0) {
|
|
18232
|
+
const stored = streams.stored.get(storedId);
|
|
18233
|
+
if (stored !== void 0) return stored;
|
|
18234
|
+
}
|
|
18235
|
+
const transient = streams.transient.get(value);
|
|
18236
|
+
if (transient !== void 0 && storedId !== void 0) {
|
|
18237
|
+
streams.stored.set(storedId, transient);
|
|
18238
|
+
streams.transient.delete(value);
|
|
18239
|
+
}
|
|
18240
|
+
return transient;
|
|
18241
|
+
}
|
|
18242
|
+
addInstance(value, storedId, seed) {
|
|
18243
|
+
const stream = new _NeoRandom(seed);
|
|
18244
|
+
const streams = this.instances ??= {
|
|
18245
|
+
transient: /* @__PURE__ */ new WeakMap(),
|
|
18246
|
+
stored: /* @__PURE__ */ new Map()
|
|
18247
|
+
};
|
|
18248
|
+
if (storedId === void 0) streams.transient.set(value, stream);
|
|
18249
|
+
else streams.stored.set(storedId, stream);
|
|
18250
|
+
return stream;
|
|
18251
|
+
}
|
|
18252
|
+
clearInstances() {
|
|
18253
|
+
this.instances = void 0;
|
|
18254
|
+
}
|
|
18255
|
+
forgetInstance(id) {
|
|
18256
|
+
if (this.instances?.stored.delete(id))
|
|
18257
|
+
this.noteSeedWrite(`${NEO_RANDOM_IDS.Seed}:${id}`);
|
|
18258
|
+
}
|
|
18259
|
+
get isContentScope() {
|
|
18260
|
+
return this.contentScope;
|
|
18261
|
+
}
|
|
18262
|
+
noteSeedWrite(key) {
|
|
18263
|
+
if (!this.contentScope) this.onSeedWrite?.(key);
|
|
18264
|
+
}
|
|
18265
|
+
initializeIdentity() {
|
|
18266
|
+
if (this.identity !== void 0) {
|
|
18267
|
+
let seed = 2166136261;
|
|
18268
|
+
for (let i = 0; i < this.identity.length; i++) {
|
|
18269
|
+
seed = Math.imul(seed ^ this.identity.charCodeAt(i), 16777619);
|
|
18270
|
+
}
|
|
18271
|
+
this.seed = seed >>> 0;
|
|
18272
|
+
}
|
|
18273
|
+
}
|
|
18274
|
+
nextWord() {
|
|
18275
|
+
this.initializeIdentity();
|
|
18276
|
+
const t = this.x ^ this.x << 11;
|
|
18277
|
+
this.x = this.y;
|
|
18278
|
+
this.y = this.z;
|
|
18279
|
+
this.z = this.w;
|
|
18280
|
+
this.w = (this.w ^ this.w >>> 19 ^ t ^ t >>> 8) >>> 0;
|
|
18281
|
+
this.draws++;
|
|
18282
|
+
return this.w;
|
|
18283
|
+
}
|
|
18284
|
+
value() {
|
|
18285
|
+
return Math.fround((this.nextWord() >>> 8) / 16777215);
|
|
18286
|
+
}
|
|
18287
|
+
rangeInt(min, max) {
|
|
18288
|
+
if (!Number.isInteger(min))
|
|
18289
|
+
argumentError("NeoRandom.Range int min must be an integer.");
|
|
18290
|
+
if (min < -2147483648 || min > 2147483647)
|
|
18291
|
+
argumentError("NeoRandom.Range int min must fit int32.");
|
|
18292
|
+
if (!Number.isInteger(max))
|
|
18293
|
+
argumentError("NeoRandom.Range int max must be an integer.");
|
|
18294
|
+
if (max < -2147483648 || max > 2147483647)
|
|
18295
|
+
argumentError("NeoRandom.Range int max must fit int32.");
|
|
18296
|
+
if (min === max) return min;
|
|
18297
|
+
const width = Math.abs(max - min);
|
|
18298
|
+
const cutoff = Math.floor(4294967296 / width) * width;
|
|
18299
|
+
let word;
|
|
18300
|
+
do {
|
|
18301
|
+
word = this.nextWord();
|
|
18302
|
+
} while (word >= cutoff);
|
|
18303
|
+
const offset = word % width;
|
|
18304
|
+
return min < max ? min + offset : min - offset;
|
|
18305
|
+
}
|
|
18306
|
+
rangeFloat(min, max) {
|
|
18307
|
+
min = Math.fround(min);
|
|
18308
|
+
max = Math.fround(max);
|
|
18309
|
+
if (!Number.isFinite(min))
|
|
18310
|
+
argumentError("NeoRandom.Range float min must be finite.");
|
|
18311
|
+
if (!Number.isFinite(max))
|
|
18312
|
+
argumentError("NeoRandom.Range float max must be finite.");
|
|
18313
|
+
if (min === max) return min;
|
|
18314
|
+
if (min > max) {
|
|
18315
|
+
const previous = min;
|
|
18316
|
+
min = max;
|
|
18317
|
+
max = previous;
|
|
18318
|
+
}
|
|
18319
|
+
const u = this.value();
|
|
18320
|
+
if (u === 0) return min;
|
|
18321
|
+
if (u === 1) return max;
|
|
18322
|
+
const result = Math.fround((1 - u) * min + u * max);
|
|
18323
|
+
if (result < min) return min;
|
|
18324
|
+
if (result > max) return max;
|
|
18325
|
+
return result;
|
|
18326
|
+
}
|
|
18327
|
+
};
|
|
18328
|
+
var contentScratch = /* @__PURE__ */ new WeakMap();
|
|
18329
|
+
function withContentRandomSource(owner, identity2, evaluate) {
|
|
18330
|
+
let random;
|
|
18331
|
+
let idle;
|
|
18332
|
+
const source = () => {
|
|
18333
|
+
if (random !== void 0) return random;
|
|
18334
|
+
idle = contentScratch.get(owner);
|
|
18335
|
+
if (idle === void 0) contentScratch.set(owner, idle = []);
|
|
18336
|
+
random = idle.pop();
|
|
18337
|
+
if (random === void 0) random = new NeoRandom(identity2);
|
|
18338
|
+
else random.deferIdentity(identity2);
|
|
18339
|
+
return random;
|
|
18340
|
+
};
|
|
18341
|
+
try {
|
|
18342
|
+
return evaluate(source);
|
|
18343
|
+
} finally {
|
|
18344
|
+
if (random !== void 0) {
|
|
18345
|
+
random.clearInstances();
|
|
18346
|
+
idle.push(random);
|
|
18347
|
+
}
|
|
18348
|
+
}
|
|
18349
|
+
}
|
|
18350
|
+
|
|
18351
|
+
// ../packages/neoscript-runtime/src/neoscript/math/neo-math-kernel.ts
|
|
18352
|
+
var words = new DataView(new ArrayBuffer(8));
|
|
18353
|
+
function highWord(x) {
|
|
18354
|
+
words.setFloat64(0, x, false);
|
|
18355
|
+
return words.getInt32(0, false);
|
|
18356
|
+
}
|
|
18357
|
+
function lowWord(x) {
|
|
18358
|
+
words.setFloat64(0, x, false);
|
|
18359
|
+
return words.getInt32(4, false);
|
|
18360
|
+
}
|
|
18361
|
+
function withHighWord(x, w) {
|
|
18362
|
+
words.setFloat64(0, x, false);
|
|
18363
|
+
words.setInt32(0, w, false);
|
|
18364
|
+
return words.getFloat64(0, false);
|
|
18365
|
+
}
|
|
18366
|
+
function withLowWord(x, w) {
|
|
18367
|
+
words.setFloat64(0, x, false);
|
|
18368
|
+
words.setInt32(4, w, false);
|
|
18369
|
+
return words.getFloat64(0, false);
|
|
18370
|
+
}
|
|
18371
|
+
function copysign(x, y) {
|
|
18372
|
+
return withHighWord(
|
|
18373
|
+
x,
|
|
18374
|
+
highWord(x) & 2147483647 | highWord(y) & 2147483648
|
|
18375
|
+
);
|
|
18376
|
+
}
|
|
18377
|
+
var s_sin_y = new Array(2).fill(0);
|
|
18378
|
+
var s_cos_y = new Array(2).fill(0);
|
|
18379
|
+
var s_tan_y = new Array(2).fill(0);
|
|
18380
|
+
var e_rem_pio2_tx = new Array(3).fill(0);
|
|
18381
|
+
var k_rem_pio2_iq = new Array(20).fill(0);
|
|
18382
|
+
var k_rem_pio2_f = new Array(20).fill(0);
|
|
18383
|
+
var k_rem_pio2_fq = new Array(20).fill(0);
|
|
18384
|
+
var k_rem_pio2_q = new Array(20).fill(0);
|
|
18385
|
+
var e_pow_bp = [1, 1.5];
|
|
18386
|
+
var e_pow_dp_h = [0, 0.5849624872207642];
|
|
18387
|
+
var e_pow_dp_l = [0, 1350039202129749e-23];
|
|
18388
|
+
var e_pow_zero = 0;
|
|
18389
|
+
var e_pow_one = 1;
|
|
18390
|
+
var e_pow_two = 2;
|
|
18391
|
+
var e_pow_two53 = 9007199254740992;
|
|
18392
|
+
var e_pow_huge = 1e300;
|
|
18393
|
+
var e_pow_tiny = 1e-300;
|
|
18394
|
+
var e_pow_L1 = 0.5999999999999946;
|
|
18395
|
+
var e_pow_L2 = 0.4285714285785502;
|
|
18396
|
+
var e_pow_L3 = 0.33333332981837743;
|
|
18397
|
+
var e_pow_L4 = 0.272728123808534;
|
|
18398
|
+
var e_pow_L5 = 0.23066074577556175;
|
|
18399
|
+
var e_pow_L6 = 0.20697501780033842;
|
|
18400
|
+
var e_pow_P1 = 0.16666666666666602;
|
|
18401
|
+
var e_pow_P2 = -0.0027777777777015593;
|
|
18402
|
+
var e_pow_P3 = 6613756321437934e-20;
|
|
18403
|
+
var e_pow_P4 = -16533902205465252e-22;
|
|
18404
|
+
var e_pow_P5 = 41381367970572385e-24;
|
|
18405
|
+
var e_pow_lg2 = 0.6931471805599453;
|
|
18406
|
+
var e_pow_lg2_h = 0.6931471824645996;
|
|
18407
|
+
var e_pow_lg2_l = -1904654299957768e-24;
|
|
18408
|
+
var e_pow_ovt = 8008566259537294e-32;
|
|
18409
|
+
var e_pow_cp = 0.9617966939259756;
|
|
18410
|
+
var e_pow_cp_h = 0.9617967009544373;
|
|
18411
|
+
var e_pow_cp_l = -7028461650952758e-24;
|
|
18412
|
+
var e_pow_ivln2 = 1.4426950408889634;
|
|
18413
|
+
var e_pow_ivln2_h = 1.4426950216293335;
|
|
18414
|
+
var e_pow_ivln2_l = 19259629911266175e-24;
|
|
18415
|
+
function kernel___ieee754_pow(x, y) {
|
|
18416
|
+
let z = 0;
|
|
18417
|
+
let ax = 0;
|
|
18418
|
+
let z_h = 0;
|
|
18419
|
+
let z_l = 0;
|
|
18420
|
+
let p_h = 0;
|
|
18421
|
+
let p_l = 0;
|
|
18422
|
+
let y1 = 0;
|
|
18423
|
+
let t1 = 0;
|
|
18424
|
+
let t2 = 0;
|
|
18425
|
+
let r = 0;
|
|
18426
|
+
let s = 0;
|
|
18427
|
+
let t = 0;
|
|
18428
|
+
let u = 0;
|
|
18429
|
+
let v = 0;
|
|
18430
|
+
let w = 0;
|
|
18431
|
+
let i = 0;
|
|
18432
|
+
let j = 0;
|
|
18433
|
+
let k = 0;
|
|
18434
|
+
let yisint = 0;
|
|
18435
|
+
let n = 0;
|
|
18436
|
+
let hx = 0;
|
|
18437
|
+
let hy = 0;
|
|
18438
|
+
let ix = 0;
|
|
18439
|
+
let iy = 0;
|
|
18440
|
+
let lx = 0;
|
|
18441
|
+
let ly = 0;
|
|
18442
|
+
hx = highWord(x) | 0;
|
|
18443
|
+
lx = lowWord(x) >>> 0;
|
|
18444
|
+
hy = highWord(y) | 0;
|
|
18445
|
+
ly = lowWord(y) >>> 0;
|
|
18446
|
+
ix = hx & 2147483647 | 0;
|
|
18447
|
+
iy = hy & 2147483647 | 0;
|
|
18448
|
+
if ((iy >>> 0 | ly >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
18449
|
+
return e_pow_one;
|
|
18450
|
+
}
|
|
18451
|
+
if (ix > 2146435072 || ix == 2146435072 && lx >>> 0 != 0 >>> 0 || iy > 2146435072 || iy == 2146435072 && ly >>> 0 != 0 >>> 0) {
|
|
18452
|
+
return x + y;
|
|
18453
|
+
}
|
|
18454
|
+
yisint = 0 | 0;
|
|
18455
|
+
if (hx < 0) {
|
|
18456
|
+
if (iy >= 1128267776) {
|
|
18457
|
+
yisint = 2 | 0;
|
|
18458
|
+
} else {
|
|
18459
|
+
if (iy >= 1072693248) {
|
|
18460
|
+
k = (iy >> 20) - 1023 | 0;
|
|
18461
|
+
if (k > 20) {
|
|
18462
|
+
j = ly >>> 52 - k | 0;
|
|
18463
|
+
if (j << 52 - k >>> 0 == ly >>> 0) {
|
|
18464
|
+
yisint = 2 - (j & 1) | 0;
|
|
18465
|
+
}
|
|
18466
|
+
} else {
|
|
18467
|
+
if (ly >>> 0 == 0 >>> 0) {
|
|
18468
|
+
j = iy >> 20 - k | 0;
|
|
18469
|
+
if (j << 20 - k == iy) {
|
|
18470
|
+
yisint = 2 - (j & 1) | 0;
|
|
18471
|
+
}
|
|
18472
|
+
}
|
|
18473
|
+
}
|
|
18474
|
+
}
|
|
18475
|
+
}
|
|
18476
|
+
}
|
|
18477
|
+
if (ly >>> 0 == 0 >>> 0) {
|
|
18478
|
+
if (iy == 2146435072) {
|
|
18479
|
+
if ((ix - 1072693248 >>> 0 | lx >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
18480
|
+
return y - y;
|
|
18481
|
+
} else {
|
|
18482
|
+
if (ix >= 1072693248) {
|
|
18483
|
+
return hy >= 0 ? y : e_pow_zero;
|
|
18484
|
+
} else {
|
|
18485
|
+
return hy < 0 ? -y : e_pow_zero;
|
|
18486
|
+
}
|
|
18487
|
+
}
|
|
18488
|
+
}
|
|
18489
|
+
if (iy == 1072693248) {
|
|
18490
|
+
if (hy < 0) {
|
|
18491
|
+
return e_pow_one / x;
|
|
18492
|
+
} else {
|
|
18493
|
+
return x;
|
|
18494
|
+
}
|
|
18495
|
+
}
|
|
18496
|
+
if (hy == 1073741824) {
|
|
18497
|
+
return x * x;
|
|
18498
|
+
}
|
|
18499
|
+
if (hy == 1071644672) {
|
|
18500
|
+
if (hx >= 0) {
|
|
18501
|
+
return Math.sqrt(x);
|
|
18502
|
+
}
|
|
18503
|
+
}
|
|
18504
|
+
}
|
|
18505
|
+
ax = Math.abs(x);
|
|
18506
|
+
if (lx >>> 0 == 0 >>> 0) {
|
|
18507
|
+
if (ix == 2146435072 || ix == 0 || ix == 1072693248) {
|
|
18508
|
+
z = ax;
|
|
18509
|
+
if (hy < 0) {
|
|
18510
|
+
z = e_pow_one / z;
|
|
18511
|
+
}
|
|
18512
|
+
if (hx < 0) {
|
|
18513
|
+
if ((ix - 1072693248 | yisint) == 0) {
|
|
18514
|
+
z = (z - z) / (z - z);
|
|
18515
|
+
} else {
|
|
18516
|
+
if (yisint == 1) {
|
|
18517
|
+
z = -z;
|
|
18518
|
+
}
|
|
18519
|
+
}
|
|
18520
|
+
}
|
|
18521
|
+
return z;
|
|
18522
|
+
}
|
|
18523
|
+
}
|
|
18524
|
+
n = (hx >> 31) + 1 | 0;
|
|
18525
|
+
if ((n | yisint) == 0) {
|
|
18526
|
+
return (x - x) / (x - x);
|
|
18527
|
+
}
|
|
18528
|
+
s = e_pow_one;
|
|
18529
|
+
if ((n | yisint - 1) == 0) {
|
|
18530
|
+
s = -e_pow_one;
|
|
18531
|
+
}
|
|
18532
|
+
if (iy > 1105199104) {
|
|
18533
|
+
if (iy > 1139802112) {
|
|
18534
|
+
if (ix <= 1072693247) {
|
|
18535
|
+
return hy < 0 ? e_pow_huge * e_pow_huge : e_pow_tiny * e_pow_tiny;
|
|
18536
|
+
}
|
|
18537
|
+
if (ix >= 1072693248) {
|
|
18538
|
+
return hy > 0 ? e_pow_huge * e_pow_huge : e_pow_tiny * e_pow_tiny;
|
|
18539
|
+
}
|
|
18540
|
+
}
|
|
18541
|
+
if (ix < 1072693247) {
|
|
18542
|
+
return hy < 0 ? s * e_pow_huge * e_pow_huge : s * e_pow_tiny * e_pow_tiny;
|
|
18543
|
+
}
|
|
18544
|
+
if (ix > 1072693248) {
|
|
18545
|
+
return hy > 0 ? s * e_pow_huge * e_pow_huge : s * e_pow_tiny * e_pow_tiny;
|
|
18546
|
+
}
|
|
18547
|
+
t = ax - e_pow_one;
|
|
18548
|
+
w = t * t * (0.5 - t * (0.3333333333333333 - t * 0.25));
|
|
18549
|
+
u = e_pow_ivln2_h * t;
|
|
18550
|
+
v = t * e_pow_ivln2_l - w * e_pow_ivln2;
|
|
18551
|
+
t1 = u + v;
|
|
18552
|
+
t1 = withLowWord(t1, 0 | 0);
|
|
18553
|
+
t2 = v - (t1 - u);
|
|
18554
|
+
} else {
|
|
18555
|
+
let ss = 0;
|
|
18556
|
+
let s2 = 0;
|
|
18557
|
+
let s_h = 0;
|
|
18558
|
+
let s_l = 0;
|
|
18559
|
+
let t_h = 0;
|
|
18560
|
+
let t_l = 0;
|
|
18561
|
+
n = 0 | 0;
|
|
18562
|
+
if (ix < 1048576) {
|
|
18563
|
+
ax = ax * e_pow_two53;
|
|
18564
|
+
n = n - 53 | 0;
|
|
18565
|
+
ix = highWord(ax) | 0;
|
|
18566
|
+
}
|
|
18567
|
+
n = n + ((ix >> 20) - 1023) | 0;
|
|
18568
|
+
j = ix & 1048575 | 0;
|
|
18569
|
+
ix = j | 1072693248 | 0;
|
|
18570
|
+
if (j <= 235662) {
|
|
18571
|
+
k = 0 | 0;
|
|
18572
|
+
} else {
|
|
18573
|
+
if (j < 767610) {
|
|
18574
|
+
k = 1 | 0;
|
|
18575
|
+
} else {
|
|
18576
|
+
k = 0 | 0;
|
|
18577
|
+
n = n + 1 | 0;
|
|
18578
|
+
ix = ix - 1048576 | 0;
|
|
18579
|
+
}
|
|
18580
|
+
}
|
|
18581
|
+
ax = withHighWord(ax, ix | 0);
|
|
18582
|
+
u = ax - e_pow_bp[k];
|
|
18583
|
+
v = e_pow_one / (ax + e_pow_bp[k]);
|
|
18584
|
+
ss = u * v;
|
|
18585
|
+
s_h = ss;
|
|
18586
|
+
s_h = withLowWord(s_h, 0 | 0);
|
|
18587
|
+
t_h = e_pow_zero;
|
|
18588
|
+
t_h = withHighWord(
|
|
18589
|
+
t_h,
|
|
18590
|
+
(ix >> 1 | 536870912) + 524288 + (k << 18) | 0
|
|
18591
|
+
);
|
|
18592
|
+
t_l = ax - (t_h - e_pow_bp[k]);
|
|
18593
|
+
s_l = v * (u - s_h * t_h - s_h * t_l);
|
|
18594
|
+
s2 = ss * ss;
|
|
18595
|
+
r = s2 * s2 * (e_pow_L1 + s2 * (e_pow_L2 + s2 * (e_pow_L3 + s2 * (e_pow_L4 + s2 * (e_pow_L5 + s2 * e_pow_L6)))));
|
|
18596
|
+
r = r + s_l * (s_h + ss);
|
|
18597
|
+
s2 = s_h * s_h;
|
|
18598
|
+
t_h = 3 + s2 + r;
|
|
18599
|
+
t_h = withLowWord(t_h, 0 | 0);
|
|
18600
|
+
t_l = r - (t_h - 3 - s2);
|
|
18601
|
+
u = s_h * t_h;
|
|
18602
|
+
v = s_l * t_h + t_l * ss;
|
|
18603
|
+
p_h = u + v;
|
|
18604
|
+
p_h = withLowWord(p_h, 0 | 0);
|
|
18605
|
+
p_l = v - (p_h - u);
|
|
18606
|
+
z_h = e_pow_cp_h * p_h;
|
|
18607
|
+
z_l = e_pow_cp_l * p_h + p_l * e_pow_cp + e_pow_dp_l[k];
|
|
18608
|
+
t = n;
|
|
18609
|
+
t1 = z_h + z_l + e_pow_dp_h[k] + t;
|
|
18610
|
+
t1 = withLowWord(t1, 0 | 0);
|
|
18611
|
+
t2 = z_l - (t1 - t - e_pow_dp_h[k] - z_h);
|
|
18612
|
+
}
|
|
18613
|
+
y1 = y;
|
|
18614
|
+
y1 = withLowWord(y1, 0 | 0);
|
|
18615
|
+
p_l = (y - y1) * t1 + y * t2;
|
|
18616
|
+
p_h = y1 * t1;
|
|
18617
|
+
z = p_l + p_h;
|
|
18618
|
+
j = highWord(z) | 0;
|
|
18619
|
+
i = lowWord(z) | 0;
|
|
18620
|
+
if (j >= 1083179008) {
|
|
18621
|
+
if ((j - 1083179008 | i) != 0) {
|
|
18622
|
+
return s * e_pow_huge * e_pow_huge;
|
|
18623
|
+
} else {
|
|
18624
|
+
if (p_l + e_pow_ovt > z - p_h) {
|
|
18625
|
+
return s * e_pow_huge * e_pow_huge;
|
|
18626
|
+
}
|
|
18627
|
+
}
|
|
18628
|
+
} else {
|
|
18629
|
+
if ((j & 2147483647) >= 1083231232) {
|
|
18630
|
+
if (((j >>> 0) - (3230714880 >>> 0) >>> 0 | i >>> 0) >>> 0 >>> 0 != 0 >>> 0) {
|
|
18631
|
+
return s * e_pow_tiny * e_pow_tiny;
|
|
18632
|
+
} else {
|
|
18633
|
+
if (p_l <= z - p_h) {
|
|
18634
|
+
return s * e_pow_tiny * e_pow_tiny;
|
|
18635
|
+
}
|
|
18636
|
+
}
|
|
18637
|
+
}
|
|
18638
|
+
}
|
|
18639
|
+
i = j & 2147483647 | 0;
|
|
18640
|
+
k = (i >> 20) - 1023 | 0;
|
|
18641
|
+
n = 0 | 0;
|
|
18642
|
+
if (i > 1071644672) {
|
|
18643
|
+
n = j + (1048576 >> k + 1) | 0;
|
|
18644
|
+
k = ((n & 2147483647) >> 20) - 1023 | 0;
|
|
18645
|
+
t = e_pow_zero;
|
|
18646
|
+
t = withHighWord(t, n & ~(1048575 >> k) | 0);
|
|
18647
|
+
n = (n & 1048575 | 1048576) >> 20 - k | 0;
|
|
18648
|
+
if (j < 0) {
|
|
18649
|
+
n = -n | 0;
|
|
18650
|
+
}
|
|
18651
|
+
p_h = p_h - t;
|
|
18652
|
+
}
|
|
18653
|
+
t = p_l + p_h;
|
|
18654
|
+
t = withLowWord(t, 0 | 0);
|
|
18655
|
+
u = t * e_pow_lg2_h;
|
|
18656
|
+
v = (p_l - (t - p_h)) * e_pow_lg2 + t * e_pow_lg2_l;
|
|
18657
|
+
z = u + v;
|
|
18658
|
+
w = v - (z - u);
|
|
18659
|
+
t = z * z;
|
|
18660
|
+
t1 = z - t * (e_pow_P1 + t * (e_pow_P2 + t * (e_pow_P3 + t * (e_pow_P4 + t * e_pow_P5))));
|
|
18661
|
+
r = z * t1 / (t1 - e_pow_two) - (w + z * w);
|
|
18662
|
+
z = e_pow_one - (r - z);
|
|
18663
|
+
j = highWord(z) | 0;
|
|
18664
|
+
j = j + (n << 20) | 0;
|
|
18665
|
+
if (j >> 20 <= 0) {
|
|
18666
|
+
z = kernel_scalbn(z, n);
|
|
18667
|
+
} else {
|
|
18668
|
+
z = withHighWord(z, highWord(z) + (n << 20) | 0);
|
|
18669
|
+
}
|
|
18670
|
+
return s * z;
|
|
18671
|
+
}
|
|
18672
|
+
var e_exp_one = 1;
|
|
18673
|
+
var e_exp_halF = [0.5, -0.5];
|
|
18674
|
+
var e_exp_huge = 1e300;
|
|
18675
|
+
var e_exp_twom1000 = 9332636185032189e-317;
|
|
18676
|
+
var e_exp_o_threshold = 709.782712893384;
|
|
18677
|
+
var e_exp_u_threshold = -745.1332191019411;
|
|
18678
|
+
var e_exp_ln2HI = [0.6931471803691238, -0.6931471803691238];
|
|
18679
|
+
var e_exp_ln2LO = [19082149292705877e-26, -19082149292705877e-26];
|
|
18680
|
+
var e_exp_invln2 = 1.4426950408889634;
|
|
18681
|
+
var e_exp_P1 = 0.16666666666666602;
|
|
18682
|
+
var e_exp_P2 = -0.0027777777777015593;
|
|
18683
|
+
var e_exp_P3 = 6613756321437934e-20;
|
|
18684
|
+
var e_exp_P4 = -16533902205465252e-22;
|
|
18685
|
+
var e_exp_P5 = 41381367970572385e-24;
|
|
18686
|
+
function kernel___ieee754_exp(x) {
|
|
18687
|
+
let y = 0;
|
|
18688
|
+
let hi = 0;
|
|
18689
|
+
let lo = 0;
|
|
18690
|
+
let c = 0;
|
|
18691
|
+
let t = 0;
|
|
18692
|
+
let k = 0;
|
|
18693
|
+
let xsb = 0;
|
|
18694
|
+
let hx = 0;
|
|
18695
|
+
hx = highWord(x) >>> 0;
|
|
18696
|
+
xsb = (hx >>> 31 >>> 0 & 1 >>> 0) >>> 0 | 0;
|
|
18697
|
+
hx = (hx & 2147483647) >>> 0;
|
|
18698
|
+
if (hx >>> 0 >= 1082535490 >>> 0) {
|
|
18699
|
+
if (hx >>> 0 >= 2146435072 >>> 0) {
|
|
18700
|
+
if (((hx >>> 0 & 1048575 >>> 0) >>> 0 >>> 0 | lowWord(x) >>> 0) >>> 0 >>> 0 != 0 >>> 0) {
|
|
18701
|
+
return x + x;
|
|
18702
|
+
} else {
|
|
18703
|
+
return xsb == 0 ? x : 0;
|
|
18704
|
+
}
|
|
18705
|
+
}
|
|
18706
|
+
if (x > e_exp_o_threshold) {
|
|
18707
|
+
return e_exp_huge * e_exp_huge;
|
|
18708
|
+
}
|
|
18709
|
+
if (x < e_exp_u_threshold) {
|
|
18710
|
+
return e_exp_twom1000 * e_exp_twom1000;
|
|
18711
|
+
}
|
|
18712
|
+
}
|
|
18713
|
+
if (hx >>> 0 > 1071001154 >>> 0) {
|
|
18714
|
+
if (hx >>> 0 < 1072734898 >>> 0) {
|
|
18715
|
+
hi = x - e_exp_ln2HI[xsb];
|
|
18716
|
+
lo = e_exp_ln2LO[xsb];
|
|
18717
|
+
k = 1 - xsb - xsb | 0;
|
|
18718
|
+
} else {
|
|
18719
|
+
k = e_exp_invln2 * x + e_exp_halF[xsb] | 0 | 0;
|
|
18720
|
+
t = k;
|
|
18721
|
+
hi = x - t * e_exp_ln2HI[0];
|
|
18722
|
+
lo = t * e_exp_ln2LO[0];
|
|
18723
|
+
}
|
|
18724
|
+
x = hi - lo;
|
|
18725
|
+
} else {
|
|
18726
|
+
if (hx >>> 0 < 1043333120 >>> 0) {
|
|
18727
|
+
if (e_exp_huge + x > e_exp_one) {
|
|
18728
|
+
return e_exp_one + x;
|
|
18729
|
+
}
|
|
18730
|
+
} else {
|
|
18731
|
+
k = 0 | 0;
|
|
18732
|
+
}
|
|
18733
|
+
}
|
|
18734
|
+
t = x * x;
|
|
18735
|
+
c = x - t * (e_exp_P1 + t * (e_exp_P2 + t * (e_exp_P3 + t * (e_exp_P4 + t * e_exp_P5))));
|
|
18736
|
+
if (k == 0) {
|
|
18737
|
+
return e_exp_one - (x * c / (c - 2) - x);
|
|
18738
|
+
} else {
|
|
18739
|
+
y = e_exp_one - (lo - x * c / (2 - c) - hi);
|
|
18740
|
+
}
|
|
18741
|
+
if (k >= -1021) {
|
|
18742
|
+
y = withHighWord(y, highWord(y) + (k << 20) | 0);
|
|
18743
|
+
return y;
|
|
18744
|
+
} else {
|
|
18745
|
+
y = withHighWord(y, highWord(y) + (k + 1e3 << 20) | 0);
|
|
18746
|
+
return y * e_exp_twom1000;
|
|
18747
|
+
}
|
|
18748
|
+
}
|
|
18749
|
+
var e_log_ln2_hi = 0.6931471803691238;
|
|
18750
|
+
var e_log_ln2_lo = 19082149292705877e-26;
|
|
18751
|
+
var e_log_two54 = 18014398509481984;
|
|
18752
|
+
var e_log_Lg1 = 0.6666666666666735;
|
|
18753
|
+
var e_log_Lg2 = 0.3999999999940942;
|
|
18754
|
+
var e_log_Lg3 = 0.2857142874366239;
|
|
18755
|
+
var e_log_Lg4 = 0.22222198432149784;
|
|
18756
|
+
var e_log_Lg5 = 0.1818357216161805;
|
|
18757
|
+
var e_log_Lg6 = 0.15313837699209373;
|
|
18758
|
+
var e_log_Lg7 = 0.14798198605116586;
|
|
18759
|
+
var e_log_zero = 0;
|
|
18760
|
+
function kernel___ieee754_log(x) {
|
|
18761
|
+
let hfsq = 0;
|
|
18762
|
+
let f = 0;
|
|
18763
|
+
let s = 0;
|
|
18764
|
+
let z = 0;
|
|
18765
|
+
let R = 0;
|
|
18766
|
+
let w = 0;
|
|
18767
|
+
let t1 = 0;
|
|
18768
|
+
let t2 = 0;
|
|
18769
|
+
let dk = 0;
|
|
18770
|
+
let k = 0;
|
|
18771
|
+
let hx = 0;
|
|
18772
|
+
let i = 0;
|
|
18773
|
+
let j = 0;
|
|
18774
|
+
let lx = 0;
|
|
18775
|
+
hx = highWord(x) | 0;
|
|
18776
|
+
lx = lowWord(x) >>> 0;
|
|
18777
|
+
k = 0 | 0;
|
|
18778
|
+
if (hx < 1048576) {
|
|
18779
|
+
if (((hx & 2147483647) >>> 0 | lx >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
18780
|
+
return -e_log_two54 / e_log_zero;
|
|
18781
|
+
}
|
|
18782
|
+
if (hx < 0) {
|
|
18783
|
+
return (x - x) / e_log_zero;
|
|
18784
|
+
}
|
|
18785
|
+
k = k - 54 | 0;
|
|
18786
|
+
x = x * e_log_two54;
|
|
18787
|
+
hx = highWord(x) | 0;
|
|
18788
|
+
}
|
|
18789
|
+
if (hx >= 2146435072) {
|
|
18790
|
+
return x + x;
|
|
18791
|
+
}
|
|
18792
|
+
k = k + ((hx >> 20) - 1023) | 0;
|
|
18793
|
+
hx = hx & 1048575 | 0;
|
|
18794
|
+
i = hx + 614244 & 1048576 | 0;
|
|
18795
|
+
x = withHighWord(x, hx | i ^ 1072693248 | 0);
|
|
18796
|
+
k = k + (i >> 20) | 0;
|
|
18797
|
+
f = x - 1;
|
|
18798
|
+
if ((1048575 & 2 + hx) < 3) {
|
|
18799
|
+
if (f == e_log_zero) {
|
|
18800
|
+
if (k == 0) {
|
|
18801
|
+
return e_log_zero;
|
|
18802
|
+
} else {
|
|
18803
|
+
dk = k;
|
|
18804
|
+
return dk * e_log_ln2_hi + dk * e_log_ln2_lo;
|
|
18805
|
+
}
|
|
18806
|
+
}
|
|
18807
|
+
R = f * f * (0.5 - 0.3333333333333333 * f);
|
|
18808
|
+
if (k == 0) {
|
|
18809
|
+
return f - R;
|
|
18810
|
+
} else {
|
|
18811
|
+
dk = k;
|
|
18812
|
+
return dk * e_log_ln2_hi - (R - dk * e_log_ln2_lo - f);
|
|
18813
|
+
}
|
|
18814
|
+
}
|
|
18815
|
+
s = f / (2 + f);
|
|
18816
|
+
dk = k;
|
|
18817
|
+
z = s * s;
|
|
18818
|
+
i = hx - 398458 | 0;
|
|
18819
|
+
w = z * z;
|
|
18820
|
+
j = 440401 - hx | 0;
|
|
18821
|
+
t1 = w * (e_log_Lg2 + w * (e_log_Lg4 + w * e_log_Lg6));
|
|
18822
|
+
t2 = z * (e_log_Lg1 + w * (e_log_Lg3 + w * (e_log_Lg5 + w * e_log_Lg7)));
|
|
18823
|
+
i = i | j | 0;
|
|
18824
|
+
R = t2 + t1;
|
|
18825
|
+
if (i > 0) {
|
|
18826
|
+
hfsq = 0.5 * f * f;
|
|
18827
|
+
if (k == 0) {
|
|
18828
|
+
return f - (hfsq - s * (hfsq + R));
|
|
18829
|
+
} else {
|
|
18830
|
+
return dk * e_log_ln2_hi - (hfsq - (s * (hfsq + R) + dk * e_log_ln2_lo) - f);
|
|
18831
|
+
}
|
|
18832
|
+
} else {
|
|
18833
|
+
if (k == 0) {
|
|
18834
|
+
return f - s * (f - R);
|
|
18835
|
+
} else {
|
|
18836
|
+
return dk * e_log_ln2_hi - (s * (f - R) - dk * e_log_ln2_lo - f);
|
|
18837
|
+
}
|
|
18838
|
+
}
|
|
18839
|
+
}
|
|
18840
|
+
var e_log10_two54 = 18014398509481984;
|
|
18841
|
+
var e_log10_ivln10 = 0.4342944819032518;
|
|
18842
|
+
var e_log10_log10_2hi = 0.30102999566361177;
|
|
18843
|
+
var e_log10_log10_2lo = 3694239077158931e-28;
|
|
18844
|
+
var e_log10_zero = 0;
|
|
18845
|
+
function kernel___ieee754_log10(x) {
|
|
18846
|
+
let y = 0;
|
|
18847
|
+
let z = 0;
|
|
18848
|
+
let i = 0;
|
|
18849
|
+
let k = 0;
|
|
18850
|
+
let hx = 0;
|
|
18851
|
+
let lx = 0;
|
|
18852
|
+
hx = highWord(x) | 0;
|
|
18853
|
+
lx = lowWord(x) >>> 0;
|
|
18854
|
+
k = 0 | 0;
|
|
18855
|
+
if (hx < 1048576) {
|
|
18856
|
+
if (((hx & 2147483647) >>> 0 | lx >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
18857
|
+
return -e_log10_two54 / e_log10_zero;
|
|
18858
|
+
}
|
|
18859
|
+
if (hx < 0) {
|
|
18860
|
+
return (x - x) / e_log10_zero;
|
|
18861
|
+
}
|
|
18862
|
+
k = k - 54 | 0;
|
|
18863
|
+
x = x * e_log10_two54;
|
|
18864
|
+
hx = highWord(x) | 0;
|
|
18865
|
+
}
|
|
18866
|
+
if (hx >= 2146435072) {
|
|
18867
|
+
return x + x;
|
|
18868
|
+
}
|
|
18869
|
+
k = k + ((hx >> 20) - 1023) | 0;
|
|
18870
|
+
i = (k >>> 0 >>> 0 & 2147483648 >>> 0) >>> 0 >>> 31 | 0;
|
|
18871
|
+
hx = hx & 1048575 | 1023 - i << 20 | 0;
|
|
18872
|
+
y = k + i;
|
|
18873
|
+
x = withHighWord(x, hx | 0);
|
|
18874
|
+
z = y * e_log10_log10_2lo + e_log10_ivln10 * kernel___ieee754_log(x);
|
|
18875
|
+
return z + y * e_log10_log10_2hi;
|
|
18876
|
+
}
|
|
18877
|
+
function kernel_sin(x) {
|
|
18878
|
+
const y = s_sin_y;
|
|
18879
|
+
const z = 0;
|
|
18880
|
+
let n = 0;
|
|
18881
|
+
let ix = 0;
|
|
18882
|
+
ix = highWord(x) | 0;
|
|
18883
|
+
ix = ix & 2147483647 | 0;
|
|
18884
|
+
if (ix <= 1072243195) {
|
|
18885
|
+
return kernel___kernel_sin(x, z, 0);
|
|
18886
|
+
} else {
|
|
18887
|
+
if (ix >= 2146435072) {
|
|
18888
|
+
return x - x;
|
|
18889
|
+
} else {
|
|
18890
|
+
n = kernel___ieee754_rem_pio2(x, y) | 0;
|
|
18891
|
+
switch (n & 3) {
|
|
18892
|
+
case 0:
|
|
18893
|
+
return kernel___kernel_sin(y[0], y[1], 1);
|
|
18894
|
+
case 1:
|
|
18895
|
+
return kernel___kernel_cos(y[0], y[1]);
|
|
18896
|
+
case 2:
|
|
18897
|
+
return -kernel___kernel_sin(y[0], y[1], 1);
|
|
18898
|
+
default:
|
|
18899
|
+
return -kernel___kernel_cos(y[0], y[1]);
|
|
18900
|
+
}
|
|
18901
|
+
}
|
|
18902
|
+
}
|
|
18903
|
+
}
|
|
18904
|
+
function kernel_cos(x) {
|
|
18905
|
+
const y = s_cos_y;
|
|
18906
|
+
const z = 0;
|
|
18907
|
+
let n = 0;
|
|
18908
|
+
let ix = 0;
|
|
18909
|
+
ix = highWord(x) | 0;
|
|
18910
|
+
ix = ix & 2147483647 | 0;
|
|
18911
|
+
if (ix <= 1072243195) {
|
|
18912
|
+
return kernel___kernel_cos(x, z);
|
|
18913
|
+
} else {
|
|
18914
|
+
if (ix >= 2146435072) {
|
|
18915
|
+
return x - x;
|
|
18916
|
+
} else {
|
|
18917
|
+
n = kernel___ieee754_rem_pio2(x, y) | 0;
|
|
18918
|
+
switch (n & 3) {
|
|
18919
|
+
case 0:
|
|
18920
|
+
return kernel___kernel_cos(y[0], y[1]);
|
|
18921
|
+
case 1:
|
|
18922
|
+
return -kernel___kernel_sin(y[0], y[1], 1);
|
|
18923
|
+
case 2:
|
|
18924
|
+
return -kernel___kernel_cos(y[0], y[1]);
|
|
18925
|
+
default:
|
|
18926
|
+
return kernel___kernel_sin(y[0], y[1], 1);
|
|
18927
|
+
}
|
|
18928
|
+
}
|
|
18929
|
+
}
|
|
18930
|
+
}
|
|
18931
|
+
function kernel_tan(x) {
|
|
18932
|
+
const y = s_tan_y;
|
|
18933
|
+
const z = 0;
|
|
18934
|
+
let n = 0;
|
|
18935
|
+
let ix = 0;
|
|
18936
|
+
ix = highWord(x) | 0;
|
|
18937
|
+
ix = ix & 2147483647 | 0;
|
|
18938
|
+
if (ix <= 1072243195) {
|
|
18939
|
+
return kernel___kernel_tan(x, z, 1);
|
|
18940
|
+
} else {
|
|
18941
|
+
if (ix >= 2146435072) {
|
|
18942
|
+
return x - x;
|
|
18943
|
+
} else {
|
|
18944
|
+
n = kernel___ieee754_rem_pio2(x, y) | 0;
|
|
18945
|
+
return kernel___kernel_tan(y[0], y[1], 1 - ((n & 1) << 1));
|
|
18946
|
+
}
|
|
18947
|
+
}
|
|
18948
|
+
}
|
|
18949
|
+
var e_asin_one = 1;
|
|
18950
|
+
var e_asin_huge = 1e300;
|
|
18951
|
+
var e_asin_pio2_hi = 1.5707963267948966;
|
|
18952
|
+
var e_asin_pio2_lo = 6123233995736766e-32;
|
|
18953
|
+
var e_asin_pio4_hi = 0.7853981633974483;
|
|
18954
|
+
var e_asin_pS0 = 0.16666666666666666;
|
|
18955
|
+
var e_asin_pS1 = -0.3255658186224009;
|
|
18956
|
+
var e_asin_pS2 = 0.20121253213486293;
|
|
18957
|
+
var e_asin_pS3 = -0.04005553450067941;
|
|
18958
|
+
var e_asin_pS4 = 7915349942898145e-19;
|
|
18959
|
+
var e_asin_pS5 = 3479331075960212e-20;
|
|
18960
|
+
var e_asin_qS1 = -2.403394911734414;
|
|
18961
|
+
var e_asin_qS2 = 2.0209457602335057;
|
|
18962
|
+
var e_asin_qS3 = -0.6882839716054533;
|
|
18963
|
+
var e_asin_qS4 = 0.07703815055590194;
|
|
18964
|
+
function kernel___ieee754_asin(x) {
|
|
18965
|
+
let t = 0;
|
|
18966
|
+
let w = 0;
|
|
18967
|
+
let p = 0;
|
|
18968
|
+
let q = 0;
|
|
18969
|
+
let c = 0;
|
|
18970
|
+
let r = 0;
|
|
18971
|
+
let s = 0;
|
|
18972
|
+
let hx = 0;
|
|
18973
|
+
let ix = 0;
|
|
18974
|
+
hx = highWord(x) | 0;
|
|
18975
|
+
ix = hx & 2147483647 | 0;
|
|
18976
|
+
if (ix >= 1072693248) {
|
|
18977
|
+
if ((ix - 1072693248 | lowWord(x)) == 0) {
|
|
18978
|
+
return x * e_asin_pio2_hi + x * e_asin_pio2_lo;
|
|
18979
|
+
}
|
|
18980
|
+
return (x - x) / (x - x);
|
|
18981
|
+
} else {
|
|
18982
|
+
if (ix < 1071644672) {
|
|
18983
|
+
if (ix < 1044381696) {
|
|
18984
|
+
if (e_asin_huge + x > e_asin_one) {
|
|
18985
|
+
return x;
|
|
18986
|
+
}
|
|
18987
|
+
} else {
|
|
18988
|
+
t = x * x;
|
|
18989
|
+
}
|
|
18990
|
+
p = t * (e_asin_pS0 + t * (e_asin_pS1 + t * (e_asin_pS2 + t * (e_asin_pS3 + t * (e_asin_pS4 + t * e_asin_pS5)))));
|
|
18991
|
+
q = e_asin_one + t * (e_asin_qS1 + t * (e_asin_qS2 + t * (e_asin_qS3 + t * e_asin_qS4)));
|
|
18992
|
+
w = p / q;
|
|
18993
|
+
return x + x * w;
|
|
18994
|
+
}
|
|
18995
|
+
}
|
|
18996
|
+
w = e_asin_one - Math.abs(x);
|
|
18997
|
+
t = w * 0.5;
|
|
18998
|
+
p = t * (e_asin_pS0 + t * (e_asin_pS1 + t * (e_asin_pS2 + t * (e_asin_pS3 + t * (e_asin_pS4 + t * e_asin_pS5)))));
|
|
18999
|
+
q = e_asin_one + t * (e_asin_qS1 + t * (e_asin_qS2 + t * (e_asin_qS3 + t * e_asin_qS4)));
|
|
19000
|
+
s = Math.sqrt(t);
|
|
19001
|
+
if (ix >= 1072640819) {
|
|
19002
|
+
w = p / q;
|
|
19003
|
+
t = e_asin_pio2_hi - (2 * (s + s * w) - e_asin_pio2_lo);
|
|
19004
|
+
} else {
|
|
19005
|
+
w = s;
|
|
19006
|
+
w = withLowWord(w, 0 | 0);
|
|
19007
|
+
c = (t - w * w) / (s + w);
|
|
19008
|
+
r = p / q;
|
|
19009
|
+
p = 2 * s * r - (e_asin_pio2_lo - 2 * c);
|
|
19010
|
+
q = e_asin_pio4_hi - 2 * w;
|
|
19011
|
+
t = e_asin_pio4_hi - (p - q);
|
|
19012
|
+
}
|
|
19013
|
+
if (hx > 0) {
|
|
19014
|
+
return t;
|
|
19015
|
+
} else {
|
|
19016
|
+
return -t;
|
|
19017
|
+
}
|
|
19018
|
+
}
|
|
19019
|
+
var e_acos_one = 1;
|
|
19020
|
+
var e_acos_pi = 3.141592653589793;
|
|
19021
|
+
var e_acos_pio2_hi = 1.5707963267948966;
|
|
19022
|
+
var e_acos_pio2_lo = 6123233995736766e-32;
|
|
19023
|
+
var e_acos_pS0 = 0.16666666666666666;
|
|
19024
|
+
var e_acos_pS1 = -0.3255658186224009;
|
|
19025
|
+
var e_acos_pS2 = 0.20121253213486293;
|
|
19026
|
+
var e_acos_pS3 = -0.04005553450067941;
|
|
19027
|
+
var e_acos_pS4 = 7915349942898145e-19;
|
|
19028
|
+
var e_acos_pS5 = 3479331075960212e-20;
|
|
19029
|
+
var e_acos_qS1 = -2.403394911734414;
|
|
19030
|
+
var e_acos_qS2 = 2.0209457602335057;
|
|
19031
|
+
var e_acos_qS3 = -0.6882839716054533;
|
|
19032
|
+
var e_acos_qS4 = 0.07703815055590194;
|
|
19033
|
+
function kernel___ieee754_acos(x) {
|
|
19034
|
+
let z = 0;
|
|
19035
|
+
let p = 0;
|
|
19036
|
+
let q = 0;
|
|
19037
|
+
let r = 0;
|
|
19038
|
+
let w = 0;
|
|
19039
|
+
let s = 0;
|
|
19040
|
+
let c = 0;
|
|
19041
|
+
let df = 0;
|
|
19042
|
+
let hx = 0;
|
|
19043
|
+
let ix = 0;
|
|
19044
|
+
hx = highWord(x) | 0;
|
|
19045
|
+
ix = hx & 2147483647 | 0;
|
|
19046
|
+
if (ix >= 1072693248) {
|
|
19047
|
+
if ((ix - 1072693248 | lowWord(x)) == 0) {
|
|
19048
|
+
if (hx > 0) {
|
|
19049
|
+
return 0;
|
|
19050
|
+
} else {
|
|
19051
|
+
return e_acos_pi + 2 * e_acos_pio2_lo;
|
|
19052
|
+
}
|
|
19053
|
+
}
|
|
19054
|
+
return (x - x) / (x - x);
|
|
19055
|
+
}
|
|
19056
|
+
if (ix < 1071644672) {
|
|
19057
|
+
if (ix <= 1012924416) {
|
|
19058
|
+
return e_acos_pio2_hi + e_acos_pio2_lo;
|
|
19059
|
+
}
|
|
19060
|
+
z = x * x;
|
|
19061
|
+
p = z * (e_acos_pS0 + z * (e_acos_pS1 + z * (e_acos_pS2 + z * (e_acos_pS3 + z * (e_acos_pS4 + z * e_acos_pS5)))));
|
|
19062
|
+
q = e_acos_one + z * (e_acos_qS1 + z * (e_acos_qS2 + z * (e_acos_qS3 + z * e_acos_qS4)));
|
|
19063
|
+
r = p / q;
|
|
19064
|
+
return e_acos_pio2_hi - (x - (e_acos_pio2_lo - x * r));
|
|
19065
|
+
} else {
|
|
19066
|
+
if (hx < 0) {
|
|
19067
|
+
z = (e_acos_one + x) * 0.5;
|
|
19068
|
+
p = z * (e_acos_pS0 + z * (e_acos_pS1 + z * (e_acos_pS2 + z * (e_acos_pS3 + z * (e_acos_pS4 + z * e_acos_pS5)))));
|
|
19069
|
+
q = e_acos_one + z * (e_acos_qS1 + z * (e_acos_qS2 + z * (e_acos_qS3 + z * e_acos_qS4)));
|
|
19070
|
+
s = Math.sqrt(z);
|
|
19071
|
+
r = p / q;
|
|
19072
|
+
w = r * s - e_acos_pio2_lo;
|
|
19073
|
+
return e_acos_pi - 2 * (s + w);
|
|
19074
|
+
} else {
|
|
19075
|
+
z = (e_acos_one - x) * 0.5;
|
|
19076
|
+
s = Math.sqrt(z);
|
|
19077
|
+
df = s;
|
|
19078
|
+
df = withLowWord(df, 0 | 0);
|
|
19079
|
+
c = (z - df * df) / (s + df);
|
|
19080
|
+
p = z * (e_acos_pS0 + z * (e_acos_pS1 + z * (e_acos_pS2 + z * (e_acos_pS3 + z * (e_acos_pS4 + z * e_acos_pS5)))));
|
|
19081
|
+
q = e_acos_one + z * (e_acos_qS1 + z * (e_acos_qS2 + z * (e_acos_qS3 + z * e_acos_qS4)));
|
|
19082
|
+
r = p / q;
|
|
19083
|
+
w = r * s + c;
|
|
19084
|
+
return 2 * (df + w);
|
|
19085
|
+
}
|
|
19086
|
+
}
|
|
19087
|
+
}
|
|
19088
|
+
var s_atan_atanhi = [
|
|
19089
|
+
0.4636476090008061,
|
|
19090
|
+
0.7853981633974483,
|
|
19091
|
+
0.982793723247329,
|
|
19092
|
+
1.5707963267948966
|
|
19093
|
+
];
|
|
19094
|
+
var s_atan_atanlo = [
|
|
19095
|
+
22698777452961687e-33,
|
|
19096
|
+
3061616997868383e-32,
|
|
19097
|
+
13903311031230998e-33,
|
|
19098
|
+
6123233995736766e-32
|
|
19099
|
+
];
|
|
19100
|
+
var s_atan_aT = [
|
|
19101
|
+
0.3333333333333293,
|
|
19102
|
+
-0.19999999999876483,
|
|
19103
|
+
0.14285714272503466,
|
|
19104
|
+
-0.11111110405462356,
|
|
19105
|
+
0.09090887133436507,
|
|
19106
|
+
-0.0769187620504483,
|
|
19107
|
+
0.06661073137387531,
|
|
19108
|
+
-0.058335701337905735,
|
|
19109
|
+
0.049768779946159324,
|
|
19110
|
+
-0.036531572744216916,
|
|
19111
|
+
0.016285820115365782
|
|
19112
|
+
];
|
|
19113
|
+
var s_atan_one = 1;
|
|
19114
|
+
var s_atan_huge = 1e300;
|
|
19115
|
+
function kernel_atan(x) {
|
|
19116
|
+
let w = 0;
|
|
19117
|
+
let s1 = 0;
|
|
19118
|
+
let s2 = 0;
|
|
19119
|
+
let z = 0;
|
|
19120
|
+
let ix = 0;
|
|
19121
|
+
let hx = 0;
|
|
19122
|
+
let id = 0;
|
|
19123
|
+
hx = highWord(x) | 0;
|
|
19124
|
+
ix = hx & 2147483647 | 0;
|
|
19125
|
+
if (ix >= 1141899264) {
|
|
19126
|
+
if (ix > 2146435072 || ix == 2146435072 && lowWord(x) != 0) {
|
|
19127
|
+
return x + x;
|
|
19128
|
+
}
|
|
19129
|
+
if (hx > 0) {
|
|
19130
|
+
return s_atan_atanhi[3] + s_atan_atanlo[3];
|
|
19131
|
+
} else {
|
|
19132
|
+
return -s_atan_atanhi[3] - s_atan_atanlo[3];
|
|
19133
|
+
}
|
|
19134
|
+
}
|
|
19135
|
+
if (ix < 1071382528) {
|
|
19136
|
+
if (ix < 1042284544) {
|
|
19137
|
+
if (s_atan_huge + x > s_atan_one) {
|
|
19138
|
+
return x;
|
|
19139
|
+
}
|
|
19140
|
+
}
|
|
19141
|
+
id = -1 | 0;
|
|
19142
|
+
} else {
|
|
19143
|
+
x = Math.abs(x);
|
|
19144
|
+
if (ix < 1072889856) {
|
|
19145
|
+
if (ix < 1072037888) {
|
|
19146
|
+
id = 0 | 0;
|
|
19147
|
+
x = (2 * x - s_atan_one) / (2 + x);
|
|
19148
|
+
} else {
|
|
19149
|
+
id = 1 | 0;
|
|
19150
|
+
x = (x - s_atan_one) / (x + s_atan_one);
|
|
19151
|
+
}
|
|
19152
|
+
} else {
|
|
19153
|
+
if (ix < 1073971200) {
|
|
19154
|
+
id = 2 | 0;
|
|
19155
|
+
x = (x - 1.5) / (s_atan_one + 1.5 * x);
|
|
19156
|
+
} else {
|
|
19157
|
+
id = 3 | 0;
|
|
19158
|
+
x = -1 / x;
|
|
19159
|
+
}
|
|
19160
|
+
}
|
|
19161
|
+
}
|
|
19162
|
+
z = x * x;
|
|
19163
|
+
w = z * z;
|
|
19164
|
+
s1 = z * (s_atan_aT[0] + w * (s_atan_aT[2] + w * (s_atan_aT[4] + w * (s_atan_aT[6] + w * (s_atan_aT[8] + w * s_atan_aT[10])))));
|
|
19165
|
+
s2 = w * (s_atan_aT[1] + w * (s_atan_aT[3] + w * (s_atan_aT[5] + w * (s_atan_aT[7] + w * s_atan_aT[9]))));
|
|
19166
|
+
if (id < 0) {
|
|
19167
|
+
return x - x * (s1 + s2);
|
|
19168
|
+
} else {
|
|
19169
|
+
z = s_atan_atanhi[id] - (x * (s1 + s2) - s_atan_atanlo[id] - x);
|
|
19170
|
+
return hx < 0 ? -z : z;
|
|
19171
|
+
}
|
|
19172
|
+
}
|
|
19173
|
+
var e_atan2_tiny = 1e-300;
|
|
19174
|
+
var e_atan2_zero = 0;
|
|
19175
|
+
var e_atan2_pi_o_4 = 0.7853981633974483;
|
|
19176
|
+
var e_atan2_pi_o_2 = 1.5707963267948966;
|
|
19177
|
+
var e_atan2_pi = 3.141592653589793;
|
|
19178
|
+
var e_atan2_pi_lo = 12246467991473532e-32;
|
|
19179
|
+
function kernel___ieee754_atan2(y, x) {
|
|
19180
|
+
let z = 0;
|
|
19181
|
+
let k = 0;
|
|
19182
|
+
let m = 0;
|
|
19183
|
+
let hx = 0;
|
|
19184
|
+
let hy = 0;
|
|
19185
|
+
let ix = 0;
|
|
19186
|
+
let iy = 0;
|
|
19187
|
+
let lx = 0;
|
|
19188
|
+
let ly = 0;
|
|
19189
|
+
hx = highWord(x) | 0;
|
|
19190
|
+
ix = hx & 2147483647 | 0;
|
|
19191
|
+
lx = lowWord(x) >>> 0;
|
|
19192
|
+
hy = highWord(y) | 0;
|
|
19193
|
+
iy = hy & 2147483647 | 0;
|
|
19194
|
+
ly = lowWord(y) >>> 0;
|
|
19195
|
+
if ((ix >>> 0 | (lx >>> 0 | -lx >>> 0) >>> 0 >>> 31 >>> 0) >>> 0 >>> 0 > 2146435072 >>> 0 || (iy >>> 0 | (ly >>> 0 | -ly >>> 0) >>> 0 >>> 31 >>> 0) >>> 0 >>> 0 > 2146435072 >>> 0) {
|
|
19196
|
+
return x + y;
|
|
19197
|
+
}
|
|
19198
|
+
if ((hx - 1072693248 >>> 0 | lx >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
19199
|
+
return kernel_atan(y);
|
|
19200
|
+
}
|
|
19201
|
+
m = hy >> 31 & 1 | hx >> 30 & 2 | 0;
|
|
19202
|
+
if ((iy >>> 0 | ly >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
19203
|
+
switch (m) {
|
|
19204
|
+
case 0:
|
|
19205
|
+
case 1:
|
|
19206
|
+
return y;
|
|
19207
|
+
case 2:
|
|
19208
|
+
return e_atan2_pi + e_atan2_tiny;
|
|
19209
|
+
case 3:
|
|
19210
|
+
return -e_atan2_pi - e_atan2_tiny;
|
|
19211
|
+
}
|
|
19212
|
+
}
|
|
19213
|
+
if ((ix >>> 0 | lx >>> 0) >>> 0 >>> 0 == 0 >>> 0) {
|
|
19214
|
+
return hy < 0 ? -e_atan2_pi_o_2 - e_atan2_tiny : e_atan2_pi_o_2 + e_atan2_tiny;
|
|
19215
|
+
}
|
|
19216
|
+
if (ix == 2146435072) {
|
|
19217
|
+
if (iy == 2146435072) {
|
|
19218
|
+
switch (m) {
|
|
19219
|
+
case 0:
|
|
19220
|
+
return e_atan2_pi_o_4 + e_atan2_tiny;
|
|
19221
|
+
case 1:
|
|
19222
|
+
return -e_atan2_pi_o_4 - e_atan2_tiny;
|
|
19223
|
+
case 2:
|
|
19224
|
+
return 3 * e_atan2_pi_o_4 + e_atan2_tiny;
|
|
19225
|
+
case 3:
|
|
19226
|
+
return -3 * e_atan2_pi_o_4 - e_atan2_tiny;
|
|
19227
|
+
}
|
|
19228
|
+
} else {
|
|
19229
|
+
switch (m) {
|
|
19230
|
+
case 0:
|
|
19231
|
+
return e_atan2_zero;
|
|
19232
|
+
case 1:
|
|
19233
|
+
return -e_atan2_zero;
|
|
19234
|
+
case 2:
|
|
19235
|
+
return e_atan2_pi + e_atan2_tiny;
|
|
19236
|
+
case 3:
|
|
19237
|
+
return -e_atan2_pi - e_atan2_tiny;
|
|
19238
|
+
}
|
|
19239
|
+
}
|
|
19240
|
+
}
|
|
19241
|
+
if (iy == 2146435072) {
|
|
19242
|
+
return hy < 0 ? -e_atan2_pi_o_2 - e_atan2_tiny : e_atan2_pi_o_2 + e_atan2_tiny;
|
|
19243
|
+
}
|
|
19244
|
+
k = iy - ix >> 20 | 0;
|
|
19245
|
+
if (k > 60) {
|
|
19246
|
+
z = e_atan2_pi_o_2 + 0.5 * e_atan2_pi_lo;
|
|
19247
|
+
} else {
|
|
19248
|
+
if (hx < 0 && k < -60) {
|
|
19249
|
+
z = 0;
|
|
19250
|
+
} else {
|
|
19251
|
+
z = kernel_atan(Math.abs(y / x));
|
|
19252
|
+
}
|
|
19253
|
+
}
|
|
19254
|
+
switch (m) {
|
|
19255
|
+
case 0:
|
|
19256
|
+
return z;
|
|
19257
|
+
case 1:
|
|
19258
|
+
z = withHighWord(z, highWord(z) ^ 2147483648 | 0);
|
|
19259
|
+
return z;
|
|
19260
|
+
case 2:
|
|
19261
|
+
return e_atan2_pi - (z - e_atan2_pi_lo);
|
|
19262
|
+
default:
|
|
19263
|
+
return z - e_atan2_pi_lo - e_atan2_pi;
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
19266
|
+
var e_rem_pio2_two_over_pi = [
|
|
19267
|
+
10680707,
|
|
19268
|
+
7228996,
|
|
19269
|
+
1387004,
|
|
19270
|
+
2578385,
|
|
19271
|
+
16069853,
|
|
19272
|
+
12639074,
|
|
19273
|
+
9804092,
|
|
19274
|
+
4427841,
|
|
19275
|
+
16666979,
|
|
19276
|
+
11263675,
|
|
19277
|
+
12935607,
|
|
19278
|
+
2387514,
|
|
19279
|
+
4345298,
|
|
19280
|
+
14681673,
|
|
19281
|
+
3074569,
|
|
19282
|
+
13734428,
|
|
19283
|
+
16653803,
|
|
19284
|
+
1880361,
|
|
19285
|
+
10960616,
|
|
19286
|
+
8533493,
|
|
19287
|
+
3062596,
|
|
19288
|
+
8710556,
|
|
19289
|
+
7349940,
|
|
19290
|
+
6258241,
|
|
19291
|
+
3772886,
|
|
19292
|
+
3769171,
|
|
19293
|
+
3798172,
|
|
19294
|
+
8675211,
|
|
19295
|
+
12450088,
|
|
19296
|
+
3874808,
|
|
19297
|
+
9961438,
|
|
19298
|
+
366607,
|
|
19299
|
+
15675153,
|
|
19300
|
+
9132554,
|
|
19301
|
+
7151469,
|
|
19302
|
+
3571407,
|
|
19303
|
+
2607881,
|
|
19304
|
+
12013382,
|
|
19305
|
+
4155038,
|
|
19306
|
+
6285869,
|
|
19307
|
+
7677882,
|
|
19308
|
+
13102053,
|
|
19309
|
+
15825725,
|
|
19310
|
+
473591,
|
|
19311
|
+
9065106,
|
|
19312
|
+
15363067,
|
|
19313
|
+
6271263,
|
|
19314
|
+
9264392,
|
|
19315
|
+
5636912,
|
|
19316
|
+
4652155,
|
|
19317
|
+
7056368,
|
|
19318
|
+
13614112,
|
|
19319
|
+
10155062,
|
|
19320
|
+
1944035,
|
|
19321
|
+
9527646,
|
|
19322
|
+
15080200,
|
|
19323
|
+
6658437,
|
|
19324
|
+
6231200,
|
|
19325
|
+
6832269,
|
|
19326
|
+
16767104,
|
|
19327
|
+
5075751,
|
|
19328
|
+
3212806,
|
|
19329
|
+
1398474,
|
|
19330
|
+
7579849,
|
|
19331
|
+
6349435,
|
|
19332
|
+
12618859
|
|
19333
|
+
];
|
|
19334
|
+
var e_rem_pio2_npio2_hw = [
|
|
19335
|
+
1073291771,
|
|
19336
|
+
1074340347,
|
|
19337
|
+
1074977148,
|
|
19338
|
+
1075388923,
|
|
19339
|
+
1075800698,
|
|
19340
|
+
1076025724,
|
|
19341
|
+
1076231611,
|
|
19342
|
+
1076437499,
|
|
19343
|
+
1076643386,
|
|
19344
|
+
1076849274,
|
|
19345
|
+
1076971356,
|
|
19346
|
+
1077074300,
|
|
19347
|
+
1077177244,
|
|
19348
|
+
1077280187,
|
|
19349
|
+
1077383131,
|
|
19350
|
+
1077486075,
|
|
19351
|
+
1077589019,
|
|
19352
|
+
1077691962,
|
|
19353
|
+
1077794906,
|
|
19354
|
+
1077897850,
|
|
19355
|
+
1077968460,
|
|
19356
|
+
1078019932,
|
|
19357
|
+
1078071404,
|
|
19358
|
+
1078122876,
|
|
19359
|
+
1078174348,
|
|
19360
|
+
1078225820,
|
|
19361
|
+
1078277292,
|
|
19362
|
+
1078328763,
|
|
19363
|
+
1078380235,
|
|
19364
|
+
1078431707,
|
|
19365
|
+
1078483179,
|
|
19366
|
+
1078534651
|
|
19367
|
+
];
|
|
19368
|
+
var e_rem_pio2_zero = 0;
|
|
19369
|
+
var e_rem_pio2_half = 0.5;
|
|
19370
|
+
var e_rem_pio2_two24 = 16777216;
|
|
19371
|
+
var e_rem_pio2_invpio2 = 0.6366197723675814;
|
|
19372
|
+
var e_rem_pio2_pio2_1 = 1.5707963267341256;
|
|
19373
|
+
var e_rem_pio2_pio2_1t = 6077100506506192e-26;
|
|
19374
|
+
var e_rem_pio2_pio2_2 = 6077100506303966e-26;
|
|
19375
|
+
var e_rem_pio2_pio2_2t = 20222662487959506e-37;
|
|
19376
|
+
var e_rem_pio2_pio2_3 = 20222662487111665e-37;
|
|
19377
|
+
var e_rem_pio2_pio2_3t = 84784276603689e-45;
|
|
19378
|
+
function kernel___ieee754_rem_pio2(x, y) {
|
|
19379
|
+
let z = 0;
|
|
19380
|
+
let w = 0;
|
|
19381
|
+
let t = 0;
|
|
19382
|
+
let r = 0;
|
|
19383
|
+
let fn = 0;
|
|
19384
|
+
const tx = e_rem_pio2_tx;
|
|
19385
|
+
let e0 = 0;
|
|
19386
|
+
let i = 0;
|
|
19387
|
+
let j = 0;
|
|
19388
|
+
let nx = 0;
|
|
19389
|
+
let n = 0;
|
|
19390
|
+
let ix = 0;
|
|
19391
|
+
let hx = 0;
|
|
19392
|
+
hx = highWord(x) | 0;
|
|
19393
|
+
ix = hx & 2147483647 | 0;
|
|
19394
|
+
if (ix <= 1072243195) {
|
|
19395
|
+
y[0] = x;
|
|
19396
|
+
y[1] = 0;
|
|
19397
|
+
return 0 | 0;
|
|
19398
|
+
}
|
|
19399
|
+
if (ix < 1073928572) {
|
|
19400
|
+
if (hx > 0) {
|
|
19401
|
+
z = x - e_rem_pio2_pio2_1;
|
|
19402
|
+
if (ix != 1073291771) {
|
|
19403
|
+
y[0] = z - e_rem_pio2_pio2_1t;
|
|
19404
|
+
y[1] = z - y[0] - e_rem_pio2_pio2_1t;
|
|
19405
|
+
} else {
|
|
19406
|
+
z = z - e_rem_pio2_pio2_2;
|
|
19407
|
+
y[0] = z - e_rem_pio2_pio2_2t;
|
|
19408
|
+
y[1] = z - y[0] - e_rem_pio2_pio2_2t;
|
|
19409
|
+
}
|
|
19410
|
+
return 1 | 0;
|
|
19411
|
+
} else {
|
|
19412
|
+
z = x + e_rem_pio2_pio2_1;
|
|
19413
|
+
if (ix != 1073291771) {
|
|
19414
|
+
y[0] = z + e_rem_pio2_pio2_1t;
|
|
19415
|
+
y[1] = z - y[0] + e_rem_pio2_pio2_1t;
|
|
19416
|
+
} else {
|
|
19417
|
+
z = z + e_rem_pio2_pio2_2;
|
|
19418
|
+
y[0] = z + e_rem_pio2_pio2_2t;
|
|
19419
|
+
y[1] = z - y[0] + e_rem_pio2_pio2_2t;
|
|
19420
|
+
}
|
|
19421
|
+
return -1 | 0;
|
|
19422
|
+
}
|
|
19423
|
+
}
|
|
19424
|
+
if (ix <= 1094263291) {
|
|
19425
|
+
t = Math.abs(x);
|
|
19426
|
+
n = t * e_rem_pio2_invpio2 + e_rem_pio2_half | 0 | 0;
|
|
19427
|
+
fn = n;
|
|
19428
|
+
r = t - fn * e_rem_pio2_pio2_1;
|
|
19429
|
+
w = fn * e_rem_pio2_pio2_1t;
|
|
19430
|
+
if (n < 32 && ix != e_rem_pio2_npio2_hw[n - 1]) {
|
|
19431
|
+
y[0] = r - w;
|
|
19432
|
+
} else {
|
|
19433
|
+
j = ix >> 20 | 0;
|
|
19434
|
+
y[0] = r - w;
|
|
19435
|
+
i = j - (highWord(y[0]) >> 20 & 2047) | 0;
|
|
19436
|
+
if (i > 16) {
|
|
19437
|
+
t = r;
|
|
19438
|
+
w = fn * e_rem_pio2_pio2_2;
|
|
19439
|
+
r = t - w;
|
|
19440
|
+
w = fn * e_rem_pio2_pio2_2t - (t - r - w);
|
|
19441
|
+
y[0] = r - w;
|
|
19442
|
+
i = j - (highWord(y[0]) >> 20 & 2047) | 0;
|
|
19443
|
+
if (i > 49) {
|
|
19444
|
+
t = r;
|
|
19445
|
+
w = fn * e_rem_pio2_pio2_3;
|
|
19446
|
+
r = t - w;
|
|
19447
|
+
w = fn * e_rem_pio2_pio2_3t - (t - r - w);
|
|
19448
|
+
y[0] = r - w;
|
|
19449
|
+
}
|
|
19450
|
+
}
|
|
19451
|
+
}
|
|
19452
|
+
y[1] = r - y[0] - w;
|
|
19453
|
+
if (hx < 0) {
|
|
19454
|
+
y[0] = -y[0];
|
|
19455
|
+
y[1] = -y[1];
|
|
19456
|
+
return -n | 0;
|
|
19457
|
+
} else {
|
|
19458
|
+
return n | 0;
|
|
19459
|
+
}
|
|
19460
|
+
}
|
|
19461
|
+
if (ix >= 2146435072) {
|
|
19462
|
+
y[0] = y[1] = x - x;
|
|
19463
|
+
return 0 | 0;
|
|
19464
|
+
}
|
|
19465
|
+
z = withLowWord(z, lowWord(x) | 0);
|
|
19466
|
+
e0 = (ix >> 20) - 1046 | 0;
|
|
19467
|
+
z = withHighWord(z, ix - (e0 << 20) | 0);
|
|
19468
|
+
for (i = 0 | 0; i < 2; i++) {
|
|
19469
|
+
tx[i] = z | 0;
|
|
19470
|
+
z = (z - tx[i]) * e_rem_pio2_two24;
|
|
19471
|
+
}
|
|
19472
|
+
tx[2] = z;
|
|
19473
|
+
nx = 3 | 0;
|
|
19474
|
+
while (tx[nx - 1] == e_rem_pio2_zero) {
|
|
19475
|
+
nx--;
|
|
19476
|
+
}
|
|
19477
|
+
n = kernel___kernel_rem_pio2(tx, y, e0, nx, 2, e_rem_pio2_two_over_pi) | 0;
|
|
19478
|
+
if (hx < 0) {
|
|
19479
|
+
y[0] = -y[0];
|
|
19480
|
+
y[1] = -y[1];
|
|
19481
|
+
return -n | 0;
|
|
19482
|
+
}
|
|
19483
|
+
return n | 0;
|
|
19484
|
+
}
|
|
19485
|
+
var k_rem_pio2_init_jk = [2, 3, 4, 6];
|
|
19486
|
+
var k_rem_pio2_PIo2 = [
|
|
19487
|
+
1.570796251296997,
|
|
19488
|
+
7549789415861596e-23,
|
|
19489
|
+
5390302529957765e-30,
|
|
19490
|
+
3282003415807913e-37,
|
|
19491
|
+
1270655753080676e-44,
|
|
19492
|
+
12293330898111133e-52,
|
|
19493
|
+
27337005381646456e-60,
|
|
19494
|
+
21674168387780482e-67
|
|
19495
|
+
];
|
|
19496
|
+
var k_rem_pio2_zero = 0;
|
|
19497
|
+
var k_rem_pio2_one = 1;
|
|
19498
|
+
var k_rem_pio2_two24 = 16777216;
|
|
19499
|
+
var k_rem_pio2_twon24 = 5960464477539063e-23;
|
|
19500
|
+
function kernel___kernel_rem_pio2(x, y, e0, nx, prec, ipio2) {
|
|
19501
|
+
let jz = 0;
|
|
19502
|
+
let jx = 0;
|
|
19503
|
+
let jv = 0;
|
|
19504
|
+
let jp = 0;
|
|
19505
|
+
let jk = 0;
|
|
19506
|
+
let carry = 0;
|
|
19507
|
+
let n = 0;
|
|
19508
|
+
const iq = k_rem_pio2_iq;
|
|
19509
|
+
let i = 0;
|
|
19510
|
+
let j = 0;
|
|
19511
|
+
let k = 0;
|
|
19512
|
+
let m = 0;
|
|
19513
|
+
let q0 = 0;
|
|
19514
|
+
let ih = 0;
|
|
19515
|
+
let z = 0;
|
|
19516
|
+
let fw = 0;
|
|
19517
|
+
const f = k_rem_pio2_f;
|
|
19518
|
+
const fq = k_rem_pio2_fq;
|
|
19519
|
+
const q = k_rem_pio2_q;
|
|
19520
|
+
jk = k_rem_pio2_init_jk[prec] | 0;
|
|
19521
|
+
jp = jk | 0;
|
|
19522
|
+
jx = nx - 1 | 0;
|
|
19523
|
+
jv = (e0 - 3) / 24 | 0 | 0;
|
|
19524
|
+
if (jv < 0) {
|
|
19525
|
+
jv = 0 | 0;
|
|
19526
|
+
}
|
|
19527
|
+
q0 = e0 - 24 * (jv + 1) | 0;
|
|
19528
|
+
j = jv - jx | 0;
|
|
19529
|
+
m = jx + jk | 0;
|
|
19530
|
+
for (i = 0 | 0; i <= m; i++, j++) {
|
|
19531
|
+
f[i] = j < 0 ? k_rem_pio2_zero : ipio2[j];
|
|
19532
|
+
}
|
|
19533
|
+
for (i = 0 | 0; i <= jk; i++) {
|
|
19534
|
+
for (j = 0 | 0, fw = 0; j <= jx; j++) {
|
|
19535
|
+
fw = fw + x[j] * f[jx + i - j];
|
|
19536
|
+
}
|
|
19537
|
+
q[i] = fw;
|
|
19538
|
+
}
|
|
19539
|
+
jz = jk | 0;
|
|
19540
|
+
while (true) {
|
|
19541
|
+
for (i = 0 | 0, j = jz | 0, z = q[jz]; j > 0; i++, j--) {
|
|
19542
|
+
fw = k_rem_pio2_twon24 * z | 0;
|
|
19543
|
+
iq[i] = z - k_rem_pio2_two24 * fw | 0 | 0;
|
|
19544
|
+
z = q[j - 1] + fw;
|
|
19545
|
+
}
|
|
19546
|
+
z = kernel_scalbn(z, q0);
|
|
19547
|
+
z = z - 8 * Math.floor(z * 0.125);
|
|
19548
|
+
n = z | 0 | 0;
|
|
19549
|
+
z = z - n;
|
|
19550
|
+
ih = 0 | 0;
|
|
19551
|
+
if (q0 > 0) {
|
|
19552
|
+
i = iq[jz - 1] >> 24 - q0 | 0;
|
|
19553
|
+
n = n + i | 0;
|
|
19554
|
+
iq[jz - 1] = iq[jz - 1] - (i << 24 - q0) | 0;
|
|
19555
|
+
ih = iq[jz - 1] >> 23 - q0 | 0;
|
|
19556
|
+
} else {
|
|
19557
|
+
if (q0 == 0) {
|
|
19558
|
+
ih = iq[jz - 1] >> 23 | 0;
|
|
19559
|
+
} else {
|
|
19560
|
+
if (z >= 0.5) {
|
|
19561
|
+
ih = 2 | 0;
|
|
19562
|
+
}
|
|
19563
|
+
}
|
|
19564
|
+
}
|
|
19565
|
+
if (ih > 0) {
|
|
19566
|
+
n = n + 1 | 0;
|
|
19567
|
+
carry = 0 | 0;
|
|
19568
|
+
for (i = 0 | 0; i < jz; i++) {
|
|
19569
|
+
j = iq[i] | 0;
|
|
19570
|
+
if (carry == 0) {
|
|
19571
|
+
if (j != 0) {
|
|
19572
|
+
carry = 1 | 0;
|
|
19573
|
+
iq[i] = 16777216 - j | 0;
|
|
19574
|
+
}
|
|
19575
|
+
} else {
|
|
19576
|
+
iq[i] = 16777215 - j | 0;
|
|
19577
|
+
}
|
|
19578
|
+
}
|
|
19579
|
+
if (q0 > 0) {
|
|
19580
|
+
switch (q0) {
|
|
19581
|
+
case 1:
|
|
19582
|
+
iq[jz - 1] = iq[jz - 1] & 8388607 | 0;
|
|
19583
|
+
break;
|
|
19584
|
+
case 2:
|
|
19585
|
+
iq[jz - 1] = iq[jz - 1] & 4194303 | 0;
|
|
19586
|
+
break;
|
|
19587
|
+
}
|
|
19588
|
+
}
|
|
19589
|
+
if (ih == 2) {
|
|
19590
|
+
z = k_rem_pio2_one - z;
|
|
19591
|
+
if (carry != 0) {
|
|
19592
|
+
z = z - kernel_scalbn(k_rem_pio2_one, q0);
|
|
19593
|
+
}
|
|
19594
|
+
}
|
|
19595
|
+
}
|
|
19596
|
+
if (z == k_rem_pio2_zero) {
|
|
19597
|
+
j = 0 | 0;
|
|
19598
|
+
for (i = jz - 1 | 0; i >= jk; i--) {
|
|
19599
|
+
j = j | iq[i] | 0;
|
|
19600
|
+
}
|
|
19601
|
+
if (j == 0) {
|
|
19602
|
+
for (k = 1 | 0; iq[jk - k] == 0; k++) {
|
|
19603
|
+
}
|
|
19604
|
+
for (i = jz + 1 | 0; i <= jz + k; i++) {
|
|
19605
|
+
f[jx + i] = ipio2[jv + i];
|
|
19606
|
+
for (j = 0 | 0, fw = 0; j <= jx; j++) {
|
|
19607
|
+
fw = fw + x[j] * f[jx + i - j];
|
|
19608
|
+
}
|
|
19609
|
+
q[i] = fw;
|
|
19610
|
+
}
|
|
19611
|
+
jz = jz + k | 0;
|
|
19612
|
+
continue;
|
|
19613
|
+
}
|
|
19614
|
+
}
|
|
19615
|
+
break;
|
|
19616
|
+
}
|
|
19617
|
+
if (z == 0) {
|
|
19618
|
+
jz = jz - 1 | 0;
|
|
19619
|
+
q0 = q0 - 24 | 0;
|
|
19620
|
+
while (iq[jz] == 0) {
|
|
19621
|
+
jz--;
|
|
19622
|
+
q0 = q0 - 24 | 0;
|
|
19623
|
+
}
|
|
19624
|
+
} else {
|
|
19625
|
+
z = kernel_scalbn(z, -q0);
|
|
19626
|
+
if (z >= k_rem_pio2_two24) {
|
|
19627
|
+
fw = k_rem_pio2_twon24 * z | 0;
|
|
19628
|
+
iq[jz] = z - k_rem_pio2_two24 * fw | 0 | 0;
|
|
19629
|
+
jz = jz + 1 | 0;
|
|
19630
|
+
q0 = q0 + 24 | 0;
|
|
19631
|
+
iq[jz] = fw | 0 | 0;
|
|
19632
|
+
} else {
|
|
19633
|
+
iq[jz] = z | 0 | 0;
|
|
19634
|
+
}
|
|
19635
|
+
}
|
|
19636
|
+
fw = kernel_scalbn(k_rem_pio2_one, q0);
|
|
19637
|
+
for (i = jz | 0; i >= 0; i--) {
|
|
19638
|
+
q[i] = fw * iq[i];
|
|
19639
|
+
fw = fw * k_rem_pio2_twon24;
|
|
19640
|
+
}
|
|
19641
|
+
for (i = jz | 0; i >= 0; i--) {
|
|
19642
|
+
for (fw = 0, k = 0 | 0; k <= jp && k <= jz - i; k++) {
|
|
19643
|
+
fw = fw + k_rem_pio2_PIo2[k] * q[i + k];
|
|
19644
|
+
}
|
|
19645
|
+
fq[jz - i] = fw;
|
|
19646
|
+
}
|
|
19647
|
+
switch (prec) {
|
|
19648
|
+
case 0:
|
|
19649
|
+
fw = 0;
|
|
19650
|
+
for (i = jz | 0; i >= 0; i--) {
|
|
19651
|
+
fw = fw + fq[i];
|
|
19652
|
+
}
|
|
19653
|
+
y[0] = ih == 0 ? fw : -fw;
|
|
19654
|
+
break;
|
|
19655
|
+
case 1:
|
|
19656
|
+
case 2:
|
|
19657
|
+
fw = 0;
|
|
19658
|
+
for (i = jz | 0; i >= 0; i--) {
|
|
19659
|
+
fw = fw + fq[i];
|
|
19660
|
+
}
|
|
19661
|
+
y[0] = ih == 0 ? fw : -fw;
|
|
19662
|
+
fw = fq[0] - fw;
|
|
19663
|
+
for (i = 1 | 0; i <= jz; i++) {
|
|
19664
|
+
fw = fw + fq[i];
|
|
19665
|
+
}
|
|
19666
|
+
y[1] = ih == 0 ? fw : -fw;
|
|
19667
|
+
break;
|
|
19668
|
+
case 3:
|
|
19669
|
+
for (i = jz | 0; i > 0; i--) {
|
|
19670
|
+
fw = fq[i - 1] + fq[i];
|
|
19671
|
+
fq[i] = fq[i] + (fq[i - 1] - fw);
|
|
19672
|
+
fq[i - 1] = fw;
|
|
19673
|
+
}
|
|
19674
|
+
for (i = jz | 0; i > 1; i--) {
|
|
19675
|
+
fw = fq[i - 1] + fq[i];
|
|
19676
|
+
fq[i] = fq[i] + (fq[i - 1] - fw);
|
|
19677
|
+
fq[i - 1] = fw;
|
|
19678
|
+
}
|
|
19679
|
+
for (fw = 0, i = jz | 0; i >= 2; i--) {
|
|
19680
|
+
fw = fw + fq[i];
|
|
19681
|
+
}
|
|
19682
|
+
if (ih == 0) {
|
|
19683
|
+
y[0] = fq[0];
|
|
19684
|
+
y[1] = fq[1];
|
|
19685
|
+
y[2] = fw;
|
|
19686
|
+
} else {
|
|
19687
|
+
y[0] = -fq[0];
|
|
19688
|
+
y[1] = -fq[1];
|
|
19689
|
+
y[2] = -fw;
|
|
19690
|
+
}
|
|
19691
|
+
break;
|
|
19692
|
+
}
|
|
19693
|
+
return n & 7 | 0;
|
|
19694
|
+
}
|
|
19695
|
+
var k_sin_half = 0.5;
|
|
19696
|
+
var k_sin_S1 = -0.16666666666666632;
|
|
19697
|
+
var k_sin_S2 = 0.00833333333332249;
|
|
19698
|
+
var k_sin_S3 = -1984126982985795e-19;
|
|
19699
|
+
var k_sin_S4 = 27557313707070068e-22;
|
|
19700
|
+
var k_sin_S5 = -25050760253406863e-24;
|
|
19701
|
+
var k_sin_S6 = 158969099521155e-24;
|
|
19702
|
+
function kernel___kernel_sin(x, y, iy) {
|
|
19703
|
+
let z = 0;
|
|
19704
|
+
let r = 0;
|
|
19705
|
+
let v = 0;
|
|
19706
|
+
let ix = 0;
|
|
19707
|
+
ix = highWord(x) & 2147483647 | 0;
|
|
19708
|
+
if (ix < 1044381696) {
|
|
19709
|
+
if ((x | 0) == 0) {
|
|
19710
|
+
return x;
|
|
19711
|
+
}
|
|
19712
|
+
}
|
|
19713
|
+
z = x * x;
|
|
19714
|
+
v = z * x;
|
|
19715
|
+
r = k_sin_S2 + z * (k_sin_S3 + z * (k_sin_S4 + z * (k_sin_S5 + z * k_sin_S6)));
|
|
19716
|
+
if (iy == 0) {
|
|
19717
|
+
return x + v * (k_sin_S1 + z * r);
|
|
19718
|
+
} else {
|
|
19719
|
+
return x - (z * (k_sin_half * y - v * r) - y - v * k_sin_S1);
|
|
19720
|
+
}
|
|
19721
|
+
}
|
|
19722
|
+
var k_cos_one = 1;
|
|
19723
|
+
var k_cos_C1 = 0.0416666666666666;
|
|
19724
|
+
var k_cos_C2 = -0.001388888888887411;
|
|
19725
|
+
var k_cos_C3 = 2480158728947673e-20;
|
|
19726
|
+
var k_cos_C4 = -27557314351390663e-23;
|
|
19727
|
+
var k_cos_C5 = 2087572321298175e-24;
|
|
19728
|
+
var k_cos_C6 = -11359647557788195e-27;
|
|
19729
|
+
function kernel___kernel_cos(x, y) {
|
|
19730
|
+
let a = 0;
|
|
19731
|
+
let hz = 0;
|
|
19732
|
+
let z = 0;
|
|
19733
|
+
let r = 0;
|
|
19734
|
+
let qx = 0;
|
|
19735
|
+
let ix = 0;
|
|
19736
|
+
ix = highWord(x) & 2147483647 | 0;
|
|
19737
|
+
if (ix < 1044381696) {
|
|
19738
|
+
if ((x | 0) == 0) {
|
|
19739
|
+
return k_cos_one;
|
|
19740
|
+
}
|
|
19741
|
+
}
|
|
19742
|
+
z = x * x;
|
|
19743
|
+
r = z * (k_cos_C1 + z * (k_cos_C2 + z * (k_cos_C3 + z * (k_cos_C4 + z * (k_cos_C5 + z * k_cos_C6)))));
|
|
19744
|
+
if (ix < 1070805811) {
|
|
19745
|
+
return k_cos_one - (0.5 * z - (z * r - x * y));
|
|
19746
|
+
} else {
|
|
19747
|
+
if (ix > 1072234496) {
|
|
19748
|
+
qx = 0.28125;
|
|
19749
|
+
} else {
|
|
19750
|
+
qx = withHighWord(qx, ix - 2097152 | 0);
|
|
19751
|
+
qx = withLowWord(qx, 0 | 0);
|
|
19752
|
+
}
|
|
19753
|
+
hz = 0.5 * z - qx;
|
|
19754
|
+
a = k_cos_one - qx;
|
|
19755
|
+
return a - (hz - (z * r - x * y));
|
|
19756
|
+
}
|
|
19757
|
+
}
|
|
19758
|
+
var k_tan_xxx = [
|
|
19759
|
+
0.3333333333333341,
|
|
19760
|
+
0.13333333333320124,
|
|
19761
|
+
0.05396825397622605,
|
|
19762
|
+
0.021869488294859542,
|
|
19763
|
+
0.0088632398235993,
|
|
19764
|
+
0.0035920791075913124,
|
|
19765
|
+
0.0014562094543252903,
|
|
19766
|
+
5880412408202641e-19,
|
|
19767
|
+
2464631348184699e-19,
|
|
19768
|
+
7817944429395571e-20,
|
|
19769
|
+
7140724913826082e-20,
|
|
19770
|
+
-18558637485527546e-21,
|
|
19771
|
+
2590730518636337e-20,
|
|
19772
|
+
1,
|
|
19773
|
+
0.7853981633974483,
|
|
19774
|
+
3061616997868383e-32
|
|
19775
|
+
];
|
|
19776
|
+
function kernel___kernel_tan(x, y, iy) {
|
|
19777
|
+
let z = 0;
|
|
19778
|
+
let r = 0;
|
|
19779
|
+
let v = 0;
|
|
19780
|
+
let w = 0;
|
|
19781
|
+
let s = 0;
|
|
19782
|
+
let ix = 0;
|
|
19783
|
+
let hx = 0;
|
|
19784
|
+
hx = highWord(x) | 0;
|
|
19785
|
+
ix = hx & 2147483647 | 0;
|
|
19786
|
+
if (ix < 1043333120) {
|
|
19787
|
+
if ((x | 0) == 0) {
|
|
19788
|
+
if ((ix | lowWord(x) | iy + 1) == 0) {
|
|
19789
|
+
return k_tan_xxx[13] / Math.abs(x);
|
|
19790
|
+
} else {
|
|
19791
|
+
if (iy == 1) {
|
|
19792
|
+
return x;
|
|
19793
|
+
} else {
|
|
19794
|
+
let a = 0;
|
|
19795
|
+
let t = 0;
|
|
19796
|
+
z = w = x + y;
|
|
19797
|
+
z = withLowWord(z, 0 | 0);
|
|
19798
|
+
v = y - (z - x);
|
|
19799
|
+
t = a = -k_tan_xxx[13] / w;
|
|
19800
|
+
t = withLowWord(t, 0 | 0);
|
|
19801
|
+
s = k_tan_xxx[13] + t * z;
|
|
19802
|
+
return t + a * (s + t * v);
|
|
19803
|
+
}
|
|
19804
|
+
}
|
|
19805
|
+
}
|
|
19806
|
+
}
|
|
19807
|
+
if (ix >= 1072010280) {
|
|
19808
|
+
if (hx < 0) {
|
|
19809
|
+
x = -x;
|
|
19810
|
+
y = -y;
|
|
19811
|
+
}
|
|
19812
|
+
z = k_tan_xxx[14] - x;
|
|
19813
|
+
w = k_tan_xxx[15] - y;
|
|
19814
|
+
x = z + w;
|
|
19815
|
+
y = 0;
|
|
19816
|
+
}
|
|
19817
|
+
z = x * x;
|
|
19818
|
+
w = z * z;
|
|
19819
|
+
r = k_tan_xxx[1] + w * (k_tan_xxx[3] + w * (k_tan_xxx[5] + w * (k_tan_xxx[7] + w * (k_tan_xxx[9] + w * k_tan_xxx[11]))));
|
|
19820
|
+
v = z * (k_tan_xxx[2] + w * (k_tan_xxx[4] + w * (k_tan_xxx[6] + w * (k_tan_xxx[8] + w * (k_tan_xxx[10] + w * k_tan_xxx[12])))));
|
|
19821
|
+
s = z * x;
|
|
19822
|
+
r = y + z * (s * (r + v) + y);
|
|
19823
|
+
r = r + k_tan_xxx[0] * s;
|
|
19824
|
+
w = x + r;
|
|
19825
|
+
if (ix >= 1072010280) {
|
|
19826
|
+
v = iy;
|
|
19827
|
+
return (1 - (hx >> 30 & 2)) * (v - 2 * (x - (w * w / (w + v) - r)));
|
|
19828
|
+
}
|
|
19829
|
+
if (iy == 1) {
|
|
19830
|
+
return w;
|
|
19831
|
+
} else {
|
|
19832
|
+
let a = 0;
|
|
19833
|
+
let t = 0;
|
|
19834
|
+
z = w;
|
|
19835
|
+
z = withLowWord(z, 0 | 0);
|
|
19836
|
+
v = r - (z - x);
|
|
19837
|
+
t = a = -1 / w;
|
|
19838
|
+
t = withLowWord(t, 0 | 0);
|
|
19839
|
+
s = 1 + t * z;
|
|
19840
|
+
return t + a * (s + t * v);
|
|
19841
|
+
}
|
|
19842
|
+
}
|
|
19843
|
+
var s_scalbn_two54 = 18014398509481984;
|
|
19844
|
+
var s_scalbn_twom54 = 5551115123125783e-32;
|
|
19845
|
+
var s_scalbn_huge = 1e300;
|
|
19846
|
+
var s_scalbn_tiny = 1e-300;
|
|
19847
|
+
function kernel_scalbn(x, n) {
|
|
19848
|
+
let k = 0;
|
|
19849
|
+
let hx = 0;
|
|
19850
|
+
let lx = 0;
|
|
19851
|
+
hx = highWord(x) | 0;
|
|
19852
|
+
lx = lowWord(x) | 0;
|
|
19853
|
+
k = (hx & 2146435072) >> 20 | 0;
|
|
19854
|
+
if (k == 0) {
|
|
19855
|
+
if ((lx | hx & 2147483647) == 0) {
|
|
19856
|
+
return x;
|
|
19857
|
+
}
|
|
19858
|
+
x = x * s_scalbn_two54;
|
|
19859
|
+
hx = highWord(x) | 0;
|
|
19860
|
+
k = ((hx & 2146435072) >> 20) - 54 | 0;
|
|
19861
|
+
if (n < -5e4) {
|
|
19862
|
+
return s_scalbn_tiny * x;
|
|
19863
|
+
}
|
|
19864
|
+
}
|
|
19865
|
+
if (k == 2047) {
|
|
19866
|
+
return x + x;
|
|
19867
|
+
}
|
|
19868
|
+
k = k + n | 0;
|
|
19869
|
+
if (k > 2046) {
|
|
19870
|
+
return s_scalbn_huge * copysign(s_scalbn_huge, x);
|
|
19871
|
+
}
|
|
19872
|
+
if (k > 0) {
|
|
19873
|
+
x = withHighWord(
|
|
19874
|
+
x,
|
|
19875
|
+
((hx >>> 0 & 2148532223 >>> 0) >>> 0 >>> 0 | k << 20 >>> 0) >>> 0 | 0
|
|
19876
|
+
);
|
|
19877
|
+
return x;
|
|
19878
|
+
}
|
|
19879
|
+
if (k <= -54) {
|
|
19880
|
+
if (n > 5e4) {
|
|
19881
|
+
return s_scalbn_huge * copysign(s_scalbn_huge, x);
|
|
19882
|
+
} else {
|
|
19883
|
+
return s_scalbn_tiny * copysign(s_scalbn_tiny, x);
|
|
19884
|
+
}
|
|
19885
|
+
}
|
|
19886
|
+
k = k + 54 | 0;
|
|
19887
|
+
x = withHighWord(
|
|
19888
|
+
x,
|
|
19889
|
+
((hx >>> 0 & 2148532223 >>> 0) >>> 0 >>> 0 | k << 20 >>> 0) >>> 0 | 0
|
|
19890
|
+
);
|
|
19891
|
+
return x * s_scalbn_twom54;
|
|
19892
|
+
}
|
|
19893
|
+
function pow(x, y) {
|
|
19894
|
+
return Math.fround(
|
|
19895
|
+
x == 1 || x == -1 && !Number.isFinite(y) && !Number.isNaN(y) ? 1 : kernel___ieee754_pow(x, y)
|
|
19896
|
+
);
|
|
19897
|
+
}
|
|
19898
|
+
function exp(x) {
|
|
19899
|
+
return Math.fround(kernel___ieee754_exp(x));
|
|
19900
|
+
}
|
|
19901
|
+
function log(x) {
|
|
19902
|
+
return Math.fround(kernel___ieee754_log(x));
|
|
19903
|
+
}
|
|
19904
|
+
function log10(x) {
|
|
19905
|
+
return Math.fround(kernel___ieee754_log10(x));
|
|
19906
|
+
}
|
|
19907
|
+
function sin(x) {
|
|
19908
|
+
return Math.fround(kernel_sin(x));
|
|
19909
|
+
}
|
|
19910
|
+
function cos(x) {
|
|
19911
|
+
return Math.fround(kernel_cos(x));
|
|
19912
|
+
}
|
|
19913
|
+
function tan(x) {
|
|
19914
|
+
return Math.fround(kernel_tan(x));
|
|
19915
|
+
}
|
|
19916
|
+
function asin(x) {
|
|
19917
|
+
return Math.fround(kernel___ieee754_asin(x));
|
|
19918
|
+
}
|
|
19919
|
+
function acos(x) {
|
|
19920
|
+
return Math.fround(kernel___ieee754_acos(x));
|
|
19921
|
+
}
|
|
19922
|
+
function atan(x) {
|
|
19923
|
+
return Math.fround(kernel_atan(x));
|
|
19924
|
+
}
|
|
19925
|
+
function atan2(x, y) {
|
|
19926
|
+
return Math.fround(kernel___ieee754_atan2(x, y));
|
|
19927
|
+
}
|
|
19928
|
+
|
|
19929
|
+
// ../packages/neoscript-runtime/src/neoscript/math/extended-math.ts
|
|
19930
|
+
function clamp(value, min, max) {
|
|
19931
|
+
if (value < min) return min;
|
|
19932
|
+
if (value > max) return max;
|
|
19933
|
+
return value;
|
|
19934
|
+
}
|
|
19935
|
+
function repeat(t, length) {
|
|
19936
|
+
const quotient = Math.fround(t / length);
|
|
19937
|
+
if (!Number.isFinite(quotient)) return NaN;
|
|
19938
|
+
const multiple = Math.fround(Math.floor(quotient) * length);
|
|
19939
|
+
if (!Number.isFinite(multiple)) return NaN;
|
|
19940
|
+
return clamp(Math.fround(t - multiple), 0, length);
|
|
19941
|
+
}
|
|
19942
|
+
function requireRepeatDomain(name, t, length) {
|
|
19943
|
+
if (!Number.isFinite(t)) {
|
|
19944
|
+
throw new NSGetterRuntimeError(`Math.${name} requires finite t.`, {
|
|
19945
|
+
errorClassId: NEO_ERROR_CLASS_IDS.NeoArgumentError
|
|
19946
|
+
});
|
|
19947
|
+
}
|
|
19948
|
+
if (!Number.isFinite(length)) {
|
|
19949
|
+
throw new NSGetterRuntimeError(`Math.${name} requires finite length.`, {
|
|
19950
|
+
errorClassId: NEO_ERROR_CLASS_IDS.NeoArgumentError
|
|
19951
|
+
});
|
|
19952
|
+
}
|
|
19953
|
+
if (length <= 0) {
|
|
19954
|
+
throw new NSGetterRuntimeError(`Math.${name} requires length > 0.`, {
|
|
19955
|
+
errorClassId: NEO_ERROR_CLASS_IDS.NeoArgumentError
|
|
19956
|
+
});
|
|
19957
|
+
}
|
|
19958
|
+
}
|
|
19959
|
+
function evaluateExtendedMath(op, a, b = 0, c = 0) {
|
|
19960
|
+
switch (op) {
|
|
19961
|
+
case "pow":
|
|
19962
|
+
return pow(a, b);
|
|
19963
|
+
case "exp":
|
|
19964
|
+
return exp(a);
|
|
19965
|
+
case "log":
|
|
19966
|
+
return log(a);
|
|
19967
|
+
case "log10":
|
|
19968
|
+
return log10(a);
|
|
19969
|
+
case "sin":
|
|
19970
|
+
return sin(a);
|
|
19971
|
+
case "cos":
|
|
19972
|
+
return cos(a);
|
|
19973
|
+
case "tan":
|
|
19974
|
+
return tan(a);
|
|
19975
|
+
case "asin":
|
|
19976
|
+
return asin(a);
|
|
19977
|
+
case "acos":
|
|
19978
|
+
return acos(a);
|
|
19979
|
+
case "atan":
|
|
19980
|
+
return atan(a);
|
|
19981
|
+
case "atan2":
|
|
19982
|
+
return atan2(a, b);
|
|
19983
|
+
case "lerp":
|
|
19984
|
+
return Math.fround(a + Math.fround(Math.fround(b - a) * clamp(c, 0, 1)));
|
|
19985
|
+
case "inverselerp":
|
|
19986
|
+
return a === b ? 0 : clamp(Math.fround(Math.fround(c - a) / Math.fround(b - a)), 0, 1);
|
|
19987
|
+
case "movetowards": {
|
|
19988
|
+
const delta = Math.fround(b - a);
|
|
19989
|
+
if (Math.abs(delta) <= c) return b;
|
|
19990
|
+
const sign = delta >= 0 ? 1 : -1;
|
|
19991
|
+
return Math.fround(a + Math.fround(sign * c));
|
|
19992
|
+
}
|
|
19993
|
+
case "repeat":
|
|
19994
|
+
requireRepeatDomain("Repeat", a, b);
|
|
19995
|
+
return repeat(a, b);
|
|
19996
|
+
case "pingpong": {
|
|
19997
|
+
requireRepeatDomain("PingPong", a, b);
|
|
19998
|
+
const period = Math.fround(2 * b);
|
|
19999
|
+
if (!Number.isFinite(period)) return NaN;
|
|
20000
|
+
return Math.fround(b - Math.abs(Math.fround(repeat(a, period) - b)));
|
|
20001
|
+
}
|
|
20002
|
+
default:
|
|
20003
|
+
throw new NSGetterRuntimeError(`Unknown extended math op '${op}'.`);
|
|
20004
|
+
}
|
|
20005
|
+
}
|
|
20006
|
+
|
|
17964
20007
|
// ../packages/neoscript-runtime/src/neoscript/tuple-handle-identity.ts
|
|
17965
20008
|
var TupleHandleIdentity = class {
|
|
17966
20009
|
objects = /* @__PURE__ */ new WeakMap();
|
|
@@ -23244,6 +25287,7 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
|
|
|
23244
25287
|
const requestedWrites = [];
|
|
23245
25288
|
const runtimeCtx = withEvaluationRuntime(ctx, requestedWrites);
|
|
23246
25289
|
checkDeadline(runtimeCtx);
|
|
25290
|
+
const randomDrawCheckpoint = runtimeCtx.__executionState?.randomDraws ?? 0;
|
|
23247
25291
|
const writes = runtimeCtx.__executionState?.writes ?? requestedWrites;
|
|
23248
25292
|
const writeCheckpoint = writes.length;
|
|
23249
25293
|
const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
|
|
@@ -23368,6 +25412,8 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
|
|
|
23368
25412
|
}
|
|
23369
25413
|
rejectEscapedLoopTransfer(result, "NeoScript getter");
|
|
23370
25414
|
} catch (error) {
|
|
25415
|
+
if (error instanceof NSGetterRuntimeError && runtimeCtx.randomIdentity !== void 0 && isPendingId(runtimeCtx.randomIdentity) && (runtimeCtx.__executionState?.randomDraws ?? 0) > randomDrawCheckpoint)
|
|
25416
|
+
error.provisionalRandomFailure = true;
|
|
23371
25417
|
finalizeConstructorAllocations(
|
|
23372
25418
|
runtimeCtx,
|
|
23373
25419
|
void 0,
|
|
@@ -23525,6 +25571,10 @@ function withEvaluationRuntime(ctx, writes) {
|
|
|
23525
25571
|
__dirtyRuntimeSets: ctx.__dirtyRuntimeSets ?? /* @__PURE__ */ new Set(),
|
|
23526
25572
|
__runtimeReferenceRemap: referenceRemap,
|
|
23527
25573
|
__executionState: ctx.__executionState ?? {
|
|
25574
|
+
randomDraws: 0,
|
|
25575
|
+
random: ctx.random,
|
|
25576
|
+
randomIdentity: ctx.randomIdentity,
|
|
25577
|
+
randomSource: ctx.randomSource,
|
|
23528
25578
|
exceptionHandlers: [],
|
|
23529
25579
|
activeScopes: [],
|
|
23530
25580
|
caughtErrors: [],
|
|
@@ -25903,6 +27953,9 @@ function keepAssignedCollectionValues(value, targetTypeInfo, ctx) {
|
|
|
25903
27953
|
}
|
|
25904
27954
|
}
|
|
25905
27955
|
function replaceRowValue(row, value, receiver, ctx) {
|
|
27956
|
+
if (row.value !== value) {
|
|
27957
|
+
(ctx.__executionState?.random ?? ctx.random ?? ctx.vm.databaseVM?.random)?.forgetInstance(row.id);
|
|
27958
|
+
}
|
|
25906
27959
|
const indexes4 = ctx.__indexes;
|
|
25907
27960
|
if (indexes4 === void 0 || ctx.__runtimeSessionValues?.get(row.id) !== row || !indexes4.indexedRowIds.has(row.id)) {
|
|
25908
27961
|
row.value = value;
|
|
@@ -28081,7 +30134,12 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
|
|
|
28081
30134
|
if (member.kind === 13 /* Function */) {
|
|
28082
30135
|
const systemResult = evaluateSystemNative(
|
|
28083
30136
|
member.id,
|
|
28084
|
-
{
|
|
30137
|
+
{
|
|
30138
|
+
receiverKind: pointer.receiver.kind,
|
|
30139
|
+
receiver: innerThis,
|
|
30140
|
+
args,
|
|
30141
|
+
typeArguments
|
|
30142
|
+
},
|
|
28085
30143
|
ctx
|
|
28086
30144
|
);
|
|
28087
30145
|
if (systemResult.handled) return systemResult.value;
|
|
@@ -28452,6 +30510,7 @@ function invokeDelegateValue(value, args, ctx, callSiteId, ownerReceiver, result
|
|
|
28452
30510
|
const systemResult = evaluateSystemNative(
|
|
28453
30511
|
member.id,
|
|
28454
30512
|
{
|
|
30513
|
+
receiverKind: isStaticMember(member) ? "static" : "instance",
|
|
28455
30514
|
receiver,
|
|
28456
30515
|
args,
|
|
28457
30516
|
typeArguments: calleeTypeArguments(void 0, member, ctx)
|
|
@@ -29965,27 +32024,31 @@ function readDeclarationDefault(member, ctx) {
|
|
|
29965
32024
|
const created = [];
|
|
29966
32025
|
const closeFrame = pushConstructionFrame(ctx, `${member.name} declaration`);
|
|
29967
32026
|
try {
|
|
29968
|
-
const root =
|
|
29969
|
-
|
|
29970
|
-
|
|
29971
|
-
|
|
29972
|
-
|
|
29973
|
-
|
|
29974
|
-
|
|
29975
|
-
|
|
29976
|
-
genericEnv
|
|
29977
|
-
() => evaluateInitializerInContext(
|
|
29978
|
-
init,
|
|
32027
|
+
const root = withContentRandom(
|
|
32028
|
+
ctx,
|
|
32029
|
+
member.id,
|
|
32030
|
+
() => buildDefaultMemberValue({
|
|
32031
|
+
document: document2,
|
|
32032
|
+
projectId: ctx.vm.project.id,
|
|
32033
|
+
member,
|
|
32034
|
+
createdValues: created,
|
|
32035
|
+
initEvaluator: (child, init, sourceValueId, genericEnv = /* @__PURE__ */ new Map()) => withConstructionGenericSlots(
|
|
29979
32036
|
child,
|
|
29980
32037
|
ctx,
|
|
29981
|
-
|
|
29982
|
-
|
|
29983
|
-
|
|
29984
|
-
|
|
29985
|
-
|
|
32038
|
+
genericEnv,
|
|
32039
|
+
() => evaluateInitializerInContext(
|
|
32040
|
+
init,
|
|
32041
|
+
child,
|
|
32042
|
+
ctx,
|
|
32043
|
+
created,
|
|
32044
|
+
[],
|
|
32045
|
+
sourceValueId,
|
|
32046
|
+
void 0,
|
|
32047
|
+
genericEnv
|
|
32048
|
+
)
|
|
29986
32049
|
)
|
|
29987
|
-
)
|
|
29988
|
-
|
|
32050
|
+
})
|
|
32051
|
+
);
|
|
29989
32052
|
stageConstructedRows([root, ...created], ctx);
|
|
29990
32053
|
if (known?.constant === true) known.root = root.id;
|
|
29991
32054
|
return {
|
|
@@ -30819,6 +32882,72 @@ var getAreaNative = (call, ctx) => {
|
|
|
30819
32882
|
}
|
|
30820
32883
|
return null;
|
|
30821
32884
|
};
|
|
32885
|
+
function randomNative(memberId) {
|
|
32886
|
+
return (call, ctx) => {
|
|
32887
|
+
if (memberId === NEO_RANDOM_IDS.ValidateSeed) {
|
|
32888
|
+
validateRandomSeed(randomNumberArg(call.args[0], "seed"));
|
|
32889
|
+
return null;
|
|
32890
|
+
}
|
|
32891
|
+
let row = null;
|
|
32892
|
+
if (call.receiverKind === "instance") {
|
|
32893
|
+
if (call.receiver === null || call.receiver === void 0)
|
|
32894
|
+
throw new NSGetterRuntimeError("NeoRandom instance receiver is null.", {
|
|
32895
|
+
errorClassId: NEO_ERROR_CLASS_IDS.NeoNullReferenceError
|
|
32896
|
+
});
|
|
32897
|
+
row = trackedRowForValueReference(call.receiver, ctx);
|
|
32898
|
+
if (row === null || classIdForValueRow(row, ctx) !== NEO_RANDOM_IDS.class)
|
|
32899
|
+
throw new NSGetterRuntimeError(
|
|
32900
|
+
"NeoRandom requires a NeoRandom instance receiver."
|
|
32901
|
+
);
|
|
32902
|
+
}
|
|
32903
|
+
const owner = randomForContext(ctx);
|
|
32904
|
+
let random = owner;
|
|
32905
|
+
if (row !== null) {
|
|
32906
|
+
if (typeof row.value !== "object" || row.value === null)
|
|
32907
|
+
throw new NSGetterRuntimeError(
|
|
32908
|
+
"NeoRandom instance has no object value."
|
|
32909
|
+
);
|
|
32910
|
+
const id = ctx.__runtimeSessionValues?.has(row.id) === true ? void 0 : row.id;
|
|
32911
|
+
const existing = owner.findInstance(row.value, id);
|
|
32912
|
+
if (existing !== void 0) random = existing;
|
|
32913
|
+
else {
|
|
32914
|
+
const seed = dispatchSchemaMember(row.value, "_constructorSeed", ctx);
|
|
32915
|
+
if (seed.kind !== "ok")
|
|
32916
|
+
throw new NSGetterRuntimeError(
|
|
32917
|
+
"NeoRandom constructor seed is missing."
|
|
32918
|
+
);
|
|
32919
|
+
random = owner.addInstance(
|
|
32920
|
+
row.value,
|
|
32921
|
+
id,
|
|
32922
|
+
randomNumberArg(seed.value, "seed")
|
|
32923
|
+
);
|
|
32924
|
+
}
|
|
32925
|
+
}
|
|
32926
|
+
if (memberId === NEO_RANDOM_IDS.GetSeed || memberId === NEO_RANDOM_IDS.SetSeed) {
|
|
32927
|
+
const key = row === null ? NEO_RANDOM_IDS.Seed : `${NEO_RANDOM_IDS.Seed}:${row.id}`;
|
|
32928
|
+
if (memberId === NEO_RANDOM_IDS.GetSeed) {
|
|
32929
|
+
if (!owner.isContentScope) {
|
|
32930
|
+
ctx.__getterReads?.add(key);
|
|
32931
|
+
ctx.valueDependencies?.add(key);
|
|
32932
|
+
}
|
|
32933
|
+
return random.seed;
|
|
32934
|
+
}
|
|
32935
|
+
random.seed = randomNumberArg(call.args[0], "seed");
|
|
32936
|
+
if (!owner.isContentScope) ctx.__getterSubscriptions?.noteValueWrite(key);
|
|
32937
|
+
if (random !== owner) owner.noteSeedWrite(key);
|
|
32938
|
+
return null;
|
|
32939
|
+
}
|
|
32940
|
+
const before = random.drawCount;
|
|
32941
|
+
try {
|
|
32942
|
+
if (memberId === NEO_RANDOM_IDS.Value) return random.value();
|
|
32943
|
+
const min = randomNumberArg(call.args[0], "Range min");
|
|
32944
|
+
const max = randomNumberArg(call.args[1], "Range max");
|
|
32945
|
+
return memberId === NEO_RANDOM_IDS.RangeInt ? random.rangeInt(min, max) : random.rangeFloat(min, max);
|
|
32946
|
+
} finally {
|
|
32947
|
+
ctx.__executionState.randomDraws += random.drawCount - before;
|
|
32948
|
+
}
|
|
32949
|
+
};
|
|
32950
|
+
}
|
|
30822
32951
|
var SYSTEM_NATIVE_HANDLERS = new Map([
|
|
30823
32952
|
[
|
|
30824
32953
|
NEO_OBJECT_GRID_MEMBER_IDS.GetCell,
|
|
@@ -30889,6 +33018,9 @@ var SYSTEM_NATIVE_HANDLERS = new Map([
|
|
|
30889
33018
|
],
|
|
30890
33019
|
[NEO_GET_AREA_MEMBER_IDS.NeoObjectBase, getAreaNative],
|
|
30891
33020
|
[NEO_GET_AREA_MEMBER_IDS.NeoTile, getAreaNative],
|
|
33021
|
+
...[...NEO_RANDOM_NATIVE_MEMBER_IDS].map(
|
|
33022
|
+
(id) => [id, randomNative(id)]
|
|
33023
|
+
),
|
|
30892
33024
|
...[...NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS].map(
|
|
30893
33025
|
(id) => [id, cellPatternNative(id)]
|
|
30894
33026
|
)
|
|
@@ -31145,7 +33277,23 @@ var NS_MATH_OP_NAMES = {
|
|
|
31145
33277
|
truncate: "Truncate",
|
|
31146
33278
|
abs: "Abs",
|
|
31147
33279
|
sign: "Sign",
|
|
31148
|
-
sqrt: "Sqrt"
|
|
33280
|
+
sqrt: "Sqrt",
|
|
33281
|
+
pow: "Pow",
|
|
33282
|
+
exp: "Exp",
|
|
33283
|
+
log: "Log",
|
|
33284
|
+
log10: "Log10",
|
|
33285
|
+
sin: "Sin",
|
|
33286
|
+
cos: "Cos",
|
|
33287
|
+
tan: "Tan",
|
|
33288
|
+
asin: "Asin",
|
|
33289
|
+
acos: "Acos",
|
|
33290
|
+
atan: "Atan",
|
|
33291
|
+
atan2: "Atan2",
|
|
33292
|
+
lerp: "Lerp",
|
|
33293
|
+
inverselerp: "InverseLerp",
|
|
33294
|
+
movetowards: "MoveTowards",
|
|
33295
|
+
repeat: "Repeat",
|
|
33296
|
+
pingpong: "PingPong"
|
|
31149
33297
|
};
|
|
31150
33298
|
var DOUBLE_INTEGRAL_MAGNITUDE = 2 ** 53;
|
|
31151
33299
|
function mathArgPointer(info, index, fn) {
|
|
@@ -31157,6 +33305,53 @@ function mathArgPointer(info, index, fn) {
|
|
|
31157
33305
|
}
|
|
31158
33306
|
return pointer;
|
|
31159
33307
|
}
|
|
33308
|
+
function randomForContext(ctx) {
|
|
33309
|
+
const state = ctx.__executionState;
|
|
33310
|
+
if (state === void 0)
|
|
33311
|
+
throw new NSGetterRuntimeError(
|
|
33312
|
+
"NeoRandom requires an initialized evaluation runtime."
|
|
33313
|
+
);
|
|
33314
|
+
if (state.random !== void 0) return state.random;
|
|
33315
|
+
if (state.randomSource !== void 0)
|
|
33316
|
+
return state.random = state.randomSource();
|
|
33317
|
+
if (state.randomIdentity !== void 0)
|
|
33318
|
+
return state.random = new NeoRandom(state.randomIdentity);
|
|
33319
|
+
return state.random = ctx.random ?? ctx.vm.databaseVM?.random ?? new NeoRandom();
|
|
33320
|
+
}
|
|
33321
|
+
function withContentRandom(ctx, identity2, evaluate) {
|
|
33322
|
+
const state = ctx.__executionState;
|
|
33323
|
+
if (state === void 0)
|
|
33324
|
+
throw new NSGetterRuntimeError(
|
|
33325
|
+
"NeoRandom requires an initialized evaluation runtime."
|
|
33326
|
+
);
|
|
33327
|
+
const draws = state.randomDraws;
|
|
33328
|
+
try {
|
|
33329
|
+
if (state.random !== void 0)
|
|
33330
|
+
return state.random.withIdentity(identity2, evaluate);
|
|
33331
|
+
const previous = state.randomIdentity;
|
|
33332
|
+
const source = state.randomSource;
|
|
33333
|
+
return withContentRandomSource(state, identity2, (randomSource) => {
|
|
33334
|
+
state.randomSource = randomSource;
|
|
33335
|
+
state.randomIdentity = identity2;
|
|
33336
|
+
try {
|
|
33337
|
+
return evaluate();
|
|
33338
|
+
} finally {
|
|
33339
|
+
state.randomIdentity = previous;
|
|
33340
|
+
state.randomSource = source;
|
|
33341
|
+
state.random = void 0;
|
|
33342
|
+
}
|
|
33343
|
+
});
|
|
33344
|
+
} finally {
|
|
33345
|
+
state.randomDraws = draws;
|
|
33346
|
+
}
|
|
33347
|
+
}
|
|
33348
|
+
function randomNumberArg(value, label) {
|
|
33349
|
+
if (typeof value !== "number")
|
|
33350
|
+
throw new NSGetterRuntimeError(`NeoRandom.${label} must be numeric.`, {
|
|
33351
|
+
errorClassId: NEO_ERROR_CLASS_IDS.NeoArgumentError
|
|
33352
|
+
});
|
|
33353
|
+
return value;
|
|
33354
|
+
}
|
|
31160
33355
|
function mathNumberArg(value, fn) {
|
|
31161
33356
|
if (value === null || value === void 0) {
|
|
31162
33357
|
throw new NSGetterRuntimeError(`Math.${fn} argument is null.`, {
|
|
@@ -31257,6 +33452,49 @@ function evalMathOp(info, scope, ctx) {
|
|
|
31257
33452
|
if (value > 0) return 1;
|
|
31258
33453
|
if (value < 0) return -1;
|
|
31259
33454
|
return 0;
|
|
33455
|
+
case "exp":
|
|
33456
|
+
case "log":
|
|
33457
|
+
case "log10":
|
|
33458
|
+
case "sin":
|
|
33459
|
+
case "cos":
|
|
33460
|
+
case "tan":
|
|
33461
|
+
case "asin":
|
|
33462
|
+
case "acos":
|
|
33463
|
+
case "atan":
|
|
33464
|
+
return evaluateExtendedMath(info.op, Math.fround(value));
|
|
33465
|
+
case "pow":
|
|
33466
|
+
case "atan2":
|
|
33467
|
+
case "repeat":
|
|
33468
|
+
case "pingpong":
|
|
33469
|
+
return evaluateExtendedMath(
|
|
33470
|
+
info.op,
|
|
33471
|
+
Math.fround(value),
|
|
33472
|
+
Math.fround(
|
|
33473
|
+
mathNumberArg(
|
|
33474
|
+
evalPointer(mathArgPointer(info, 1, fn), scope, ctx),
|
|
33475
|
+
fn
|
|
33476
|
+
)
|
|
33477
|
+
)
|
|
33478
|
+
);
|
|
33479
|
+
case "lerp":
|
|
33480
|
+
case "inverselerp":
|
|
33481
|
+
case "movetowards":
|
|
33482
|
+
return evaluateExtendedMath(
|
|
33483
|
+
info.op,
|
|
33484
|
+
Math.fround(value),
|
|
33485
|
+
Math.fround(
|
|
33486
|
+
mathNumberArg(
|
|
33487
|
+
evalPointer(mathArgPointer(info, 1, fn), scope, ctx),
|
|
33488
|
+
fn
|
|
33489
|
+
)
|
|
33490
|
+
),
|
|
33491
|
+
Math.fround(
|
|
33492
|
+
mathNumberArg(
|
|
33493
|
+
evalPointer(mathArgPointer(info, 2, fn), scope, ctx),
|
|
33494
|
+
fn
|
|
33495
|
+
)
|
|
33496
|
+
)
|
|
33497
|
+
);
|
|
31260
33498
|
case "sqrt":
|
|
31261
33499
|
return Math.fround(Math.sqrt(value));
|
|
31262
33500
|
}
|
|
@@ -31268,6 +33506,25 @@ function evalDecimalMathOp(info, fn, scope, ctx) {
|
|
|
31268
33506
|
);
|
|
31269
33507
|
try {
|
|
31270
33508
|
switch (info.op) {
|
|
33509
|
+
case "pow":
|
|
33510
|
+
case "exp":
|
|
33511
|
+
case "log":
|
|
33512
|
+
case "log10":
|
|
33513
|
+
case "sin":
|
|
33514
|
+
case "cos":
|
|
33515
|
+
case "tan":
|
|
33516
|
+
case "asin":
|
|
33517
|
+
case "acos":
|
|
33518
|
+
case "atan":
|
|
33519
|
+
case "atan2":
|
|
33520
|
+
case "lerp":
|
|
33521
|
+
case "inverselerp":
|
|
33522
|
+
case "movetowards":
|
|
33523
|
+
case "repeat":
|
|
33524
|
+
case "pingpong":
|
|
33525
|
+
throw new NSGetterRuntimeError(
|
|
33526
|
+
`Math.${fn} does not accept decimal arguments.`
|
|
33527
|
+
);
|
|
31271
33528
|
case "min":
|
|
31272
33529
|
return minDecimalStrings(
|
|
31273
33530
|
value,
|
|
@@ -33839,7 +36096,7 @@ function evaluateBaseConstructorArguments(record4, baseRecord, argumentValues, t
|
|
|
33839
36096
|
argument2.name,
|
|
33840
36097
|
executeCompiledFunction(
|
|
33841
36098
|
getter,
|
|
33842
|
-
|
|
36099
|
+
bindThisValue(ctx, thisValue),
|
|
33843
36100
|
argumentValues,
|
|
33844
36101
|
false
|
|
33845
36102
|
)
|
|
@@ -35389,7 +37646,12 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
|
|
|
35389
37646
|
const preparedArgumentScopes = prepareConstructorArgumentScopes(
|
|
35390
37647
|
record4,
|
|
35391
37648
|
argumentValues,
|
|
35392
|
-
|
|
37649
|
+
// Base arguments run before a receiver exists, but still belong to the
|
|
37650
|
+
// constructed class's generic scope rather than the caller's.
|
|
37651
|
+
{
|
|
37652
|
+
...bindThisValue(ctx, null),
|
|
37653
|
+
__initializerGenericEnv: descriptor.instanceEnv
|
|
37654
|
+
}
|
|
35393
37655
|
);
|
|
35394
37656
|
const createdValues = [];
|
|
35395
37657
|
const storageKeyDeclarations = /* @__PURE__ */ new Map();
|
|
@@ -37231,7 +39493,7 @@ var SourceText = class {
|
|
|
37231
39493
|
return this.lineStarts.length;
|
|
37232
39494
|
}
|
|
37233
39495
|
positionAt(rawOffset) {
|
|
37234
|
-
const offset =
|
|
39496
|
+
const offset = clamp2(rawOffset, 0, this.text.length);
|
|
37235
39497
|
const previousLine = this.#lastPositionLine;
|
|
37236
39498
|
const previousStart = this.lineStarts[previousLine];
|
|
37237
39499
|
const nextStart = this.lineStarts[previousLine + 1];
|
|
@@ -37253,11 +39515,11 @@ var SourceText = class {
|
|
|
37253
39515
|
};
|
|
37254
39516
|
}
|
|
37255
39517
|
offsetAt(position) {
|
|
37256
|
-
const line =
|
|
39518
|
+
const line = clamp2(position.line, 0, this.lineStarts.length - 1);
|
|
37257
39519
|
const start = this.lineStarts[line] ?? 0;
|
|
37258
39520
|
const next = this.lineStarts[line + 1] ?? this.text.length;
|
|
37259
39521
|
const rawEnd = next > start && this.text.charCodeAt(next - 1) === 10 ? next - 1 : next;
|
|
37260
|
-
return
|
|
39522
|
+
return clamp2(start + position.character, start, rawEnd);
|
|
37261
39523
|
}
|
|
37262
39524
|
range(start, end) {
|
|
37263
39525
|
return {
|
|
@@ -37277,7 +39539,7 @@ var SourceText = class {
|
|
|
37277
39539
|
return this.text.slice(start, withoutCarriageReturn);
|
|
37278
39540
|
}
|
|
37279
39541
|
};
|
|
37280
|
-
function
|
|
39542
|
+
function clamp2(value, minimum, maximum) {
|
|
37281
39543
|
return Math.max(minimum, Math.min(maximum, value));
|
|
37282
39544
|
}
|
|
37283
39545
|
|
|
@@ -39574,6 +41836,7 @@ function evaluateInitializerMaterialization(args) {
|
|
|
39574
41836
|
const createdValues = [];
|
|
39575
41837
|
const storageKeyDeclarations = /* @__PURE__ */ new Map();
|
|
39576
41838
|
const evaluated = args.evaluateInitializer({
|
|
41839
|
+
randomSource: args.randomSource,
|
|
39577
41840
|
genericEnv: args.genericEnv,
|
|
39578
41841
|
init: args.init,
|
|
39579
41842
|
member: args.member,
|
|
@@ -39653,6 +41916,7 @@ function finalizeMaterializedRoot(args) {
|
|
|
39653
41916
|
}
|
|
39654
41917
|
function materializeInitializerValue(args) {
|
|
39655
41918
|
const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
|
|
41919
|
+
randomSource: args.randomSource,
|
|
39656
41920
|
evaluateInitializer: args.evaluateInitializer,
|
|
39657
41921
|
init: args.row.init,
|
|
39658
41922
|
member: args.member,
|
|
@@ -39703,11 +41967,19 @@ function materializeInitializerValue(args) {
|
|
|
39703
41967
|
return {
|
|
39704
41968
|
root,
|
|
39705
41969
|
createdValues,
|
|
41970
|
+
snapshot: evaluated.snapshot,
|
|
39706
41971
|
pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
|
|
39707
41972
|
pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
|
|
39708
41973
|
};
|
|
39709
41974
|
}
|
|
39710
41975
|
function materializeMemberDefaultValue(args) {
|
|
41976
|
+
if (args.randomSource === void 0)
|
|
41977
|
+
return withContentRandomSource(
|
|
41978
|
+
args.document,
|
|
41979
|
+
args.randomIdentity ?? args.envelope.id,
|
|
41980
|
+
(randomSource2) => materializeMemberDefaultValue({ ...args, randomSource: randomSource2 })
|
|
41981
|
+
);
|
|
41982
|
+
const randomSource = args.randomSource;
|
|
39711
41983
|
const createdValues = [];
|
|
39712
41984
|
const storageKeyDeclarations = /* @__PURE__ */ new Map();
|
|
39713
41985
|
const declarationArguments = (member, init, sourceValueId) => {
|
|
@@ -39789,6 +42061,8 @@ function materializeMemberDefaultValue(args) {
|
|
|
39789
42061
|
// A declaration default may itself be init-backed one level down (P43 §2),
|
|
39790
42062
|
// and those nested initializers must evaluate against the same document.
|
|
39791
42063
|
initEvaluator: (member, init, sourceValueId, genericEnv) => args.evaluateInitializer({
|
|
42064
|
+
randomSource,
|
|
42065
|
+
randomIdentity: args.randomIdentity ?? args.envelope.id,
|
|
39792
42066
|
genericEnv,
|
|
39793
42067
|
storageKeyDeclarations,
|
|
39794
42068
|
init,
|
|
@@ -41199,6 +43473,12 @@ function materializationReadTracking(recorder) {
|
|
|
41199
43473
|
return { readTracking, trackMaterialization };
|
|
41200
43474
|
}
|
|
41201
43475
|
function expandStoredInstance(args) {
|
|
43476
|
+
if (args.randomSource === void 0)
|
|
43477
|
+
return withContentRandomSource(
|
|
43478
|
+
args.document,
|
|
43479
|
+
args.instanceRoot.id,
|
|
43480
|
+
(randomSource2) => expandStoredInstance({ ...args, randomSource: randomSource2 })
|
|
43481
|
+
);
|
|
41202
43482
|
const { readTracking, trackMaterialization } = materializationReadTracking(
|
|
41203
43483
|
args.readRecorder
|
|
41204
43484
|
);
|
|
@@ -41210,6 +43490,7 @@ function expandStoredInstance(args) {
|
|
|
41210
43490
|
);
|
|
41211
43491
|
}
|
|
41212
43492
|
const instanceRoot = literalRow(args.instanceRoot);
|
|
43493
|
+
const randomSource = args.randomSource;
|
|
41213
43494
|
const classId = rowClassId(rootMember, instanceRoot);
|
|
41214
43495
|
const schemaIndex = projectSchemaIndexFor(args.document);
|
|
41215
43496
|
const schemaClass2 = schemaIndex.class(classId);
|
|
@@ -41304,6 +43585,7 @@ function expandStoredInstance(args) {
|
|
|
41304
43585
|
return trackMaterialization(
|
|
41305
43586
|
() => args.materializeInitializerValue({
|
|
41306
43587
|
evaluateInitializer: args.evaluateInitializer,
|
|
43588
|
+
randomSource,
|
|
41307
43589
|
document: args.document,
|
|
41308
43590
|
member: replayMember,
|
|
41309
43591
|
row: { ...envelope, init },
|
|
@@ -41320,6 +43602,7 @@ function expandStoredInstance(args) {
|
|
|
41320
43602
|
const built = trackMaterialization(
|
|
41321
43603
|
() => args.materializeMemberDefaultValue({
|
|
41322
43604
|
evaluateInitializer: args.evaluateInitializer,
|
|
43605
|
+
randomSource,
|
|
41323
43606
|
document: args.document,
|
|
41324
43607
|
member: replayMember,
|
|
41325
43608
|
envelope,
|
|
@@ -41348,6 +43631,7 @@ function expandStoredInstance(args) {
|
|
|
41348
43631
|
const materialized = typeof appliedVariantId !== "string" ? constructed : trackMaterialization(
|
|
41349
43632
|
() => replayAppliedVariant({
|
|
41350
43633
|
evaluateInitializer: args.evaluateInitializer,
|
|
43634
|
+
randomSource,
|
|
41351
43635
|
document: args.document,
|
|
41352
43636
|
member: replayMember,
|
|
41353
43637
|
constructed,
|
|
@@ -41381,6 +43665,7 @@ function replayAppliedVariant(args) {
|
|
|
41381
43665
|
classId: args.classId
|
|
41382
43666
|
};
|
|
41383
43667
|
args.evaluateInitializer({
|
|
43668
|
+
randomSource: args.randomSource,
|
|
41384
43669
|
init: {
|
|
41385
43670
|
code: `virtual-applied-variant:${rootId}`,
|
|
41386
43671
|
compiled: {
|
|
@@ -45079,6 +47364,7 @@ function initializerEvaluatorLookups(document2, readTracking) {
|
|
|
45079
47364
|
if (document2.databaseVM !== void 0) {
|
|
45080
47365
|
const databaseVM = document2.databaseVM;
|
|
45081
47366
|
const lookups2 = {
|
|
47367
|
+
random: databaseVM.random,
|
|
45082
47368
|
...databaseVM.changeListenerDefaultsForOwner === void 0 ? {} : {
|
|
45083
47369
|
changeListenerDefaultsForOwner: (id) => databaseVM.changeListenerDefaultsForOwner(id)
|
|
45084
47370
|
},
|
|
@@ -45330,12 +47616,25 @@ function compileMemberInitializer(args, databaseVM = initializerEvaluatorLookups
|
|
|
45330
47616
|
});
|
|
45331
47617
|
}
|
|
45332
47618
|
function evaluateMemberInitializer(args) {
|
|
47619
|
+
const randomIdentity = args.randomIdentity ?? args.sourceValueId ?? Reflect.get(args.member, "id");
|
|
47620
|
+
if (typeof randomIdentity !== "string")
|
|
47621
|
+
throw new Error(
|
|
47622
|
+
"Stored initializer evaluation requires its content identity."
|
|
47623
|
+
);
|
|
47624
|
+
if (args.randomSource === void 0)
|
|
47625
|
+
return withContentRandomSource(
|
|
47626
|
+
args.document,
|
|
47627
|
+
randomIdentity,
|
|
47628
|
+
(randomSource) => evaluateMemberInitializer({ ...args, randomIdentity, randomSource })
|
|
47629
|
+
);
|
|
45333
47630
|
const databaseVM = initializerEvaluatorLookups(
|
|
45334
47631
|
args.document,
|
|
45335
47632
|
args.readTracking
|
|
45336
47633
|
);
|
|
45337
47634
|
const compiled = compileMemberInitializer(args, databaseVM);
|
|
45338
47635
|
const ctx = {
|
|
47636
|
+
randomSource: args.randomSource,
|
|
47637
|
+
randomIdentity,
|
|
45339
47638
|
...args.sessionValues === void 0 ? {} : { __runtimeSessionValues: args.sessionValues },
|
|
45340
47639
|
debugSink: args.document.debugSink,
|
|
45341
47640
|
beforeValueAllocation: args.document.beforeValueAllocation,
|
|
@@ -45455,6 +47754,7 @@ function evaluateMemberInitializer(args) {
|
|
|
45455
47754
|
const provenance = pickInstanceProvenance({ ...rootRow, constructorArgs });
|
|
45456
47755
|
return {
|
|
45457
47756
|
value: result.value,
|
|
47757
|
+
snapshot: (evaluatedContext.__executionState?.randomDraws ?? 0) > 0,
|
|
45458
47758
|
classId: rootRow.classId ?? null,
|
|
45459
47759
|
...rootRow.genericBindings === void 0 ? {} : { genericBindings: { ...rootRow.genericBindings } },
|
|
45460
47760
|
...pinnedRootSchemaKeys === void 0 ? {} : { pinnedRootSchemaKeys },
|
|
@@ -48173,7 +50473,23 @@ var MATH_FUNCTIONS = /* @__PURE__ */ new Map([
|
|
|
48173
50473
|
["Truncate", { op: "truncate", arity: 1, result: "integral" }],
|
|
48174
50474
|
["Abs", { op: "abs", arity: 1, result: "join" }],
|
|
48175
50475
|
["Sign", { op: "sign", arity: 1, result: "int" }],
|
|
48176
|
-
["Sqrt", { op: "sqrt", arity: 1, result: "float" }]
|
|
50476
|
+
["Sqrt", { op: "sqrt", arity: 1, result: "float" }],
|
|
50477
|
+
["Pow", { op: "pow", arity: 2, result: "float" }],
|
|
50478
|
+
["Exp", { op: "exp", arity: 1, result: "float" }],
|
|
50479
|
+
["Log", { op: "log", arity: 1, result: "float" }],
|
|
50480
|
+
["Log10", { op: "log10", arity: 1, result: "float" }],
|
|
50481
|
+
["Sin", { op: "sin", arity: 1, result: "float" }],
|
|
50482
|
+
["Cos", { op: "cos", arity: 1, result: "float" }],
|
|
50483
|
+
["Tan", { op: "tan", arity: 1, result: "float" }],
|
|
50484
|
+
["Asin", { op: "asin", arity: 1, result: "float" }],
|
|
50485
|
+
["Acos", { op: "acos", arity: 1, result: "float" }],
|
|
50486
|
+
["Atan", { op: "atan", arity: 1, result: "float" }],
|
|
50487
|
+
["Atan2", { op: "atan2", arity: 2, result: "float" }],
|
|
50488
|
+
["Lerp", { op: "lerp", arity: 3, result: "float" }],
|
|
50489
|
+
["InverseLerp", { op: "inverselerp", arity: 3, result: "float" }],
|
|
50490
|
+
["MoveTowards", { op: "movetowards", arity: 3, result: "float" }],
|
|
50491
|
+
["Repeat", { op: "repeat", arity: 2, result: "float" }],
|
|
50492
|
+
["PingPong", { op: "pingpong", arity: 2, result: "float" }]
|
|
48177
50493
|
]);
|
|
48178
50494
|
var MATH_CONSTANTS = /* @__PURE__ */ new Map([
|
|
48179
50495
|
["PI", 3.141592653589793],
|
|
@@ -49436,7 +51752,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
49436
51752
|
statement.iterator,
|
|
49437
51753
|
iteratorScope
|
|
49438
51754
|
);
|
|
49439
|
-
if (iterator.type !== "assign" /* Assign */) {
|
|
51755
|
+
if (iterator.type !== "assign" /* Assign */ && iterator.type !== "functionCall" /* FunctionCall */) {
|
|
49440
51756
|
throw new CompileError(
|
|
49441
51757
|
"A for-loop iterator must be an assignment; an NSAction subscription is not a valid iterator.",
|
|
49442
51758
|
statement.iterator.pos
|
|
@@ -50140,7 +52456,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
50140
52456
|
assertLocalNameAvailable(name, scope, pos) {
|
|
50141
52457
|
if (name === MATH_NAMESPACE_NAME) {
|
|
50142
52458
|
throw new CompileError(
|
|
50143
|
-
`Cannot declare a local named '${
|
|
52459
|
+
`Cannot declare a local named '${name}' because it is a builtin namespace.`,
|
|
50144
52460
|
pos
|
|
50145
52461
|
);
|
|
50146
52462
|
}
|
|
@@ -50355,6 +52671,31 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
50355
52671
|
statement.target,
|
|
50356
52672
|
scope
|
|
50357
52673
|
);
|
|
52674
|
+
if (placeTarget.symbol?.id === NEO_RANDOM_IDS.Seed && placeTarget.pointer.type === "callFunction" /* CallFunction */ && placeTarget.pointer.receiver.kind === "static") {
|
|
52675
|
+
const value2 = statement.op === "=" && statement.value ? this.resolveExpression(statement.value, scope, placeTarget.type) : this.resolveCompoundAssignment(
|
|
52676
|
+
statement.op,
|
|
52677
|
+
statement.value,
|
|
52678
|
+
placeTarget,
|
|
52679
|
+
scope,
|
|
52680
|
+
statement.pos
|
|
52681
|
+
);
|
|
52682
|
+
this.requireAssignable(
|
|
52683
|
+
value2.type,
|
|
52684
|
+
placeTarget.type,
|
|
52685
|
+
statement.pos,
|
|
52686
|
+
"assign"
|
|
52687
|
+
);
|
|
52688
|
+
return {
|
|
52689
|
+
type: "functionCall" /* FunctionCall */,
|
|
52690
|
+
call: {
|
|
52691
|
+
type: "callFunction" /* CallFunction */,
|
|
52692
|
+
memberId: NEO_RANDOM_IDS.SetSeed,
|
|
52693
|
+
receiver: { kind: "static", memberId: NEO_RANDOM_IDS.SetSeed },
|
|
52694
|
+
args: [value2.pointer],
|
|
52695
|
+
callSiteId: this.nextCallSite(statement.pos)
|
|
52696
|
+
}
|
|
52697
|
+
};
|
|
52698
|
+
}
|
|
50358
52699
|
if (placeTarget.pointer.type === "function" /* Function */ && placeTarget.pointer.function.type === "tupleElement" /* TupleElement */) {
|
|
50359
52700
|
throw new CompileError(
|
|
50360
52701
|
"Tuple elements are immutable. Assign a new tuple to the whole value.",
|
|
@@ -50429,13 +52770,15 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
50429
52770
|
statement.pos
|
|
50430
52771
|
);
|
|
50431
52772
|
}
|
|
50432
|
-
|
|
50433
|
-
|
|
50434
|
-
|
|
50435
|
-
|
|
50436
|
-
|
|
50437
|
-
|
|
50438
|
-
|
|
52773
|
+
if (target.symbol?.id !== NEO_RANDOM_IDS.Seed) {
|
|
52774
|
+
this.validateConstructorWriteTarget(
|
|
52775
|
+
target.pointer,
|
|
52776
|
+
"assign to",
|
|
52777
|
+
statement.pos,
|
|
52778
|
+
scope,
|
|
52779
|
+
false
|
|
52780
|
+
);
|
|
52781
|
+
}
|
|
50439
52782
|
if (target.type.kind === "action") {
|
|
50440
52783
|
return this.resolveActionSubscription(
|
|
50441
52784
|
statement,
|
|
@@ -52870,7 +55213,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
52870
55213
|
}
|
|
52871
55214
|
if (name === MATH_NAMESPACE_NAME) {
|
|
52872
55215
|
throw new CompileError(
|
|
52873
|
-
`'${
|
|
55216
|
+
`'${name}' is a builtin namespace, not a value.`,
|
|
52874
55217
|
pos
|
|
52875
55218
|
);
|
|
52876
55219
|
}
|
|
@@ -53416,6 +55759,20 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
53416
55759
|
}
|
|
53417
55760
|
resolveStaticMemberValue(staticType, member, pos) {
|
|
53418
55761
|
this.assertMemberAccessible(staticType, member, pos);
|
|
55762
|
+
if (staticType.id === NEO_RANDOM_IDS.class && member.id === NEO_RANDOM_IDS.Seed) {
|
|
55763
|
+
return {
|
|
55764
|
+
pointer: {
|
|
55765
|
+
type: "callFunction" /* CallFunction */,
|
|
55766
|
+
memberId: NEO_RANDOM_IDS.GetSeed,
|
|
55767
|
+
receiver: { kind: "static", memberId: NEO_RANDOM_IDS.GetSeed },
|
|
55768
|
+
args: [],
|
|
55769
|
+
callSiteId: this.nextCallSite(pos)
|
|
55770
|
+
},
|
|
55771
|
+
type: member.type,
|
|
55772
|
+
symbol: member,
|
|
55773
|
+
writability: "setter" /* Setter */
|
|
55774
|
+
};
|
|
55775
|
+
}
|
|
53419
55776
|
if (member.static !== true) {
|
|
53420
55777
|
throw new CompileError(
|
|
53421
55778
|
`Member '${staticType.name}.${member.name}' requires an instance receiver.`,
|
|
@@ -54564,7 +56921,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
54564
56921
|
argPointers: joined.arguments.map((argument2) => argument2.pointer),
|
|
54565
56922
|
...isPrimitive(joined.type, "decimal") ? { decimal: true } : {}
|
|
54566
56923
|
},
|
|
54567
|
-
mathResultType(fn.result, joined.type, pos)
|
|
56924
|
+
mathResultType(fn.result, joined.type, pos, name)
|
|
54568
56925
|
);
|
|
54569
56926
|
}
|
|
54570
56927
|
/**
|
|
@@ -54902,7 +57259,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
54902
57259
|
const candidates2 = this.overloadCandidates(
|
|
54903
57260
|
staticType,
|
|
54904
57261
|
callee.name,
|
|
54905
|
-
"static"
|
|
57262
|
+
staticType.id === NEO_RANDOM_IDS.class ? "instance" : "static"
|
|
54906
57263
|
);
|
|
54907
57264
|
const member2 = candidates2[0] ?? staticType.members.find(
|
|
54908
57265
|
(candidate) => candidate.name === callee.name
|
|
@@ -54914,7 +57271,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
54914
57271
|
);
|
|
54915
57272
|
}
|
|
54916
57273
|
this.assertMemberAccessible(staticType, member2, pos);
|
|
54917
|
-
if (member2.static !== true) {
|
|
57274
|
+
if (member2.static !== true && !isNeoRandomSharedMethod(staticType.id, member2.id)) {
|
|
54918
57275
|
throw new CompileError(
|
|
54919
57276
|
`Member '${staticType.name}.${callee.name}' requires an instance receiver.`,
|
|
54920
57277
|
pos
|
|
@@ -55610,7 +57967,9 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
55610
57967
|
};
|
|
55611
57968
|
}
|
|
55612
57969
|
resolveConstructorOverload(className, declared, named, expression, scope, pos) {
|
|
55613
|
-
if (named.length === 0
|
|
57970
|
+
if (named.length === 0 && neoScriptRequiredConstructor(
|
|
57971
|
+
this.project.typeByName.get(className) ?? { declaredConstructors: [] }
|
|
57972
|
+
) === null) {
|
|
55614
57973
|
return neoScriptParameterlessConstructor(
|
|
55615
57974
|
this.project.typeByName.get(className) ?? { declaredConstructors: [] }
|
|
55616
57975
|
);
|
|
@@ -58418,14 +60777,14 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
58418
60777
|
const candidates2 = this.overloadCandidates(
|
|
58419
60778
|
staticType,
|
|
58420
60779
|
memberName,
|
|
58421
|
-
"static"
|
|
60780
|
+
staticType.id === NEO_RANDOM_IDS.class ? "instance" : "static"
|
|
58422
60781
|
);
|
|
58423
60782
|
const found2 = candidates2[0] ?? staticType.members.find(
|
|
58424
60783
|
(candidate) => (candidate.kind === "function" || candidate.kind === "method") && candidate.name === memberName
|
|
58425
60784
|
);
|
|
58426
60785
|
if (!found2) return null;
|
|
58427
60786
|
this.assertMemberAccessible(staticType, found2, expression.pos);
|
|
58428
|
-
if (found2.static !== true) {
|
|
60787
|
+
if (found2.static !== true && !isNeoRandomSharedMethod(staticType.id, found2.id)) {
|
|
58429
60788
|
throw new CompileError(
|
|
58430
60789
|
`Member '${staticType.name}.${memberName}' requires an instance receiver.`,
|
|
58431
60790
|
expression.pos
|
|
@@ -59596,7 +61955,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
|
|
|
59596
61955
|
return this.expressionWriteRoot(initial, scope);
|
|
59597
61956
|
}
|
|
59598
61957
|
validateCallableInContext(symbol, pos) {
|
|
59599
|
-
if (symbol.native === true && !NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS.has(symbol.id) && isNeoScriptConstructionDocumentKind(this.context.kind)) {
|
|
61958
|
+
if (symbol.native === true && !NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS.has(symbol.id) && !NEO_RANDOM_NATIVE_MEMBER_IDS.has(symbol.id) && isNeoScriptConstructionDocumentKind(this.context.kind)) {
|
|
59600
61959
|
throw new CompileError(
|
|
59601
61960
|
`Native Function '${symbol.name}' is implemented by the game, so a ${this.context.kind} body cannot call it; neither push nor the web can evaluate it.`,
|
|
59602
61961
|
pos
|
|
@@ -61383,7 +63742,7 @@ function isContextualNumericLiteral(expression) {
|
|
|
61383
63742
|
}
|
|
61384
63743
|
return expression.kind === "unary" && expression.op === "-" && (expression.operand.kind === "litInt" || expression.operand.kind === "litFloat");
|
|
61385
63744
|
}
|
|
61386
|
-
function mathResultType(rule, joined, pos) {
|
|
63745
|
+
function mathResultType(rule, joined, pos, name) {
|
|
61387
63746
|
switch (rule) {
|
|
61388
63747
|
case "join":
|
|
61389
63748
|
return joined;
|
|
@@ -61394,7 +63753,7 @@ function mathResultType(rule, joined, pos) {
|
|
|
61394
63753
|
case "float":
|
|
61395
63754
|
if (isPrimitive(joined, "decimal")) {
|
|
61396
63755
|
throw new CompileError(
|
|
61397
|
-
|
|
63756
|
+
`Math.${name} does not accept decimal; convert explicitly with value.ToFloat().`,
|
|
61398
63757
|
pos
|
|
61399
63758
|
);
|
|
61400
63759
|
}
|
|
@@ -64735,8 +67094,8 @@ function compareCodePoints(left, right) {
|
|
|
64735
67094
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
64736
67095
|
}
|
|
64737
67096
|
function pascalIdentifier(value) {
|
|
64738
|
-
const
|
|
64739
|
-
let identifier =
|
|
67097
|
+
const words2 = value.normalize("NFKD").replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean);
|
|
67098
|
+
let identifier = words2.map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join("");
|
|
64740
67099
|
if (identifier.length === 0) identifier = "File";
|
|
64741
67100
|
if (/^[0-9]/.test(identifier)) identifier = `File${identifier}`;
|
|
64742
67101
|
return identifier;
|
|
@@ -73244,7 +75603,7 @@ function collectAssignedOwnershipVariableIds(instructions, assigned = /* @__PURE
|
|
|
73244
75603
|
continue;
|
|
73245
75604
|
}
|
|
73246
75605
|
if (instruction.type === "for" /* for */) {
|
|
73247
|
-
if (instruction.iterator.target.pointer.type === "variable" /* variable */) {
|
|
75606
|
+
if (instruction.iterator.type === "assign" /* assign */ && instruction.iterator.target.pointer.type === "variable" /* variable */) {
|
|
73248
75607
|
assigned.add(instruction.iterator.target.pointer.variableId);
|
|
73249
75608
|
}
|
|
73250
75609
|
collectAssignedOwnershipVariableIds(instruction.instructions, assigned);
|
|
@@ -79693,38 +82052,6 @@ import { ConvexError as ConvexError4 } from "convex/values";
|
|
|
79693
82052
|
// ../src/common/client-commit-transport.ts
|
|
79694
82053
|
var INLINE_COMMIT_MAX_PAYLOAD_BYTES = 512 * 1024;
|
|
79695
82054
|
|
|
79696
|
-
// src/ui.ts
|
|
79697
|
-
var colorEnabled = process.stdout.isTTY === true && process.env.NO_COLOR === void 0 && process.env.TERM !== "dumb";
|
|
79698
|
-
function paint(open, close) {
|
|
79699
|
-
if (!colorEnabled) return (text) => text;
|
|
79700
|
-
return (text) => `\x1B[${open}m${text}\x1B[${close}m`;
|
|
79701
|
-
}
|
|
79702
|
-
var color = {
|
|
79703
|
-
bold: paint(1, 22),
|
|
79704
|
-
dim: paint(2, 22),
|
|
79705
|
-
red: paint(31, 39),
|
|
79706
|
-
green: paint(32, 39),
|
|
79707
|
-
yellow: paint(33, 39),
|
|
79708
|
-
blue: paint(34, 39),
|
|
79709
|
-
magenta: paint(35, 39),
|
|
79710
|
-
cyan: paint(36, 39)
|
|
79711
|
-
};
|
|
79712
|
-
var sym = {
|
|
79713
|
-
ok: color.green("\u2714"),
|
|
79714
|
-
fail: color.red("\u2716"),
|
|
79715
|
-
warn: color.yellow("\u25B2"),
|
|
79716
|
-
info: color.cyan("\u25CF"),
|
|
79717
|
-
arrow: color.dim("\u2192"),
|
|
79718
|
-
branch: color.magenta("\u2387"),
|
|
79719
|
-
tag: color.cyan("\u2301"),
|
|
79720
|
-
pointer: color.cyan("\u276F")
|
|
79721
|
-
};
|
|
79722
|
-
var CHANGE_KIND_COLOR = {
|
|
79723
|
-
create: color.green,
|
|
79724
|
-
update: color.yellow,
|
|
79725
|
-
delete: color.red
|
|
79726
|
-
};
|
|
79727
|
-
|
|
79728
82055
|
// src/project-source/project-file-push.ts
|
|
79729
82056
|
var UPLOAD_CONCURRENCY = 6;
|
|
79730
82057
|
var PRESIGN_BATCH_SIZE = Math.min(
|
|
@@ -79889,10 +82216,6 @@ var SCRIPT_COLLECTION_READERS = {
|
|
|
79889
82216
|
[5 /* Dictionary */]: "ReadScriptDictionary"
|
|
79890
82217
|
};
|
|
79891
82218
|
|
|
79892
|
-
// src/export-state.ts
|
|
79893
|
-
import { join } from "node:path";
|
|
79894
|
-
var EXPORT_STATE_FILE = join(".neo", "export.json");
|
|
79895
|
-
|
|
79896
82219
|
// src/export-cache.ts
|
|
79897
82220
|
var MAX_CACHE_BYTES = 256 * 1024 * 1024;
|
|
79898
82221
|
|
|
@@ -80182,10 +82505,11 @@ function sharedEvaluatorBase(rawDocument) {
|
|
|
80182
82505
|
SHARED_EVALUATOR_BASES.set(rawDocument, created);
|
|
80183
82506
|
return created;
|
|
80184
82507
|
}
|
|
80185
|
-
function makeEvaluatorContext(rawDocument, interceptor) {
|
|
82508
|
+
function makeEvaluatorContext(rawDocument, interceptor, seed) {
|
|
80186
82509
|
const base = sharedEvaluatorBase(rawDocument);
|
|
80187
82510
|
return createNeoScriptEvaluationRuntime({
|
|
80188
82511
|
vm: base.vm,
|
|
82512
|
+
random: new NeoRandom(seed),
|
|
80189
82513
|
debugSink: stderrNeoScriptDebugSink,
|
|
80190
82514
|
thisValue: null,
|
|
80191
82515
|
rootValue: base.rootValue,
|
|
@@ -80324,7 +82648,7 @@ function validateRegistrationAction(action, allowRegistration) {
|
|
|
80324
82648
|
}
|
|
80325
82649
|
}
|
|
80326
82650
|
}
|
|
80327
|
-
function registerSpec(spec, document2) {
|
|
82651
|
+
function registerSpec(spec, document2, seed) {
|
|
80328
82652
|
document2 = withCompiledConstructionTypes(document2, spec.action);
|
|
80329
82653
|
validateRegistrationAction(spec.action, true);
|
|
80330
82654
|
const root = {
|
|
@@ -80403,10 +82727,10 @@ function registerSpec(spec, document2) {
|
|
|
80403
82727
|
};
|
|
80404
82728
|
evaluateNSFunction(
|
|
80405
82729
|
spec.action,
|
|
80406
|
-
makeEvaluatorContext(document2, interceptor),
|
|
82730
|
+
makeEvaluatorContext(document2, interceptor, seed),
|
|
80407
82731
|
[]
|
|
80408
82732
|
);
|
|
80409
|
-
return { spec, root, tests, document: document2 };
|
|
82733
|
+
return { spec, root, tests, document: document2, seed };
|
|
80410
82734
|
}
|
|
80411
82735
|
function mockResponse(environment, mock, selected, call) {
|
|
80412
82736
|
if (selected === null) {
|
|
@@ -80722,8 +83046,9 @@ function interceptTestCall(environment, call) {
|
|
|
80722
83046
|
throw error;
|
|
80723
83047
|
}
|
|
80724
83048
|
}
|
|
80725
|
-
function createTestEnvironment(document2) {
|
|
83049
|
+
function createTestEnvironment(document2, seed) {
|
|
80726
83050
|
const environment = {
|
|
83051
|
+
seed,
|
|
80727
83052
|
baseDocument: document2,
|
|
80728
83053
|
context: void 0,
|
|
80729
83054
|
mocks: /* @__PURE__ */ new Map(),
|
|
@@ -80733,7 +83058,8 @@ function createTestEnvironment(document2) {
|
|
|
80733
83058
|
};
|
|
80734
83059
|
environment.context = makeEvaluatorContext(
|
|
80735
83060
|
document2,
|
|
80736
|
-
(call) => interceptTestCall(environment, call)
|
|
83061
|
+
(call) => interceptTestCall(environment, call),
|
|
83062
|
+
seed
|
|
80737
83063
|
);
|
|
80738
83064
|
return environment;
|
|
80739
83065
|
}
|
|
@@ -80795,7 +83121,10 @@ function copyMocks(source, target) {
|
|
|
80795
83121
|
}
|
|
80796
83122
|
}
|
|
80797
83123
|
function cloneTestEnvironment(source) {
|
|
80798
|
-
const cloned = createTestEnvironment(
|
|
83124
|
+
const cloned = createTestEnvironment(
|
|
83125
|
+
snapshotEnvironmentDocument(source),
|
|
83126
|
+
source.seed
|
|
83127
|
+
);
|
|
80799
83128
|
copyMocks(source, cloned);
|
|
80800
83129
|
cloned.context.__getterSubscriptions = source.context.__getterSubscriptions?.clone();
|
|
80801
83130
|
return cloned;
|
|
@@ -80856,9 +83185,9 @@ function suiteHasSelectedTests(suite, selected) {
|
|
|
80856
83185
|
function prepareTestEvaluator(document2) {
|
|
80857
83186
|
sharedEvaluatorBase(document2);
|
|
80858
83187
|
}
|
|
80859
|
-
async function executeTestFile(spec, document2, selected, timeoutMs, interrupted2 = () => false) {
|
|
83188
|
+
async function executeTestFile(spec, document2, selected, timeoutMs, interrupted2 = () => false, seed = 0) {
|
|
80860
83189
|
return executeRegisteredSpec(
|
|
80861
|
-
registerSpec(spec, document2),
|
|
83190
|
+
registerSpec(spec, document2, seed),
|
|
80862
83191
|
selected,
|
|
80863
83192
|
timeoutMs,
|
|
80864
83193
|
interrupted2
|
|
@@ -80973,7 +83302,11 @@ async function executeRegisteredSpec(registered, selected, timeoutMs, interrupte
|
|
|
80973
83302
|
}
|
|
80974
83303
|
}
|
|
80975
83304
|
};
|
|
80976
|
-
await executeSuite(
|
|
83305
|
+
await executeSuite(
|
|
83306
|
+
registered.root,
|
|
83307
|
+
createTestEnvironment(document2, registered.seed),
|
|
83308
|
+
[]
|
|
83309
|
+
);
|
|
80977
83310
|
const registrationOrder = new Map(
|
|
80978
83311
|
registered.tests.map((test, index) => [test.id, index])
|
|
80979
83312
|
);
|
|
@@ -81008,7 +83341,8 @@ parentPort?.on("message", async (request) => {
|
|
|
81008
83341
|
document,
|
|
81009
83342
|
new Set(request.selectedIds),
|
|
81010
83343
|
request.timeoutMs,
|
|
81011
|
-
() => interrupted
|
|
83344
|
+
() => interrupted,
|
|
83345
|
+
request.seed
|
|
81012
83346
|
);
|
|
81013
83347
|
respond({ kind: "result", result });
|
|
81014
83348
|
} catch (error) {
|