@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
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
unwrapFromVmValue,
|
|
13
13
|
wrapScript,
|
|
14
14
|
wrapToVmValue
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CZOIPBED.js";
|
|
16
16
|
import {
|
|
17
17
|
VmError,
|
|
18
18
|
defineProperty,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
isVmValue,
|
|
39
39
|
isVmWrapper,
|
|
40
40
|
serialize
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-UI6VQ263.js";
|
|
42
42
|
|
|
43
43
|
// src/compiler/compile-fast.ts
|
|
44
44
|
import { isKeyword } from "@mirascript/constants";
|
package/dist/subtle.js
CHANGED
|
@@ -6,16 +6,18 @@ import {
|
|
|
6
6
|
lib,
|
|
7
7
|
operations_exports,
|
|
8
8
|
wrapScript
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CZOIPBED.js";
|
|
10
10
|
import {
|
|
11
11
|
DiagnosticCode,
|
|
12
12
|
REG_IDENTIFIER,
|
|
13
13
|
constants_exports,
|
|
14
14
|
display,
|
|
15
|
+
formatDiagnosticMessage,
|
|
15
16
|
formatDiagnostics,
|
|
16
17
|
generateBytecode,
|
|
17
18
|
generateBytecodeSync,
|
|
18
19
|
getDiagnosticMessage,
|
|
20
|
+
getDiagnosticSeverity,
|
|
19
21
|
parseDiagnostics,
|
|
20
22
|
serialize,
|
|
21
23
|
serializeArray,
|
|
@@ -25,7 +27,7 @@ import {
|
|
|
25
27
|
serializeRecord,
|
|
26
28
|
serializeRecordKey,
|
|
27
29
|
serializeString
|
|
28
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-UI6VQ263.js";
|
|
29
31
|
|
|
30
32
|
// src/subtle.ts
|
|
31
33
|
import { OpCode, isKeyword } from "@mirascript/constants";
|
|
@@ -96,10 +98,12 @@ export {
|
|
|
96
98
|
convert_exports as convert,
|
|
97
99
|
createScript,
|
|
98
100
|
emitScript,
|
|
101
|
+
formatDiagnosticMessage,
|
|
99
102
|
formatDiagnostics,
|
|
100
103
|
generateBytecode,
|
|
101
104
|
generateBytecodeSync,
|
|
102
105
|
getDiagnosticMessage,
|
|
106
|
+
getDiagnosticSeverity,
|
|
103
107
|
isKeyword,
|
|
104
108
|
lib,
|
|
105
109
|
operations_exports as operations,
|
package/dist/subtle.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/subtle.ts", "../src/helpers/analyze.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;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UAAM,WAAW,MAAM,CAAC,EAAE,MAAM,SAAS,EAAE,KAAK,GAAG;AACnD,WAAO,IAAI,QAAQ;AAAA,EACvB;AACA,QAAM,eAAuC,CAAC;AAC9C,aAAW,YAAY,QAAQ;AAC3B,UAAM,QAAQ,SAAS,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS;AAC5C,UAAI,MAAM,KAAK,IAAI,GAAG;AAElB,eAAO,SAAS,MAAM,EAAE;AAAA,MAC5B;AACA,aAAO;AAAA,IACX,CAAC;AACD,iBAAa,KAAK,KAAwC;AAAA,EAC9D;AACA,SAAO;AACX;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VmAny } from '../../../types/index.js';
|
|
2
|
+
export declare const max: ((...values: readonly VmAny[]) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
3
|
+
export declare const min: ((...values: readonly VmAny[]) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
4
|
+
export declare const hypot: ((...values: readonly VmAny[]) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
5
|
+
export declare const sum: ((...values: readonly VmAny[]) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
6
|
+
export declare const product: ((...values: readonly VmAny[]) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
7
|
+
//# sourceMappingURL=arr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arr.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/math/arr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAWrD,eAAO,MAAM,GAAG,eAPyD,SAAS,KAAK,EAAE,KAAK,MAAM,iEAalG,CAAC;AAEH,eAAO,MAAM,GAAG,eAfyD,SAAS,KAAK,EAAE,KAAK,MAAM,iEAqBlG,CAAC;AAEH,eAAO,MAAM,KAAK,eAvBuD,SAAS,KAAK,EAAE,KAAK,MAAM,iEA6BlG,CAAC;AAEH,eAAO,MAAM,GAAG,eACA,SAAS,KAAK,EAAE,4EAW/B,CAAC;AAEF,eAAO,MAAM,OAAO,eACJ,SAAS,KAAK,EAAE,4EAW/B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const PI: {
|
|
2
|
+
value: number;
|
|
3
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
4
|
+
export declare const E: {
|
|
5
|
+
value: number;
|
|
6
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
7
|
+
export declare const pi: {
|
|
8
|
+
value: number;
|
|
9
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
10
|
+
export declare const e: {
|
|
11
|
+
value: number;
|
|
12
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
13
|
+
export declare const SQRT1_2: {
|
|
14
|
+
value: number;
|
|
15
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
16
|
+
export declare const SQRT2: {
|
|
17
|
+
value: number;
|
|
18
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
19
|
+
export declare const LN2: {
|
|
20
|
+
value: number;
|
|
21
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
22
|
+
export declare const LN10: {
|
|
23
|
+
value: number;
|
|
24
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
25
|
+
export declare const LOG2E: {
|
|
26
|
+
value: number;
|
|
27
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
28
|
+
export declare const LOG10E: {
|
|
29
|
+
value: number;
|
|
30
|
+
} & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
31
|
+
//# sourceMappingURL=const.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/math/const.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,EAAE;;iEAGb,CAAC;AACH,eAAO,MAAM,CAAC;;iEAGZ,CAAC;AACH,eAAO,MAAM,EAAE;;iEAOb,CAAC;AACH,eAAO,MAAM,CAAC;;iEAOZ,CAAC;AACH,eAAO,MAAM,OAAO;;iEAGlB,CAAC;AACH,eAAO,MAAM,KAAK;;iEAGhB,CAAC;AACH,eAAO,MAAM,GAAG;;iEAGd,CAAC;AACH,eAAO,MAAM,IAAI;;iEAGf,CAAC;AACH,eAAO,MAAM,KAAK;;iEAGhB,CAAC;AACH,eAAO,MAAM,MAAM;;iEAGjB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const gamma: ((x: import("../../../index.js").VmValue | undefined) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
2
|
+
export declare const factorial: ((x: import("../../../index.js").VmValue | undefined) => number) & import("../../helpers.js").VmLibOption & Record<never, never>;
|
|
3
|
+
//# sourceMappingURL=gamma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gamma.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/math/gamma.ts"],"names":[],"mappings":"AA2MA,eAAO,MAAM,KAAK,kIAYjB,CAAC;AAgBF,eAAO,MAAM,SAAS,2DACb,MAAM,iEAYd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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 './arr.js';
|
|
5
|
+
export * from './const.js';
|
|
6
|
+
export * from './unary.js';
|
|
7
|
+
export { gamma, factorial } from './gamma.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/math/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,sLAKhB,CAAC;AACH,eAAO,MAAM,GAAG,sLAKd,CAAC;AACH,eAAO,MAAM,MAAM,gFAKjB,CAAC;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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=unary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/math/unary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAU/C,eAAO,MAAM,KAAK,OAN4B,KAAK,KAAK,MAAM,iEAW5D,CAAC;AACH,eAAO,MAAM,KAAK,OAZ4B,KAAK,KAAK,MAAM,iEAiB5D,CAAC;AACH,eAAO,MAAM,IAAI,OAlB6B,KAAK,KAAK,MAAM,iEAuB5D,CAAC;AAIH,eAAO,MAAM,KAAK,OA3B4B,KAAK,KAAK,MAAM,iEA2C7D,CAAC;AACF,eAAO,MAAM,IAAI,OA5C6B,KAAK,KAAK,MAAM,iEAiD5D,CAAC;AACH,eAAO,MAAM,GAAG,OAlD8B,KAAK,KAAK,MAAM,iEAuD5D,CAAC;AAEH,eAAO,MAAM,IAAI,OAzD6B,KAAK,KAAK,MAAM,iEA8D5D,CAAC;AACH,eAAO,MAAM,KAAK,OA/D4B,KAAK,KAAK,MAAM,iEAoE5D,CAAC;AACH,eAAO,MAAM,IAAI,OArE6B,KAAK,KAAK,MAAM,iEA0E5D,CAAC;AACH,eAAO,MAAM,KAAK,OA3E4B,KAAK,KAAK,MAAM,iEAgF5D,CAAC;AACH,eAAO,MAAM,IAAI,OAjF6B,KAAK,KAAK,MAAM,iEAsF5D,CAAC;AACH,eAAO,MAAM,KAAK,OAvF4B,KAAK,KAAK,MAAM,iEA4F5D,CAAC;AACH,eAAO,MAAM,GAAG,OA7F8B,KAAK,KAAK,MAAM,iEAkG5D,CAAC;AACH,eAAO,MAAM,IAAI,OAnG6B,KAAK,KAAK,MAAM,iEAwG5D,CAAC;AACH,eAAO,MAAM,GAAG,OAzG8B,KAAK,KAAK,MAAM,iEA8G5D,CAAC;AACH,eAAO,MAAM,IAAI,OA/G6B,KAAK,KAAK,MAAM,iEAoH5D,CAAC;AACH,eAAO,MAAM,GAAG,OArH8B,KAAK,KAAK,MAAM,iEA0H5D,CAAC;AACH,eAAO,MAAM,IAAI,OA3H6B,KAAK,KAAK,MAAM,iEAgI5D,CAAC;AAEH,eAAO,MAAM,GAAG,OAlI8B,KAAK,KAAK,MAAM,iEAuI5D,CAAC;AACH,eAAO,MAAM,KAAK,OAxI4B,KAAK,KAAK,MAAM,iEA6I5D,CAAC;AACH,eAAO,MAAM,GAAG,OA9I8B,KAAK,KAAK,MAAM,iEAmJ5D,CAAC;AACH,eAAO,MAAM,KAAK,OApJ4B,KAAK,KAAK,MAAM,iEAyJ5D,CAAC;AACH,eAAO,MAAM,KAAK,OA1J4B,KAAK,KAAK,MAAM,iEA+J5D,CAAC;AACH,eAAO,MAAM,IAAI,OAhK6B,KAAK,KAAK,MAAM,iEAqK5D,CAAC;AAEH,eAAO,MAAM,IAAI,OAvK6B,KAAK,KAAK,MAAM,iEA4K5D,CAAC;AACH,eAAO,MAAM,IAAI,OA7K6B,KAAK,KAAK,MAAM,iEAkL5D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VmValue } from '../types/index.js';
|
|
2
2
|
/** 断言值已初始化 */
|
|
3
|
-
export declare function $AssertInit(value:
|
|
3
|
+
export declare function $AssertInit<T extends VmValue>(value: T | undefined): asserts value is T;
|
|
4
4
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/vm/operations/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/vm/operations/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,cAAc;AACd,wBAAgB,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAEvF"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { VmFunctionLike } from '../types/function.js';
|
|
2
2
|
import { type VmContext } from '../types/context.js';
|
|
3
|
-
import type { VmConst, VmAny, VmArray, VmValue } from '../types/index.js';
|
|
3
|
+
import type { VmConst, VmAny, VmArray, VmValue, VmImmutable } from '../types/index.js';
|
|
4
|
+
import { VmModule } from '../types/module.js';
|
|
4
5
|
import { VmFunction } from '../types/function.js';
|
|
6
|
+
/** 构造 module */
|
|
7
|
+
export declare function $Module<T extends Record<string, () => VmImmutable>>(name: string, body: T): VmModule<{
|
|
8
|
+
[K in keyof T]: ReturnType<T[K]>;
|
|
9
|
+
}>;
|
|
5
10
|
/** 构造 record | array 元素 */
|
|
6
11
|
export declare function $El(value: VmAny): VmConst;
|
|
7
12
|
/** 构造 record 可选元素 */
|
|
@@ -9,7 +14,7 @@ export declare function $ElOpt(key: string, value: VmAny): VmConst;
|
|
|
9
14
|
/** 构造函数和函数表达式 */
|
|
10
15
|
export declare function $Fn<T extends VmFunctionLike>(name: string | null | undefined, fn: T): VmFunction<T>;
|
|
11
16
|
/** 读取闭包上值 */
|
|
12
|
-
export declare function $Upvalue(value:
|
|
17
|
+
export declare function $Upvalue<T extends VmValue>(value: T | undefined): T;
|
|
13
18
|
/** 构造范围数组 */
|
|
14
19
|
export declare function $ArrayRange(start: VmAny, end: VmAny): VmArray;
|
|
15
20
|
/** 构造范围数组(不包含结束值) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/vm/operations/helpers.ts"],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C,CAEnG;AAED,aAAa;AACb,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAGnE;AAUD,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAU7D;AACD,qBAAqB;AACrB,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAUtE;AAED,cAAc;AACd,wBAAgB,eAAe,IAAI,SAAS,CAE3C"}
|
|
@@ -12,5 +12,5 @@ export declare function $IsRecord(value: VmAny): value is VmRecord;
|
|
|
12
12
|
/** 判断值是否为数组 */
|
|
13
13
|
export declare function $IsArray(value: VmAny): value is VmArray;
|
|
14
14
|
/** 断言值非 nil */
|
|
15
|
-
export declare function $AssertNonNil(value:
|
|
15
|
+
export declare function $AssertNonNil<T extends VmValue>(value: T | undefined): asserts value is NonNullable<T>;
|
|
16
16
|
//# sourceMappingURL=type-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-check.d.ts","sourceRoot":"","sources":["../../../src/vm/operations/type-check.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGrF,eAAe;AACf,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CAO5C;AACD,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,OAAO,CAGzD;AACD,eAAe;AACf,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,MAAM,CAGvD;AACD,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,MAAM,CAGvD;AACD,eAAe;AACf,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,QAAQ,CAGzD;AACD,eAAe;AACf,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,OAAO,CAGvD;AACD,eAAe;AACf,wBAAgB,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"type-check.d.ts","sourceRoot":"","sources":["../../../src/vm/operations/type-check.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGrF,eAAe;AACf,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CAO5C;AACD,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,OAAO,CAGzD;AACD,eAAe;AACf,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,MAAM,CAGvD;AACD,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,MAAM,CAGvD;AACD,eAAe;AACf,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,QAAQ,CAGzD;AACD,eAAe;AACf,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,OAAO,CAGvD;AACD,eAAe;AACf,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAItG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DiagnosticCode } from '@mirascript/constants';
|
|
2
2
|
import { kVmFunction } from '../../helpers/constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { VmAny, VmValue } from './index.js';
|
|
4
4
|
import type { VmLib } from '../lib/helpers.js';
|
|
5
5
|
/**
|
|
6
6
|
* Mirascript 函数签名
|
|
@@ -46,5 +46,5 @@ export type VmFunctionOption = Partial<Omit<VmFunctionInfo, 'original'>> & {
|
|
|
46
46
|
readonly injectCp?: boolean;
|
|
47
47
|
};
|
|
48
48
|
/** 创建 Mirascript 函数 */
|
|
49
|
-
export declare function VmFunction<T extends VmFunctionLike>(fn: T, option?: VmFunctionOption | VmFunction | VmLib<T
|
|
49
|
+
export declare function VmFunction<T extends VmFunctionLike>(fn: T, option?: NoInfer<VmFunctionOption | VmFunction | VmLib<T>>): VmFunction<T>;
|
|
50
50
|
//# sourceMappingURL=function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/vm/types/function.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAA8B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/vm/types/function.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAA8B,MAAM,4BAA4B,CAAC;AAErF,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;GAIG;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,aAAa,CAAC,OAAO,GAAG,SAAS,CAAC,KAAK,KAAK,GAAG,IAAI,CAAC;AAE3F,oBAAoB;AACpB,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,cAAc,CA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AAC,CAAC,CAAC,CAAM,GAC/D,UAAU,CAAC,CAAC,CAAC,CAmDf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirascript/mirascript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"author": "CloudPSS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An expression based scripting language.",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"@cloudpss/worker": "^0.1.10",
|
|
30
30
|
"source-map-js": "^1.2.1",
|
|
31
31
|
"supports-color": "^10.2.2",
|
|
32
|
-
"@mirascript/bindings": "~0.1.
|
|
33
|
-
"@mirascript/constants": "~0.1.
|
|
32
|
+
"@mirascript/bindings": "~0.1.45",
|
|
33
|
+
"@mirascript/constants": "~0.1.45"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^25.2.
|
|
36
|
+
"@types/node": "^25.2.3",
|
|
37
37
|
"ava": "^6.4.1",
|
|
38
38
|
"c8": "^10.1.3",
|
|
39
39
|
"tinybench": "^6.0.0",
|
|
40
|
-
"type-fest": "^5.4.
|
|
40
|
+
"type-fest": "^5.4.4"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"watch": "pnpm build:ts --watch",
|
|
@@ -13,6 +13,39 @@ export function getDiagnosticMessage(code: DiagnosticCode): string | null {
|
|
|
13
13
|
return DIAGNOSTIC_MESSAGES[code] ?? null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/** 生成诊断消息的字符串 */
|
|
17
|
+
export function formatDiagnosticMessage(code: DiagnosticCode, $0?: string | (() => string | undefined)): string {
|
|
18
|
+
let template = getDiagnosticMessage(code);
|
|
19
|
+
if (!template) {
|
|
20
|
+
return `Unknown diagnostic code: ${code}`;
|
|
21
|
+
}
|
|
22
|
+
if (template.includes(`$0`)) {
|
|
23
|
+
const replacement = (typeof $0 == 'function' ? $0() : $0) ?? '';
|
|
24
|
+
// Replace each '$' in the captured text with '$$$$' so that after replaceAll processes
|
|
25
|
+
// the string and interprets '$' as a special placeholder, we still end up with literal
|
|
26
|
+
// '$$' in the final message. The quadruple dollar signs here are intentional.
|
|
27
|
+
template = template.replaceAll(`$0`, replacement.replaceAll('$', '$$$$'));
|
|
28
|
+
}
|
|
29
|
+
return template;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 获取诊断消息的级别 */
|
|
33
|
+
export function getDiagnosticSeverity(code: DiagnosticCode): 'error' | 'warning' | 'info' | 'hint' | 'tag' | undefined {
|
|
34
|
+
if (code > DiagnosticCode.ErrorStart && code < DiagnosticCode.ErrorEnd) {
|
|
35
|
+
return 'error';
|
|
36
|
+
} else if (code > DiagnosticCode.WarningStart && code < DiagnosticCode.WarningEnd) {
|
|
37
|
+
return 'warning';
|
|
38
|
+
} else if (code > DiagnosticCode.InfoStart && code < DiagnosticCode.InfoEnd) {
|
|
39
|
+
return 'info';
|
|
40
|
+
} else if (code > DiagnosticCode.HintStart && code < DiagnosticCode.HintEnd) {
|
|
41
|
+
return 'hint';
|
|
42
|
+
} else if (code > DiagnosticCode.TagStart && code < DiagnosticCode.TagEnd) {
|
|
43
|
+
return 'tag';
|
|
44
|
+
} else {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
16
49
|
/**
|
|
17
50
|
* A range in the editor. This interface is suitable for serialization.
|
|
18
51
|
*/
|
|
@@ -76,23 +109,7 @@ interface ParsedDiagnostics {
|
|
|
76
109
|
sourcemaps: IRange[];
|
|
77
110
|
}
|
|
78
111
|
|
|
79
|
-
const {
|
|
80
|
-
ErrorStart,
|
|
81
|
-
ErrorEnd,
|
|
82
|
-
WarningStart,
|
|
83
|
-
WarningEnd,
|
|
84
|
-
InfoStart,
|
|
85
|
-
InfoEnd,
|
|
86
|
-
HintStart,
|
|
87
|
-
HintEnd,
|
|
88
|
-
TagStart,
|
|
89
|
-
TagEnd,
|
|
90
|
-
ReferenceStart,
|
|
91
|
-
ReferenceEnd,
|
|
92
|
-
TagRefStart,
|
|
93
|
-
TagRefEnd,
|
|
94
|
-
SourceMap,
|
|
95
|
-
} = DiagnosticCode;
|
|
112
|
+
const { ReferenceStart, ReferenceEnd, TagRefStart, TagRefEnd, SourceMap } = DiagnosticCode;
|
|
96
113
|
/** 分析诊断信息,{@link diagnostic_position_encoding} 不能设为 `None` */
|
|
97
114
|
export function parseDiagnostics(
|
|
98
115
|
source: ScriptInput,
|
|
@@ -132,22 +149,30 @@ export function parseDiagnostics(
|
|
|
132
149
|
for (let i = 0; i < parsed.length; i++) {
|
|
133
150
|
const diagnostic = parsed[i]!;
|
|
134
151
|
const { code } = diagnostic;
|
|
135
|
-
if (code
|
|
136
|
-
_errors.push(diagnostic);
|
|
137
|
-
} else if (code > WarningStart && code < WarningEnd) {
|
|
138
|
-
_warnings.push(diagnostic);
|
|
139
|
-
} else if (code > InfoStart && code < InfoEnd) {
|
|
140
|
-
_infos.push(diagnostic);
|
|
141
|
-
} else if (code > HintStart && code < HintEnd) {
|
|
142
|
-
_hints.push(diagnostic);
|
|
143
|
-
} else if (code > TagStart && code < TagEnd) {
|
|
144
|
-
_tags.push(diagnostic);
|
|
145
|
-
} else if (code === SourceMap) {
|
|
152
|
+
if (code === SourceMap) {
|
|
146
153
|
_sourcemaps.push(diagnostic.range);
|
|
147
154
|
continue;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
}
|
|
156
|
+
switch (getDiagnosticSeverity(code)) {
|
|
157
|
+
case 'error':
|
|
158
|
+
_errors.push(diagnostic);
|
|
159
|
+
break;
|
|
160
|
+
case 'warning':
|
|
161
|
+
_warnings.push(diagnostic);
|
|
162
|
+
break;
|
|
163
|
+
case 'info':
|
|
164
|
+
_infos.push(diagnostic);
|
|
165
|
+
break;
|
|
166
|
+
case 'hint':
|
|
167
|
+
_hints.push(diagnostic);
|
|
168
|
+
break;
|
|
169
|
+
case 'tag':
|
|
170
|
+
_tags.push(diagnostic);
|
|
171
|
+
break;
|
|
172
|
+
case undefined:
|
|
173
|
+
default:
|
|
174
|
+
// 非法诊断代码,跳过
|
|
175
|
+
continue;
|
|
151
176
|
}
|
|
152
177
|
diagnostic.references = [];
|
|
153
178
|
while (i + 1 < parsed.length) {
|
|
@@ -185,6 +185,45 @@ export class Emitter {
|
|
|
185
185
|
return this.readBlockEnd(OpCode.IfEnd);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/** 读取 module */
|
|
189
|
+
private readModule(obj: number): void {
|
|
190
|
+
this.identCounter++;
|
|
191
|
+
while (this.codeOffset < this.codeSize) {
|
|
192
|
+
const opcode_raw = this.codeReader.getUint8(this.codeOffset++);
|
|
193
|
+
const opcode = opcode_raw & 0x7f;
|
|
194
|
+
const wide = opcode_raw >= 0x80;
|
|
195
|
+
const read = () => this.readParam(wide);
|
|
196
|
+
let code = '';
|
|
197
|
+
switch (opcode) {
|
|
198
|
+
case OpCode.Field: {
|
|
199
|
+
const field = read();
|
|
200
|
+
const field_name = this.constLits[field];
|
|
201
|
+
/* c8 ignore next 3 */
|
|
202
|
+
if (!field_name) {
|
|
203
|
+
throw new Error(`Unknown field ${field}`);
|
|
204
|
+
}
|
|
205
|
+
const value = read();
|
|
206
|
+
code = `[${field_name}]: () => $Upvalue(${this.rv(value)}),`;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case OpCode.Freeze: {
|
|
210
|
+
this.identCounter--;
|
|
211
|
+
code = `});`;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
default: {
|
|
215
|
+
code = `// ?${OpCode[opcode] ?? opcode}`;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const ident = this.ident();
|
|
220
|
+
this.codeLines.push(ident + code);
|
|
221
|
+
if (opcode === OpCode.Freeze) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
188
227
|
/** 读取 record */
|
|
189
228
|
private readRecord(obj: number): void {
|
|
190
229
|
this.identCounter++;
|
|
@@ -600,6 +639,13 @@ export class Emitter {
|
|
|
600
639
|
code = `${this.wv(reg)} = $SliceExclusive(${this.rv(obj)}, ${this.rv(start)}, ${this.rv(end)});`;
|
|
601
640
|
break;
|
|
602
641
|
}
|
|
642
|
+
case OpCode.Module: {
|
|
643
|
+
reg = read();
|
|
644
|
+
const nameIdx = read();
|
|
645
|
+
const name = this.constLits[nameIdx];
|
|
646
|
+
code = `${this.wv(reg)} = $Module(${name}, {`;
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
603
649
|
case OpCode.Record: {
|
|
604
650
|
reg = read();
|
|
605
651
|
code = `${this.wv(reg)} = ({`;
|
|
@@ -709,6 +755,10 @@ export class Emitter {
|
|
|
709
755
|
this.readBlockEnd(OpCode.LoopEnd);
|
|
710
756
|
break;
|
|
711
757
|
}
|
|
758
|
+
case OpCode.Module: {
|
|
759
|
+
this.readModule(reg);
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
712
762
|
case OpCode.Record: {
|
|
713
763
|
this.readRecord(reg);
|
|
714
764
|
break;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { VmAny } from '
|
|
2
|
-
import { getNumbers, VmLib } from '
|
|
1
|
+
import type { VmAny } from '../../../types/index.js';
|
|
2
|
+
import { getNumbers, VmLib } from '../../helpers.js';
|
|
3
3
|
|
|
4
4
|
/** 生成函数 */
|
|
5
5
|
function build(f: (...values: readonly number[]) => number): (...values: readonly VmAny[]) => number {
|