@mirascript/mirascript 0.1.78 → 0.1.80
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-VNQQF2W7.js → chunk-BPFOJ4Q6.js} +381 -432
- package/dist/chunk-BPFOJ4Q6.js.map +6 -0
- package/dist/{chunk-BITOQYYQ.js → chunk-LSPCAN32.js} +204 -149
- package/dist/chunk-LSPCAN32.js.map +6 -0
- package/dist/compiler/emit/constants.d.ts +1 -1
- package/dist/compiler/emit/constants.d.ts.map +1 -1
- package/dist/compiler/emit/consts.d.ts.map +1 -1
- package/dist/compiler/worker.js +1 -1
- package/dist/helpers/convert/{to-boolean.d.ts → boolean.d.ts} +1 -1
- package/dist/helpers/convert/boolean.d.ts.map +1 -0
- package/dist/helpers/convert/{to-format.d.ts → format.d.ts} +1 -1
- package/dist/helpers/convert/format.d.ts.map +1 -0
- package/dist/helpers/convert/index.d.ts +4 -4
- package/dist/helpers/convert/index.d.ts.map +1 -1
- package/dist/helpers/convert/{to-number.d.ts → number.d.ts} +1 -1
- package/dist/helpers/convert/number.d.ts.map +1 -0
- package/dist/helpers/convert/{to-string.d.ts → string.d.ts} +1 -1
- package/dist/helpers/convert/string.d.ts.map +1 -0
- package/dist/helpers/serialize.d.ts.map +1 -1
- package/dist/helpers/types/array-like.d.ts +8 -0
- package/dist/helpers/types/array-like.d.ts.map +1 -0
- package/dist/helpers/types/basic.d.ts +26 -0
- package/dist/helpers/types/basic.d.ts.map +1 -0
- package/dist/helpers/types/composed.d.ts +12 -0
- package/dist/helpers/types/composed.d.ts.map +1 -0
- package/dist/helpers/types/const.d.ts +6 -0
- package/dist/helpers/types/const.d.ts.map +1 -0
- package/dist/helpers/types/get-type.d.ts +6 -0
- package/dist/helpers/types/get-type.d.ts.map +1 -0
- package/dist/helpers/types/index.d.ts +6 -0
- package/dist/helpers/types/index.d.ts.map +1 -0
- package/dist/helpers/types/proto.d.ts +5 -0
- package/dist/helpers/types/proto.d.ts.map +1 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/subtle.js +3 -3
- package/dist/vm/lib/global/json.d.ts +1 -1
- package/dist/vm/lib/global/json.d.ts.map +1 -1
- package/dist/vm/lib/helpers.d.ts.map +1 -1
- package/dist/vm/lib/mod/index.d.ts +1 -1
- package/dist/vm/lib/mod/index.d.ts.map +1 -1
- package/dist/vm/lib/mod/matrix/bin-ops.d.ts +8 -0
- package/dist/vm/lib/mod/matrix/bin-ops.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix/fill.d.ts +6 -0
- package/dist/vm/lib/mod/matrix/fill.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix/helpers.d.ts +6 -0
- package/dist/vm/lib/mod/matrix/helpers.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix/index.d.ts +6 -0
- package/dist/vm/lib/mod/matrix/index.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix/invert.d.ts +3 -0
- package/dist/vm/lib/mod/matrix/invert.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix/size.d.ts +2 -0
- package/dist/vm/lib/mod/matrix/size.d.ts.map +1 -0
- package/dist/vm/lib/mod/matrix/transpose.d.ts +2 -0
- package/dist/vm/lib/mod/matrix/transpose.d.ts.map +1 -0
- package/dist/vm/operations/array-range.d.ts +3 -3
- package/dist/vm/operations/array-range.d.ts.map +1 -1
- package/dist/vm/operations/call.d.ts +1 -1
- package/dist/vm/operations/call.d.ts.map +1 -1
- package/dist/vm/operations/compound.d.ts +1 -13
- package/dist/vm/operations/compound.d.ts.map +1 -1
- package/dist/vm/operations/index.d.ts +3 -0
- package/dist/vm/operations/index.d.ts.map +1 -1
- package/dist/vm/operations/iterable.d.ts +6 -0
- package/dist/vm/operations/iterable.d.ts.map +1 -0
- package/dist/vm/operations/record.d.ts +6 -0
- package/dist/vm/operations/record.d.ts.map +1 -0
- package/dist/vm/operations/slice.d.ts.map +1 -1
- package/dist/vm/operations/spread.d.ts +6 -0
- package/dist/vm/operations/spread.d.ts.map +1 -0
- package/dist/vm/operations/utils.d.ts.map +1 -1
- package/dist/vm/types/extern/access.d.ts +5 -0
- package/dist/vm/types/extern/access.d.ts.map +1 -0
- package/dist/vm/types/{extern.d.ts → extern/index.d.ts} +3 -3
- package/dist/vm/types/extern/index.d.ts.map +1 -0
- package/dist/vm/types/extern/tag.d.ts +3 -0
- package/dist/vm/types/extern/tag.d.ts.map +1 -0
- package/dist/vm/types/extern/utils.d.ts +13 -0
- package/dist/vm/types/extern/utils.d.ts.map +1 -0
- package/dist/vm/types/index.d.ts +3 -3
- package/dist/vm/types/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/compiler/diagnostic.ts +2 -2
- package/src/compiler/emit/constants.ts +1 -1
- package/src/compiler/emit/consts.ts +0 -1
- package/src/compiler/emit/index.ts +1 -1
- package/src/compiler/emit/sourcemap.ts +1 -1
- package/src/compiler/load-module.ts +5 -1
- package/src/helpers/convert/{to-boolean.ts → boolean.ts} +1 -1
- package/src/helpers/convert/{to-format.ts → format.ts} +1 -1
- package/src/helpers/convert/index.ts +4 -4
- package/src/helpers/convert/{to-number.ts → number.ts} +15 -26
- package/src/helpers/convert/{to-string.ts → string.ts} +2 -2
- package/src/helpers/serialize.ts +42 -36
- package/src/helpers/types/array-like.ts +32 -0
- package/src/helpers/types/basic.ts +82 -0
- package/src/helpers/types/composed.ts +27 -0
- package/src/helpers/types/const.ts +44 -0
- package/src/helpers/types/get-type.ts +16 -0
- package/src/helpers/types/index.ts +5 -0
- package/src/helpers/types/proto.ts +21 -0
- package/src/helpers/utils.ts +7 -1
- package/src/vm/lib/global/sequence/all-any.ts +1 -1
- package/src/vm/lib/global/sequence/find.ts +1 -1
- package/src/vm/lib/global/sequence/group.ts +1 -1
- package/src/vm/lib/global/sequence/map-filter.ts +1 -1
- package/src/vm/lib/global/sequence/new.ts +1 -1
- package/src/vm/lib/global/sequence/sort.ts +1 -1
- package/src/vm/lib/global/sequence/unique.ts +1 -1
- package/src/vm/lib/global/sequence/with.ts +1 -1
- package/src/vm/lib/global/time.ts +1 -1
- package/src/vm/lib/helpers.ts +8 -1
- package/src/vm/lib/mod/index.ts +1 -1
- package/src/vm/lib/mod/matrix/bin-ops.ts +291 -0
- package/src/vm/lib/mod/matrix/fill.ts +109 -0
- package/src/vm/lib/mod/matrix/helpers.ts +26 -0
- package/src/vm/lib/mod/matrix/index.ts +5 -0
- package/src/vm/lib/mod/matrix/invert.ts +122 -0
- package/src/vm/lib/mod/matrix/size.ts +15 -0
- package/src/vm/lib/mod/matrix/transpose.ts +32 -0
- package/src/vm/operations/array-range.ts +15 -27
- package/src/vm/operations/call.ts +2 -2
- package/src/vm/operations/compound.ts +4 -131
- package/src/vm/operations/helpers.ts +1 -1
- package/src/vm/operations/index.ts +3 -0
- package/src/vm/operations/iterable.ts +40 -0
- package/src/vm/operations/record.ts +33 -0
- package/src/vm/operations/slice.ts +23 -22
- package/src/vm/operations/spread.ts +57 -0
- package/src/vm/operations/type-check.ts +1 -1
- package/src/vm/operations/utils.ts +45 -37
- package/src/vm/types/boundary.ts +2 -2
- package/src/vm/types/extern/access.ts +24 -0
- package/src/vm/types/extern/index.ts +124 -0
- package/src/vm/types/extern/tag.ts +58 -0
- package/src/vm/types/extern/utils.ts +55 -0
- package/src/vm/types/function.ts +1 -1
- package/src/vm/types/index.ts +3 -3
- package/dist/chunk-BITOQYYQ.js.map +0 -6
- package/dist/chunk-VNQQF2W7.js.map +0 -6
- package/dist/helpers/convert/to-boolean.d.ts.map +0 -1
- package/dist/helpers/convert/to-format.d.ts.map +0 -1
- package/dist/helpers/convert/to-number.d.ts.map +0 -1
- package/dist/helpers/convert/to-string.d.ts.map +0 -1
- package/dist/helpers/types.d.ts +0 -58
- package/dist/helpers/types.d.ts.map +0 -1
- package/dist/vm/lib/mod/matrix.d.ts +0 -15
- package/dist/vm/lib/mod/matrix.d.ts.map +0 -1
- package/dist/vm/types/extern.d.ts.map +0 -1
- package/src/helpers/types.ts +0 -283
- package/src/vm/lib/mod/matrix.ts +0 -590
- package/src/vm/types/extern.ts +0 -197
package/src/helpers/types.ts
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import type { VmScript } from '../compiler/index.js';
|
|
2
|
-
import type {
|
|
3
|
-
VmAny,
|
|
4
|
-
VmArray,
|
|
5
|
-
VmConst,
|
|
6
|
-
VmContext,
|
|
7
|
-
VmExtern,
|
|
8
|
-
VmFunction,
|
|
9
|
-
VmFunctionInfo,
|
|
10
|
-
VmFunctionLike,
|
|
11
|
-
VmImmutable,
|
|
12
|
-
VmModule,
|
|
13
|
-
VmPrimitive,
|
|
14
|
-
VmRecord,
|
|
15
|
-
VmTypeName,
|
|
16
|
-
VmValue,
|
|
17
|
-
} from '../vm/types/index.js';
|
|
18
|
-
import type { VmWrapper } from '../vm/types/wrapper.js';
|
|
19
|
-
import {
|
|
20
|
-
kVmContext,
|
|
21
|
-
kVmExtern,
|
|
22
|
-
kVmFunction,
|
|
23
|
-
kVmModule,
|
|
24
|
-
kVmScript,
|
|
25
|
-
kVmWrapper,
|
|
26
|
-
VM_ARRAY_MAX_LENGTH,
|
|
27
|
-
} from './constants.js';
|
|
28
|
-
import { getPrototypeOf, isArray, keys, values } from './utils.js';
|
|
29
|
-
|
|
30
|
-
/** 检查是否为 Mirascript 脚本 */
|
|
31
|
-
export function isVmScript(value: unknown): value is VmScript {
|
|
32
|
-
return typeof value === 'function' && kVmScript in value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** 检查是否为执行上下文 */
|
|
36
|
-
export function isVmContext(context: unknown): context is VmContext {
|
|
37
|
-
return context != null && typeof context == 'object' && kVmContext in context;
|
|
38
|
-
}
|
|
39
|
-
/** 检查是否为 Mirascript 函数 */
|
|
40
|
-
export function isVmFunction<T extends VmFunctionLike>(value: unknown): value is VmFunction<T> {
|
|
41
|
-
return typeof value == 'function' && kVmFunction in value;
|
|
42
|
-
}
|
|
43
|
-
/** 检查是否为 Mirascript 函数,并获取其信息 */
|
|
44
|
-
export function getVmFunctionInfo(value: unknown): VmFunctionInfo | undefined {
|
|
45
|
-
if (typeof value != 'function') return undefined;
|
|
46
|
-
return (value as VmFunction)[kVmFunction];
|
|
47
|
-
}
|
|
48
|
-
/** 检查值是否为 MiraScript 包装器 */
|
|
49
|
-
export function isVmWrapper<T extends object>(value: unknown): value is VmWrapper<T> {
|
|
50
|
-
return value != null && typeof value == 'object' && kVmWrapper in value;
|
|
51
|
-
}
|
|
52
|
-
/** 检查值是否为 Mirascript 模块 */
|
|
53
|
-
export function isVmModule<T extends Record<string, VmImmutable>>(value: unknown): value is VmModule<T> {
|
|
54
|
-
return value != null && typeof value == 'object' && kVmModule in value;
|
|
55
|
-
}
|
|
56
|
-
/** 检查值是否为 Mirascript 外部值 */
|
|
57
|
-
export function isVmExtern<T extends object>(value: unknown): value is VmExtern<T> {
|
|
58
|
-
return value != null && typeof value == 'object' && kVmExtern in value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** 检查值是否为 Mirascript 可调用值 */
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
63
|
-
export function isVmCallable<E extends Function, F extends VmFunctionLike>(
|
|
64
|
-
value: unknown,
|
|
65
|
-
): value is VmFunction<F> | VmExtern<E> {
|
|
66
|
-
return isVmFunction<F>(value) || (isVmExtern<E>(value) && typeof value.value == 'function');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** 检查值是否为 Mirascript 原始值 */
|
|
70
|
-
export function isVmPrimitive(value: unknown): value is VmPrimitive {
|
|
71
|
-
if (value === null || typeof value == 'number' || typeof value == 'string' || typeof value == 'boolean') {
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
73
|
-
value as VmPrimitive satisfies typeof value;
|
|
74
|
-
value satisfies VmPrimitive;
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** 检查值是否为 Mirascript 数组 */
|
|
81
|
-
export function isVmArray(value: VmAny): value is VmArray {
|
|
82
|
-
if (!isArray(value)) return false;
|
|
83
|
-
value as VmArray satisfies VmArray;
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** 检查值是否为 Mirascript 记录 */
|
|
88
|
-
export function isVmRecord(value: VmAny): value is VmRecord {
|
|
89
|
-
if (value == null || typeof value != 'object') return false;
|
|
90
|
-
if (isVmWrapper(value)) return false;
|
|
91
|
-
if (isVmArray(value)) return false;
|
|
92
|
-
value satisfies VmRecord;
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** 检查是否为仅包含从 0 开始的连续数字键的 MiraScript 记录 */
|
|
97
|
-
export function isVmArrayLikeRecordByEntries(entries: ReadonlyArray<readonly [string, unknown]>): boolean {
|
|
98
|
-
const { length } = entries;
|
|
99
|
-
if (length === 0) return true;
|
|
100
|
-
if (length > VM_ARRAY_MAX_LENGTH) return false;
|
|
101
|
-
const firstKey = entries[0]![0];
|
|
102
|
-
if (firstKey !== '0') return false;
|
|
103
|
-
const lastKey = entries[length - 1]![0];
|
|
104
|
-
if (lastKey !== String(length - 1)) return false;
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** 检查是否为仅包含从 0 开始的连续数字键的 MiraScript 记录 */
|
|
109
|
-
export function isVmArrayLikeRecordByKeys(keys: readonly string[]): boolean {
|
|
110
|
-
const { length } = keys;
|
|
111
|
-
if (length === 0) return true;
|
|
112
|
-
if (length > VM_ARRAY_MAX_LENGTH) return false;
|
|
113
|
-
const firstKey = keys[0]!;
|
|
114
|
-
if (firstKey !== '0') return false;
|
|
115
|
-
const lastKey = keys[length - 1]!;
|
|
116
|
-
if (lastKey !== String(length - 1)) return false;
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** 检查是否为仅包含从 0 开始的连续数字键的 MiraScript 记录 */
|
|
121
|
-
export function isVmArrayLikeRecord(value: VmRecord): boolean {
|
|
122
|
-
return isVmArrayLikeRecordByKeys(keys(value));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const MAX_DEPTH = 16;
|
|
126
|
-
/**
|
|
127
|
-
* 检查是否为 Mirascript 数组
|
|
128
|
-
*/
|
|
129
|
-
function isVmArrayDeep(value: readonly unknown[], depth: number): value is VmArray {
|
|
130
|
-
// VmArray 应为普通数组
|
|
131
|
-
// Array.prototype
|
|
132
|
-
const proto1: unknown = getPrototypeOf(value);
|
|
133
|
-
if (!isArray(proto1)) return false;
|
|
134
|
-
if (!depth) return true;
|
|
135
|
-
return value.every((item) => isVmConstInner(item, depth));
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 检查是否为 Mirascript 记录
|
|
139
|
-
*/
|
|
140
|
-
function isVmRecordDeep(value: object, depth: number): value is VmRecord {
|
|
141
|
-
// VmRecord 应为普通对象或空原型对象
|
|
142
|
-
let isRecord;
|
|
143
|
-
// Object.prototype
|
|
144
|
-
const proto1: unknown = getPrototypeOf(value);
|
|
145
|
-
if (proto1 == null) {
|
|
146
|
-
isRecord = true;
|
|
147
|
-
} else {
|
|
148
|
-
// null
|
|
149
|
-
const proto2: unknown = getPrototypeOf(proto1);
|
|
150
|
-
if (proto2 != null) {
|
|
151
|
-
isRecord = false;
|
|
152
|
-
} else {
|
|
153
|
-
isRecord = 'hasOwnProperty' in value;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (!isRecord) return false;
|
|
157
|
-
if (!depth) return true;
|
|
158
|
-
return values(value).every((value) => isVmConstInner(value, depth));
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* 检查是否为 Mirascript 值语义值
|
|
162
|
-
*/
|
|
163
|
-
function isVmConstInner(value: unknown, depth: number): value is VmConst {
|
|
164
|
-
if (depth++ >= MAX_DEPTH) return false;
|
|
165
|
-
switch (typeof value) {
|
|
166
|
-
case 'string':
|
|
167
|
-
case 'number':
|
|
168
|
-
case 'boolean':
|
|
169
|
-
case 'undefined': // undefined 在复合类型内部被视为 nil
|
|
170
|
-
return true;
|
|
171
|
-
case 'object':
|
|
172
|
-
if (value == null) return true;
|
|
173
|
-
if (isVmWrapper(value)) return false;
|
|
174
|
-
if (isArray(value)) {
|
|
175
|
-
return isVmArrayDeep(value, depth);
|
|
176
|
-
} else {
|
|
177
|
-
return isVmRecordDeep(value, depth);
|
|
178
|
-
}
|
|
179
|
-
case 'function':
|
|
180
|
-
case 'bigint':
|
|
181
|
-
case 'symbol':
|
|
182
|
-
default:
|
|
183
|
-
return false; // Other types are not valid
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 检查是否为 Mirascript 值语义值
|
|
189
|
-
*/
|
|
190
|
-
export function isVmConst(value: VmAny): value is VmConst;
|
|
191
|
-
/**
|
|
192
|
-
* 检查是否为 Mirascript 值语义值
|
|
193
|
-
*/
|
|
194
|
-
export function isVmConst(value: unknown, checkDeep: boolean): value is VmConst;
|
|
195
|
-
/**
|
|
196
|
-
* 检查是否为 Mirascript 值语义值
|
|
197
|
-
*/
|
|
198
|
-
export function isVmConst(value: unknown, checkDeep = false): value is VmConst {
|
|
199
|
-
switch (typeof value) {
|
|
200
|
-
case 'string':
|
|
201
|
-
case 'number':
|
|
202
|
-
case 'boolean':
|
|
203
|
-
return true;
|
|
204
|
-
case 'object':
|
|
205
|
-
if (value == null) return true;
|
|
206
|
-
if (isVmWrapper(value)) return false;
|
|
207
|
-
if (!checkDeep) {
|
|
208
|
-
if (isArray(value)) {
|
|
209
|
-
return isVmArrayDeep(value, 0);
|
|
210
|
-
} else {
|
|
211
|
-
return isVmRecordDeep(value, 0);
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
return isVmConstInner(value, 1);
|
|
215
|
-
}
|
|
216
|
-
case 'undefined':
|
|
217
|
-
case 'function':
|
|
218
|
-
case 'bigint':
|
|
219
|
-
case 'symbol':
|
|
220
|
-
default:
|
|
221
|
-
return false; // Other types are not valid
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 检查是否为 Mirascript 不可变值
|
|
227
|
-
*/
|
|
228
|
-
export function isVmImmutable(value: VmAny): value is VmImmutable;
|
|
229
|
-
/**
|
|
230
|
-
* 检查是否为 Mirascript 不可变值
|
|
231
|
-
*/
|
|
232
|
-
export function isVmImmutable(value: unknown, checkDeep: boolean): value is VmImmutable;
|
|
233
|
-
/**
|
|
234
|
-
* 检查是否为 Mirascript 不可变值
|
|
235
|
-
*/
|
|
236
|
-
export function isVmImmutable(value: unknown, checkDeep = false): value is VmImmutable {
|
|
237
|
-
return isVmModule(value) || isVmFunction(value) || isVmConst(value, checkDeep);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** 检查是否为 Mirascript 值 */
|
|
241
|
-
export function isVmAny(value: unknown, checkDeep: boolean): value is VmAny {
|
|
242
|
-
switch (typeof value) {
|
|
243
|
-
case 'string':
|
|
244
|
-
case 'number':
|
|
245
|
-
case 'boolean':
|
|
246
|
-
case 'undefined':
|
|
247
|
-
return true;
|
|
248
|
-
case 'object':
|
|
249
|
-
if (value == null) return true;
|
|
250
|
-
if (isVmWrapper(value)) return true;
|
|
251
|
-
return isVmConst(value, checkDeep);
|
|
252
|
-
case 'function':
|
|
253
|
-
return isVmFunction(value);
|
|
254
|
-
case 'bigint':
|
|
255
|
-
case 'symbol':
|
|
256
|
-
default:
|
|
257
|
-
return false; // Other types are not valid
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/** 检查是否为 Mirascript 合法值 */
|
|
262
|
-
export function isVmValue(value: VmAny): value is VmValue;
|
|
263
|
-
/** 检查是否为 Mirascript 合法值 */
|
|
264
|
-
export function isVmValue(value: unknown, checkDeep: boolean): value is VmValue;
|
|
265
|
-
/** 检查是否为 Mirascript 合法值 */
|
|
266
|
-
export function isVmValue(value: unknown, checkDeep = false): value is VmValue {
|
|
267
|
-
if (value === undefined) return false;
|
|
268
|
-
return isVmAny(value, checkDeep);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/** 获取 MiraScript 类型 */
|
|
272
|
-
export function getVmType(value: VmValue): VmTypeName;
|
|
273
|
-
/** 获取 MiraScript 类型 */
|
|
274
|
-
export function getVmType(value: VmAny): VmTypeName | 'uninitialized';
|
|
275
|
-
/** 获取 MiraScript 类型 */
|
|
276
|
-
export function getVmType(value: VmAny): VmTypeName | 'uninitialized' {
|
|
277
|
-
if (value === undefined) return 'uninitialized';
|
|
278
|
-
if (value === null) return 'nil';
|
|
279
|
-
if (isVmWrapper(value)) return value.type;
|
|
280
|
-
if (isVmArray(value)) return 'array';
|
|
281
|
-
if (typeof value == 'object') return 'record';
|
|
282
|
-
return typeof value as VmTypeName;
|
|
283
|
-
}
|