@mirascript/mirascript 0.1.14 → 0.1.16
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-Q74RKZ7O.js → chunk-LU4ZKFF6.js} +1420 -607
- package/dist/chunk-LU4ZKFF6.js.map +6 -0
- package/dist/chunk-RIT53WVY.js +1 -0
- package/dist/chunk-RLWIIOH5.js +12 -0
- package/dist/chunk-RLWIIOH5.js.map +6 -0
- package/dist/{chunk-55FKP56O.js → chunk-YZGL3D7L.js} +741 -1361
- package/dist/chunk-YZGL3D7L.js.map +6 -0
- package/dist/cli/index.js +11 -67
- package/dist/cli/index.js.map +2 -2
- package/dist/compiler/compile-fast.d.ts +1 -1
- package/dist/compiler/compile-fast.d.ts.map +1 -1
- package/dist/compiler/create-script.d.ts +10 -1
- package/dist/compiler/create-script.d.ts.map +1 -1
- package/dist/compiler/diagnostic.d.ts +1 -1
- package/dist/compiler/diagnostic.d.ts.map +1 -1
- package/dist/compiler/emit/constants.d.ts +3 -0
- package/dist/compiler/emit/constants.d.ts.map +1 -0
- package/dist/compiler/emit/consts.d.ts +6 -0
- package/dist/compiler/emit/consts.d.ts.map +1 -0
- package/dist/compiler/emit/globals.d.ts +17 -0
- package/dist/compiler/emit/globals.d.ts.map +1 -0
- package/dist/compiler/emit/index.d.ts +58 -0
- package/dist/compiler/emit/index.d.ts.map +1 -0
- package/dist/compiler/emit/sourcemap.d.ts +6 -0
- package/dist/compiler/emit/sourcemap.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +3 -2
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/worker.js +1 -1
- package/dist/helpers/constants.d.ts +15 -0
- package/dist/helpers/constants.d.ts.map +1 -1
- package/dist/helpers/convert.d.ts +12 -0
- package/dist/helpers/convert.d.ts.map +1 -0
- package/dist/{vm → helpers}/error.d.ts +1 -1
- package/dist/helpers/error.d.ts.map +1 -0
- package/dist/helpers/serialize.d.ts +14 -5
- package/dist/helpers/serialize.d.ts.map +1 -1
- package/dist/helpers/types.d.ts +54 -0
- package/dist/helpers/types.d.ts.map +1 -0
- package/dist/index.js +11 -17
- package/dist/subtle.d.ts +3 -2
- package/dist/subtle.d.ts.map +1 -1
- package/dist/subtle.js +21 -15
- package/dist/vm/checkpoint.d.ts +9 -0
- package/dist/vm/checkpoint.d.ts.map +1 -0
- package/dist/vm/helpers.d.ts +4 -10
- package/dist/vm/helpers.d.ts.map +1 -1
- package/dist/vm/index.d.ts +3 -3
- package/dist/vm/index.d.ts.map +1 -1
- package/dist/vm/lib/global/bit.d.ts +7 -7
- package/dist/vm/lib/global/bit.d.ts.map +1 -1
- package/dist/vm/lib/global/debug.d.ts +2 -2
- package/dist/vm/lib/global/debug.d.ts.map +1 -1
- package/dist/vm/lib/global/index.d.ts +0 -1
- package/dist/vm/lib/global/index.d.ts.map +1 -1
- package/dist/vm/lib/global/json.d.ts +2 -2
- package/dist/vm/lib/global/json.d.ts.map +1 -1
- package/dist/vm/lib/global/math-additional.d.ts +1 -1
- package/dist/vm/lib/global/math-additional.d.ts.map +1 -1
- package/dist/vm/lib/global/math-arr.d.ts +5 -5
- package/dist/vm/lib/global/math-arr.d.ts.map +1 -1
- package/dist/vm/lib/global/math-unary.d.ts +26 -26
- package/dist/vm/lib/global/math-unary.d.ts.map +1 -1
- package/dist/vm/lib/global/math.d.ts +3 -3
- package/dist/vm/lib/global/math.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/all-any.d.ts +2 -2
- package/dist/vm/lib/global/sequence/all-any.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/entries.d.ts +5 -5
- package/dist/vm/lib/global/sequence/entries.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/find.d.ts +3 -3
- package/dist/vm/lib/global/sequence/find.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/flatten.d.ts +1 -1
- package/dist/vm/lib/global/sequence/flatten.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/len.d.ts +1 -1
- package/dist/vm/lib/global/sequence/len.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/map-filter.d.ts +3 -3
- package/dist/vm/lib/global/sequence/map-filter.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/repeat.d.ts +1 -1
- package/dist/vm/lib/global/sequence/repeat.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/reverse.d.ts +1 -1
- package/dist/vm/lib/global/sequence/reverse.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/sort.d.ts +2 -2
- package/dist/vm/lib/global/sequence/sort.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/with.d.ts +2 -2
- package/dist/vm/lib/global/sequence/with.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/zip.d.ts +1 -1
- package/dist/vm/lib/global/sequence/zip.d.ts.map +1 -1
- package/dist/vm/lib/global/string.d.ts +10 -10
- package/dist/vm/lib/global/string.d.ts.map +1 -1
- package/dist/vm/lib/global/time.d.ts +3 -13
- package/dist/vm/lib/global/time.d.ts.map +1 -1
- package/dist/vm/lib/global/to-primitive.d.ts +4 -4
- package/dist/vm/lib/global/to-primitive.d.ts.map +1 -1
- package/dist/vm/lib/helpers.d.ts +53 -0
- package/dist/vm/lib/helpers.d.ts.map +1 -0
- package/dist/vm/lib/index.d.ts +4 -0
- package/dist/vm/lib/index.d.ts.map +1 -0
- package/dist/vm/lib/{_loader.d.ts → loader.d.ts} +5 -5
- package/dist/vm/lib/loader.d.ts.map +1 -0
- package/dist/vm/lib/mod/index.d.ts +2 -0
- package/dist/vm/lib/mod/index.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix.d.ts +15 -0
- package/dist/vm/lib/mod/matrix.d.ts.map +1 -0
- package/dist/vm/operations.d.ts +4 -6
- package/dist/vm/operations.d.ts.map +1 -1
- package/dist/vm/types/boundary.d.ts +1 -1
- package/dist/vm/types/boundary.d.ts.map +1 -1
- package/dist/vm/types/context.d.ts +18 -12
- package/dist/vm/types/context.d.ts.map +1 -1
- package/dist/vm/types/extern.d.ts +1 -3
- package/dist/vm/types/extern.d.ts.map +1 -1
- package/dist/vm/types/function.d.ts +1 -6
- package/dist/vm/types/function.d.ts.map +1 -1
- package/dist/vm/types/index.d.ts +31 -17
- package/dist/vm/types/index.d.ts.map +1 -1
- package/dist/vm/types/module.d.ts +2 -4
- package/dist/vm/types/module.d.ts.map +1 -1
- package/dist/vm/types/wrapper.d.ts +0 -2
- package/dist/vm/types/wrapper.d.ts.map +1 -1
- package/package.json +7 -3
- package/src/cli/index.ts +1 -1
- package/src/compiler/compile-fast.ts +1 -2
- package/src/compiler/create-script.ts +12 -2
- package/src/compiler/diagnostic.ts +17 -8
- package/src/compiler/emit/constants.ts +2 -0
- package/src/compiler/emit/consts.ts +47 -0
- package/src/compiler/emit/globals.ts +39 -0
- package/src/compiler/{emit.ts → emit/index.ts} +18 -202
- package/src/compiler/emit/sourcemap.ts +163 -0
- package/src/compiler/index.ts +9 -9
- package/src/compiler/worker.ts +1 -1
- package/src/helpers/constants.ts +18 -1
- package/src/helpers/convert.ts +128 -0
- package/src/{vm → helpers}/error.ts +1 -1
- package/src/helpers/serialize.ts +72 -25
- package/src/helpers/types.ts +267 -0
- package/src/subtle.ts +3 -1
- package/src/vm/checkpoint.ts +42 -0
- package/src/vm/helpers.ts +9 -53
- package/src/vm/index.ts +3 -3
- package/src/vm/lib/global/bit.ts +8 -9
- package/src/vm/lib/global/debug.ts +5 -4
- package/src/vm/lib/global/index.ts +0 -1
- package/src/vm/lib/global/json.ts +2 -2
- package/src/vm/lib/global/math-additional.ts +2 -4
- package/src/vm/lib/global/math-arr.ts +1 -1
- package/src/vm/lib/global/math-unary.ts +2 -4
- package/src/vm/lib/global/math.ts +3 -4
- package/src/vm/lib/global/sequence/all-any.ts +11 -6
- package/src/vm/lib/global/sequence/entries.ts +3 -3
- package/src/vm/lib/global/sequence/find.ts +8 -7
- package/src/vm/lib/global/sequence/flatten.ts +2 -3
- package/src/vm/lib/global/sequence/len.ts +1 -1
- package/src/vm/lib/global/sequence/map-filter.ts +7 -6
- package/src/vm/lib/global/sequence/repeat.ts +2 -4
- package/src/vm/lib/global/sequence/reverse.ts +1 -1
- package/src/vm/lib/global/sequence/sort.ts +6 -5
- package/src/vm/lib/global/sequence/with.ts +22 -21
- package/src/vm/lib/global/sequence/zip.ts +4 -4
- package/src/vm/lib/global/string.ts +16 -27
- package/src/vm/lib/global/time.ts +59 -30
- package/src/vm/lib/global/to-primitive.ts +27 -18
- package/src/vm/lib/{_helpers.ts → helpers.ts} +129 -41
- package/src/vm/lib/index.ts +16 -0
- package/src/vm/lib/{_loader.ts → loader.ts} +3 -11
- package/src/vm/lib/mod/index.ts +1 -0
- package/src/vm/lib/{global/mod → mod}/matrix.ts +9 -7
- package/src/vm/operations.ts +33 -128
- package/src/vm/types/boundary.ts +10 -13
- package/src/vm/types/context.ts +36 -28
- package/src/vm/types/extern.ts +8 -15
- package/src/vm/types/function.ts +4 -19
- package/src/vm/types/index.ts +47 -25
- package/src/vm/types/module.ts +3 -7
- package/src/vm/types/wrapper.ts +1 -5
- package/dist/chunk-35JGBXRE.js +0 -1
- package/dist/chunk-55FKP56O.js.map +0 -6
- package/dist/chunk-Q74RKZ7O.js.map +0 -6
- package/dist/compiler/emit.d.ts +0 -5
- package/dist/compiler/emit.d.ts.map +0 -1
- package/dist/vm/error.d.ts.map +0 -1
- package/dist/vm/lib/_helpers.d.ts +0 -35
- package/dist/vm/lib/_helpers.d.ts.map +0 -1
- package/dist/vm/lib/_loader.d.ts.map +0 -1
- package/dist/vm/lib/global/mod/index.d.ts +0 -3
- package/dist/vm/lib/global/mod/index.d.ts.map +0 -1
- package/dist/vm/lib/global/mod/matrix.d.ts +0 -15
- package/dist/vm/lib/global/mod/matrix.d.ts.map +0 -1
- package/dist/vm/types/any.d.ts +0 -10
- package/dist/vm/types/any.d.ts.map +0 -1
- package/dist/vm/types/array.d.ts +0 -12
- package/dist/vm/types/array.d.ts.map +0 -1
- package/dist/vm/types/callable.d.ts +0 -5
- package/dist/vm/types/callable.d.ts.map +0 -1
- package/dist/vm/types/const.d.ts +0 -15
- package/dist/vm/types/const.d.ts.map +0 -1
- package/dist/vm/types/immutable.d.ts +0 -15
- package/dist/vm/types/immutable.d.ts.map +0 -1
- package/dist/vm/types/primitive.d.ts +0 -7
- package/dist/vm/types/primitive.d.ts.map +0 -1
- package/dist/vm/types/record.d.ts +0 -20
- package/dist/vm/types/record.d.ts.map +0 -1
- package/dist/vm/types/script.d.ts +0 -14
- package/dist/vm/types/script.d.ts.map +0 -1
- package/dist/vm/types/value.d.ts +0 -14
- package/dist/vm/types/value.d.ts.map +0 -1
- package/src/vm/lib/global/mod/index.ts +0 -4
- package/src/vm/types/any.ts +0 -33
- package/src/vm/types/array.ts +0 -19
- package/src/vm/types/callable.ts +0 -10
- package/src/vm/types/const.ts +0 -109
- package/src/vm/types/immutable.ts +0 -22
- package/src/vm/types/primitive.ts +0 -14
- package/src/vm/types/record.ts +0 -53
- package/src/vm/types/script.ts +0 -18
- package/src/vm/types/value.ts +0 -22
- /package/dist/{chunk-35JGBXRE.js.map → chunk-RIT53WVY.js.map} +0 -0
package/src/vm/types/const.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { VmArray } from './array.js';
|
|
2
|
-
import type { VmPrimitive } from './primitive.js';
|
|
3
|
-
import type { VmRecord } from './record.js';
|
|
4
|
-
import type { VmAny } from './any.js';
|
|
5
|
-
import { getPrototypeOf, isArray, values } from '../../helpers/utils.js';
|
|
6
|
-
import { isVmWrapper } from './wrapper.js';
|
|
7
|
-
|
|
8
|
-
/** Mirascript 虚拟机内的值语义值 */
|
|
9
|
-
export type VmConst = VmPrimitive | VmRecord | VmArray;
|
|
10
|
-
|
|
11
|
-
const MAX_DEPTH = 32;
|
|
12
|
-
/**
|
|
13
|
-
* 检查是否为 Mirascript 数组
|
|
14
|
-
*/
|
|
15
|
-
function isVmArrayDeep(value: readonly unknown[], depth: number): value is VmArray {
|
|
16
|
-
// VmArray 应为普通数组
|
|
17
|
-
// Array.prototype
|
|
18
|
-
const proto1: unknown = getPrototypeOf(value);
|
|
19
|
-
if (!isArray(proto1)) return false;
|
|
20
|
-
if (!depth) return true;
|
|
21
|
-
return value.every((item) => isVmConstInner(item, depth));
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 检查是否为 Mirascript 记录
|
|
25
|
-
*/
|
|
26
|
-
function isVmRecordDeep(value: object, depth: number): value is VmRecord {
|
|
27
|
-
// VmRecord 应为普通对象或空原型对象
|
|
28
|
-
let isRecord;
|
|
29
|
-
// Object.prototype
|
|
30
|
-
const proto1: unknown = getPrototypeOf(value);
|
|
31
|
-
if (proto1 == null) {
|
|
32
|
-
isRecord = true;
|
|
33
|
-
} else {
|
|
34
|
-
// null
|
|
35
|
-
const proto2: unknown = getPrototypeOf(proto1);
|
|
36
|
-
if (proto2 != null) {
|
|
37
|
-
isRecord = false;
|
|
38
|
-
} else {
|
|
39
|
-
isRecord = 'hasOwnProperty' in value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (!isRecord) return false;
|
|
43
|
-
if (!depth) return true;
|
|
44
|
-
return values(value).every((value) => isVmConstInner(value, depth));
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 检查是否为 Mirascript 值语义值
|
|
48
|
-
*/
|
|
49
|
-
function isVmConstInner(value: unknown, depth: number): value is VmConst {
|
|
50
|
-
if (depth++ >= MAX_DEPTH) return false;
|
|
51
|
-
switch (typeof value) {
|
|
52
|
-
case 'string':
|
|
53
|
-
case 'number':
|
|
54
|
-
case 'boolean':
|
|
55
|
-
case 'undefined': // undefined 在复合类型内部被视为 nil
|
|
56
|
-
return true;
|
|
57
|
-
case 'object':
|
|
58
|
-
if (value == null) return true;
|
|
59
|
-
if (isVmWrapper(value)) return false;
|
|
60
|
-
if (isArray(value)) {
|
|
61
|
-
return isVmArrayDeep(value, depth);
|
|
62
|
-
} else {
|
|
63
|
-
return isVmRecordDeep(value, depth);
|
|
64
|
-
}
|
|
65
|
-
case 'function':
|
|
66
|
-
case 'bigint':
|
|
67
|
-
case 'symbol':
|
|
68
|
-
default:
|
|
69
|
-
return false; // Other types are not valid
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 检查是否为 Mirascript 值语义值
|
|
75
|
-
*/
|
|
76
|
-
export function isVmConst(value: VmAny): value is VmConst;
|
|
77
|
-
/**
|
|
78
|
-
* 检查是否为 Mirascript 值语义值
|
|
79
|
-
*/
|
|
80
|
-
export function isVmConst(value: unknown, checkDeep: boolean): value is VmConst;
|
|
81
|
-
/**
|
|
82
|
-
* 检查是否为 Mirascript 值语义值
|
|
83
|
-
*/
|
|
84
|
-
export function isVmConst(value: unknown, checkDeep = false): value is VmConst {
|
|
85
|
-
switch (typeof value) {
|
|
86
|
-
case 'string':
|
|
87
|
-
case 'number':
|
|
88
|
-
case 'boolean':
|
|
89
|
-
return true;
|
|
90
|
-
case 'object':
|
|
91
|
-
if (value == null) return true;
|
|
92
|
-
if (isVmWrapper(value)) return false;
|
|
93
|
-
if (!checkDeep) {
|
|
94
|
-
if (isArray(value)) {
|
|
95
|
-
return isVmArrayDeep(value, 0);
|
|
96
|
-
} else {
|
|
97
|
-
return isVmRecordDeep(value, 0);
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
return isVmConstInner(value, 1);
|
|
101
|
-
}
|
|
102
|
-
case 'undefined':
|
|
103
|
-
case 'function':
|
|
104
|
-
case 'bigint':
|
|
105
|
-
case 'symbol':
|
|
106
|
-
default:
|
|
107
|
-
return false; // Other types are not valid
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { VmAny } from './any.js';
|
|
2
|
-
import { isVmConst, type VmConst } from './const.js';
|
|
3
|
-
import { isVmFunction, type VmFunction } from './function.js';
|
|
4
|
-
import { isVmModule, type VmModule } from './module.js';
|
|
5
|
-
|
|
6
|
-
/** Mirascript 虚拟机内的不可变值 */
|
|
7
|
-
export type VmImmutable = VmConst | VmFunction | VmModule;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 检查是否为 Mirascript 不可变值
|
|
11
|
-
*/
|
|
12
|
-
export function isVmImmutable(value: VmAny): value is VmImmutable;
|
|
13
|
-
/**
|
|
14
|
-
* 检查是否为 Mirascript 不可变值
|
|
15
|
-
*/
|
|
16
|
-
export function isVmImmutable(value: unknown, checkDeep: boolean): value is VmImmutable;
|
|
17
|
-
/**
|
|
18
|
-
* 检查是否为 Mirascript 不可变值
|
|
19
|
-
*/
|
|
20
|
-
export function isVmImmutable(value: unknown, checkDeep = false): value is VmImmutable {
|
|
21
|
-
return isVmModule(value) || isVmFunction(value) || isVmConst(value, checkDeep);
|
|
22
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Mirascript 原始值 */
|
|
2
|
-
export type VmPrimitive = null | string | number | boolean;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 检查值是否为 Mirascript 原始值
|
|
6
|
-
*/
|
|
7
|
-
export function isVmPrimitive(value: unknown): value is VmPrimitive {
|
|
8
|
-
if (value === null || typeof value == 'number' || typeof value == 'string' || typeof value == 'boolean') {
|
|
9
|
-
value as VmPrimitive satisfies typeof value;
|
|
10
|
-
value satisfies VmPrimitive;
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
package/src/vm/types/record.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { keys } from '../../helpers/utils.js';
|
|
2
|
-
import { isVmArray, VM_ARRAY_MAX_LENGTH } from './array.js';
|
|
3
|
-
import { isVmWrapper, type VmAny, type VmConst } from './index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Mirascript 记录
|
|
7
|
-
* 仅拥有且可枚举的字符串键视作存在
|
|
8
|
-
* 字段值 `undefined` 和 `null` 均视作 `nil`
|
|
9
|
-
*/
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
|
11
|
-
export type VmRecord = {
|
|
12
|
-
readonly [key: string]: VmConst | undefined;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 检查值是否为 Mirascript 记录
|
|
17
|
-
*/
|
|
18
|
-
export function isVmRecord(value: VmAny): value is VmRecord {
|
|
19
|
-
if (value == null || typeof value !== 'object') return false;
|
|
20
|
-
if (isVmWrapper(value)) return false;
|
|
21
|
-
if (isVmArray(value)) return false;
|
|
22
|
-
value satisfies VmRecord;
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** 检查是否为仅包含从 0 开始的连续数字键的 MiraScript 记录 */
|
|
27
|
-
export function isVmArrayLikeRecordByEntires(entries: ReadonlyArray<readonly [string, unknown]>): boolean {
|
|
28
|
-
const { length } = entries;
|
|
29
|
-
if (length === 0) return true;
|
|
30
|
-
if (length > VM_ARRAY_MAX_LENGTH) return false;
|
|
31
|
-
const firstKey = entries[0]![0];
|
|
32
|
-
if (firstKey !== '0') return false;
|
|
33
|
-
const lastKey = entries[length - 1]![0];
|
|
34
|
-
if (lastKey !== String(length - 1)) return false;
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** 检查是否为仅包含从 0 开始的连续数字键的 MiraScript 记录 */
|
|
39
|
-
export function isVmArrayLikeRecordByKeys(keys: readonly string[]): boolean {
|
|
40
|
-
const { length } = keys;
|
|
41
|
-
if (length === 0) return true;
|
|
42
|
-
if (length > VM_ARRAY_MAX_LENGTH) return false;
|
|
43
|
-
const firstKey = keys[0]!;
|
|
44
|
-
if (firstKey !== '0') return false;
|
|
45
|
-
const lastKey = keys[length - 1]!;
|
|
46
|
-
if (lastKey !== String(length - 1)) return false;
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** 检查是否为仅包含从 0 开始的连续数字键的 MiraScript 记录 */
|
|
51
|
-
export function isVmArrayLikeRecord(value: VmRecord): boolean {
|
|
52
|
-
return isVmArrayLikeRecordByKeys(keys(value));
|
|
53
|
-
}
|
package/src/vm/types/script.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { VmContext, VmValue } from './index.js';
|
|
2
|
-
|
|
3
|
-
const kVmScript = Symbol.for('mirascript.vm.script');
|
|
4
|
-
|
|
5
|
-
/** Mirascript 脚本 */
|
|
6
|
-
export type VmScriptLike = (global?: VmContext) => VmValue;
|
|
7
|
-
|
|
8
|
-
/** Mirascript 脚本 */
|
|
9
|
-
export type VmScript = VmScriptLike & {
|
|
10
|
-
readonly [kVmScript]: true;
|
|
11
|
-
/** 原始代码 */
|
|
12
|
-
readonly source: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/** 检查是否为 Mirascript 脚本 */
|
|
16
|
-
export function isVmScript(value: unknown): value is VmScript {
|
|
17
|
-
return typeof value === 'function' && (value as VmScript)[kVmScript] === true;
|
|
18
|
-
}
|
package/src/vm/types/value.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { isVmAny, type VmAny } from './any.js';
|
|
2
|
-
import type { VmExtern } from './extern.js';
|
|
3
|
-
import type { VmImmutable } from './immutable.js';
|
|
4
|
-
|
|
5
|
-
/** Mirascript 虚拟机内的合法值 */
|
|
6
|
-
export type VmValue = VmImmutable | VmExtern;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 检查是否为 Mirascript 合法值
|
|
10
|
-
*/
|
|
11
|
-
export function isVmValue(value: VmAny): value is VmValue;
|
|
12
|
-
/**
|
|
13
|
-
* 检查是否为 Mirascript 合法值
|
|
14
|
-
*/
|
|
15
|
-
export function isVmValue(value: unknown, checkDeep: boolean): value is VmValue;
|
|
16
|
-
/**
|
|
17
|
-
* 检查是否为 Mirascript 合法值
|
|
18
|
-
*/
|
|
19
|
-
export function isVmValue(value: unknown, checkDeep = false): value is VmValue {
|
|
20
|
-
if (value === undefined) return false;
|
|
21
|
-
return isVmAny(value, checkDeep);
|
|
22
|
-
}
|
|
File without changes
|