@mirascript/mirascript 0.1.44 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CQ42UDMB.js → chunk-CZOIPBED.js} +244 -126
- package/dist/chunk-CZOIPBED.js.map +6 -0
- package/dist/{chunk-VSUYGID4.js → chunk-UI6VQ263.js} +99 -31
- package/dist/{chunk-VSUYGID4.js.map → chunk-UI6VQ263.js.map} +1 -1
- package/dist/compiler/diagnostic.d.ts +4 -0
- package/dist/compiler/diagnostic.d.ts.map +1 -1
- package/dist/compiler/emit/index.d.ts +2 -0
- package/dist/compiler/emit/index.d.ts.map +1 -1
- package/dist/compiler/worker.js +1 -1
- package/dist/index.js +2 -2
- package/dist/subtle.js +6 -2
- package/dist/subtle.js.map +1 -1
- package/dist/vm/lib/global/index.d.ts +1 -1
- package/dist/vm/lib/global/index.d.ts.map +1 -1
- package/dist/vm/lib/global/math/arr.d.ts +7 -0
- package/dist/vm/lib/global/math/arr.d.ts.map +1 -0
- package/dist/vm/lib/global/math/const.d.ts +31 -0
- package/dist/vm/lib/global/math/const.d.ts.map +1 -0
- package/dist/vm/lib/global/math/gamma.d.ts +3 -0
- package/dist/vm/lib/global/math/gamma.d.ts.map +1 -0
- package/dist/vm/lib/global/math/index.d.ts +8 -0
- package/dist/vm/lib/global/math/index.d.ts.map +1 -0
- package/dist/vm/lib/global/math/unary.d.ts +28 -0
- package/dist/vm/lib/global/math/unary.d.ts.map +1 -0
- package/dist/vm/operations/common.d.ts +2 -2
- package/dist/vm/operations/common.d.ts.map +1 -1
- package/dist/vm/operations/helpers.d.ts +7 -2
- package/dist/vm/operations/helpers.d.ts.map +1 -1
- package/dist/vm/operations/type-check.d.ts +1 -1
- package/dist/vm/operations/type-check.d.ts.map +1 -1
- package/dist/vm/types/function.d.ts +2 -2
- package/dist/vm/types/function.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/compiler/diagnostic.ts +56 -31
- package/src/compiler/emit/index.ts +50 -0
- package/src/vm/lib/global/index.ts +1 -1
- package/src/vm/lib/global/{math-arr.ts → math/arr.ts} +2 -2
- package/src/vm/lib/global/{math-const.ts → math/const.ts} +1 -1
- package/src/vm/lib/global/math/gamma.ts +245 -0
- package/src/vm/lib/global/{math.ts → math/index.ts} +5 -5
- package/src/vm/lib/global/{math-unary.ts → math/unary.ts} +2 -2
- package/src/vm/lib/global/string.ts +1 -1
- package/src/vm/operations/common.ts +2 -2
- package/src/vm/operations/helpers.ts +16 -3
- package/src/vm/operations/type-check.ts +1 -1
- package/src/vm/types/function.ts +3 -2
- package/dist/chunk-CQ42UDMB.js.map +0 -6
- package/dist/vm/lib/global/math-additional.d.ts +0 -2
- package/dist/vm/lib/global/math-additional.d.ts.map +0 -1
- package/dist/vm/lib/global/math-arr.d.ts +0 -7
- package/dist/vm/lib/global/math-arr.d.ts.map +0 -1
- package/dist/vm/lib/global/math-const.d.ts +0 -31
- package/dist/vm/lib/global/math-const.d.ts.map +0 -1
- package/dist/vm/lib/global/math-unary.d.ts +0 -28
- package/dist/vm/lib/global/math-unary.d.ts.map +0 -1
- package/dist/vm/lib/global/math.d.ts +0 -8
- package/dist/vm/lib/global/math.d.ts.map +0 -1
- package/src/vm/lib/global/math-additional.ts +0 -69
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { VmAny } from '../../index.js';
|
|
2
|
-
export declare const trunc: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
3
|
-
export declare const floor: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
4
|
-
export declare const ceil: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
5
|
-
export declare const round: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
6
|
-
export declare const sign: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
7
|
-
export declare const abs: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
8
|
-
export declare const acos: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
9
|
-
export declare const acosh: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
10
|
-
export declare const asin: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
11
|
-
export declare const asinh: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
12
|
-
export declare const atan: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
13
|
-
export declare const atanh: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
14
|
-
export declare const cos: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
15
|
-
export declare const cosh: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
16
|
-
export declare const sin: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
17
|
-
export declare const sinh: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
18
|
-
export declare const tan: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
19
|
-
export declare const tanh: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
20
|
-
export declare const exp: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
21
|
-
export declare const expm1: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
22
|
-
export declare const log: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
23
|
-
export declare const log10: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
24
|
-
export declare const log1p: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
25
|
-
export declare const log2: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
26
|
-
export declare const sqrt: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
27
|
-
export declare const cbrt: ((x: VmAny) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
28
|
-
//# sourceMappingURL=math-unary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math-unary.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/math-unary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAU5C,eAAO,MAAM,KAAK,OAN4B,KAAK,KAAK,MAAM,8DAW5D,CAAC;AACH,eAAO,MAAM,KAAK,OAZ4B,KAAK,KAAK,MAAM,8DAiB5D,CAAC;AACH,eAAO,MAAM,IAAI,OAlB6B,KAAK,KAAK,MAAM,8DAuB5D,CAAC;AAIH,eAAO,MAAM,KAAK,OA3B4B,KAAK,KAAK,MAAM,8DA2C7D,CAAC;AACF,eAAO,MAAM,IAAI,OA5C6B,KAAK,KAAK,MAAM,8DAiD5D,CAAC;AACH,eAAO,MAAM,GAAG,OAlD8B,KAAK,KAAK,MAAM,8DAuD5D,CAAC;AAEH,eAAO,MAAM,IAAI,OAzD6B,KAAK,KAAK,MAAM,8DA8D5D,CAAC;AACH,eAAO,MAAM,KAAK,OA/D4B,KAAK,KAAK,MAAM,8DAoE5D,CAAC;AACH,eAAO,MAAM,IAAI,OArE6B,KAAK,KAAK,MAAM,8DA0E5D,CAAC;AACH,eAAO,MAAM,KAAK,OA3E4B,KAAK,KAAK,MAAM,8DAgF5D,CAAC;AACH,eAAO,MAAM,IAAI,OAjF6B,KAAK,KAAK,MAAM,8DAsF5D,CAAC;AACH,eAAO,MAAM,KAAK,OAvF4B,KAAK,KAAK,MAAM,8DA4F5D,CAAC;AACH,eAAO,MAAM,GAAG,OA7F8B,KAAK,KAAK,MAAM,8DAkG5D,CAAC;AACH,eAAO,MAAM,IAAI,OAnG6B,KAAK,KAAK,MAAM,8DAwG5D,CAAC;AACH,eAAO,MAAM,GAAG,OAzG8B,KAAK,KAAK,MAAM,8DA8G5D,CAAC;AACH,eAAO,MAAM,IAAI,OA/G6B,KAAK,KAAK,MAAM,8DAoH5D,CAAC;AACH,eAAO,MAAM,GAAG,OArH8B,KAAK,KAAK,MAAM,8DA0H5D,CAAC;AACH,eAAO,MAAM,IAAI,OA3H6B,KAAK,KAAK,MAAM,8DAgI5D,CAAC;AAEH,eAAO,MAAM,GAAG,OAlI8B,KAAK,KAAK,MAAM,8DAuI5D,CAAC;AACH,eAAO,MAAM,KAAK,OAxI4B,KAAK,KAAK,MAAM,8DA6I5D,CAAC;AACH,eAAO,MAAM,GAAG,OA9I8B,KAAK,KAAK,MAAM,8DAmJ5D,CAAC;AACH,eAAO,MAAM,KAAK,OApJ4B,KAAK,KAAK,MAAM,8DAyJ5D,CAAC;AACH,eAAO,MAAM,KAAK,OA1J4B,KAAK,KAAK,MAAM,8DA+J5D,CAAC;AACH,eAAO,MAAM,IAAI,OAhK6B,KAAK,KAAK,MAAM,8DAqK5D,CAAC;AAEH,eAAO,MAAM,IAAI,OAvK6B,KAAK,KAAK,MAAM,8DA4K5D,CAAC;AACH,eAAO,MAAM,IAAI,OA7K6B,KAAK,KAAK,MAAM,8DAkL5D,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const atan2: ((x: import("../../index.js").VmValue | undefined, y: import("../../index.js").VmValue | undefined) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
2
|
-
export declare const pow: ((x: import("../../index.js").VmValue | undefined, y: import("../../index.js").VmValue | undefined) => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
3
|
-
export declare const random: (() => number) & import("../helpers.js").VmLibOption & Record<never, never>;
|
|
4
|
-
export * from './math-arr.js';
|
|
5
|
-
export * from './math-const.js';
|
|
6
|
-
export * from './math-unary.js';
|
|
7
|
-
export * from './math-additional.js';
|
|
8
|
-
//# sourceMappingURL=math.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/math.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,6KAKhB,CAAC;AACH,eAAO,MAAM,GAAG,6KAKd,CAAC;AACH,eAAO,MAAM,MAAM,6EAKjB,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-loss-of-precision */
|
|
2
|
-
import { isInteger, isNaN, NotNumber, PositiveInfinity } from '../../../helpers/utils.js';
|
|
3
|
-
import { expectNumber, VmLib } from '../helpers.js';
|
|
4
|
-
const { sqrt, pow, exp } = Math;
|
|
5
|
-
|
|
6
|
-
const GAMMA_G = 4.742_187_5;
|
|
7
|
-
|
|
8
|
-
const GAMMA_P = [
|
|
9
|
-
0.999_999_999_999_997_091_82, 57.156_235_665_862_923_517, -59.597_960_355_475_491_248, 14.136_097_974_741_747_174,
|
|
10
|
-
-0.491_913_816_097_620_199_78, 0.339_946_499_848_118_886_99e-4, 0.465_236_289_270_485_756_65e-4,
|
|
11
|
-
-0.983_744_753_048_795_646_77e-4, 0.158_088_703_224_912_488_84e-3, -0.210_264_441_724_104_883_19e-3,
|
|
12
|
-
0.217_439_618_115_212_643_2e-3, -0.164_318_106_536_763_890_22e-3, 0.844_182_239_838_527_432_93e-4,
|
|
13
|
-
-0.261_908_384_015_814_086_7e-4, 0.368_991_826_595_316_227_04e-5,
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const SQRT_2_PI = sqrt(2 * Math.PI);
|
|
17
|
-
|
|
18
|
-
export const factorial = VmLib(
|
|
19
|
-
(x): number => {
|
|
20
|
-
let n = expectNumber('x', x);
|
|
21
|
-
if (isNaN(n) || n < 0) return NotNumber;
|
|
22
|
-
if (n >= 171) return PositiveInfinity; // will overflow
|
|
23
|
-
|
|
24
|
-
if (isInteger(n)) {
|
|
25
|
-
if (n === 0 || n === 1) return 1;
|
|
26
|
-
|
|
27
|
-
let r = 1;
|
|
28
|
-
for (let i = 2; i <= n; i++) {
|
|
29
|
-
r *= i;
|
|
30
|
-
}
|
|
31
|
-
return r;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (n > 85) {
|
|
35
|
-
// Extended Stirling Approx
|
|
36
|
-
n = n + 1;
|
|
37
|
-
const twoN = n * n;
|
|
38
|
-
const threeN = twoN * n;
|
|
39
|
-
const fourN = threeN * n;
|
|
40
|
-
const fiveN = fourN * n;
|
|
41
|
-
return (
|
|
42
|
-
sqrt((2 * Math.PI) / n) *
|
|
43
|
-
pow(n / Math.E, n) *
|
|
44
|
-
(1 +
|
|
45
|
-
1 / (12 * n) +
|
|
46
|
-
1 / (288 * twoN) -
|
|
47
|
-
139 / (51840 * threeN) -
|
|
48
|
-
571 / (2_488_320 * fourN) +
|
|
49
|
-
163_879 / (209_018_880 * fiveN) +
|
|
50
|
-
5_246_819 / (75_246_796_800 * fiveN * n))
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let p = GAMMA_P[0]!;
|
|
55
|
-
for (let i = 1; i < GAMMA_P.length; ++i) {
|
|
56
|
-
p += GAMMA_P[i]! / (n + i);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const t = n + GAMMA_G + 0.5;
|
|
60
|
-
return SQRT_2_PI * pow(t, n + 0.5) * exp(-t) * p;
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
summary: '返回一个数的阶乘',
|
|
64
|
-
params: { x: '要计算阶乘的数值' },
|
|
65
|
-
paramsType: { x: 'number' },
|
|
66
|
-
returnsType: 'number',
|
|
67
|
-
examples: ['factorial(5) // 120'],
|
|
68
|
-
},
|
|
69
|
-
);
|