@mirascript/mirascript 0.1.13 → 0.1.14

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.
Files changed (74) hide show
  1. package/dist/chunk-55FKP56O.js +2317 -0
  2. package/dist/chunk-55FKP56O.js.map +6 -0
  3. package/dist/{chunk-IKSSUVRE.js → chunk-Q74RKZ7O.js} +73 -1250
  4. package/dist/chunk-Q74RKZ7O.js.map +6 -0
  5. package/dist/cli/index.js +8 -7
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/compiler/emit.d.ts.map +1 -1
  8. package/dist/compiler/worker.js +1 -1
  9. package/dist/helpers/serialize.d.ts +1 -1
  10. package/dist/helpers/serialize.d.ts.map +1 -1
  11. package/dist/index.js +15 -9
  12. package/dist/subtle.d.ts +1 -1
  13. package/dist/subtle.d.ts.map +1 -1
  14. package/dist/subtle.js +7 -7
  15. package/dist/vm/lib/global/debug.d.ts +1 -1
  16. package/dist/vm/lib/global/json.d.ts +2 -2
  17. package/dist/vm/lib/global/json.d.ts.map +1 -1
  18. package/dist/vm/lib/global/mod/matrix.d.ts +1 -1
  19. package/dist/vm/lib/global/mod/matrix.d.ts.map +1 -1
  20. package/dist/vm/lib/global/sequence/all-any.d.ts +2 -2
  21. package/dist/vm/lib/global/sequence/entries.d.ts +4 -4
  22. package/dist/vm/lib/global/sequence/find.d.ts +2 -2
  23. package/dist/vm/lib/global/sequence/repeat.d.ts +1 -1
  24. package/dist/vm/lib/global/sequence/with.d.ts +1 -1
  25. package/dist/vm/lib/global/sequence/with.d.ts.map +1 -1
  26. package/dist/vm/lib/global/sequence/zip.d.ts +1 -1
  27. package/dist/vm/operations.d.ts +2 -0
  28. package/dist/vm/operations.d.ts.map +1 -1
  29. package/dist/vm/types/any.d.ts +10 -0
  30. package/dist/vm/types/any.d.ts.map +1 -0
  31. package/dist/vm/types/array.d.ts +12 -0
  32. package/dist/vm/types/array.d.ts.map +1 -0
  33. package/dist/vm/types/callable.d.ts +5 -0
  34. package/dist/vm/types/callable.d.ts.map +1 -0
  35. package/dist/vm/types/const.d.ts +15 -0
  36. package/dist/vm/types/const.d.ts.map +1 -0
  37. package/dist/vm/types/context.d.ts.map +1 -1
  38. package/dist/vm/types/extern.d.ts +1 -1
  39. package/dist/vm/types/extern.d.ts.map +1 -1
  40. package/dist/vm/types/immutable.d.ts +15 -0
  41. package/dist/vm/types/immutable.d.ts.map +1 -0
  42. package/dist/vm/types/index.d.ts +17 -47
  43. package/dist/vm/types/index.d.ts.map +1 -1
  44. package/dist/vm/types/primitive.d.ts +7 -0
  45. package/dist/vm/types/primitive.d.ts.map +1 -0
  46. package/dist/vm/types/record.d.ts +20 -0
  47. package/dist/vm/types/record.d.ts.map +1 -0
  48. package/dist/vm/types/value.d.ts +14 -0
  49. package/dist/vm/types/value.d.ts.map +1 -0
  50. package/dist/vm/types/wrapper.d.ts +1 -1
  51. package/dist/vm/types/wrapper.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/src/compiler/compile-fast.ts +1 -1
  54. package/src/compiler/emit.ts +131 -17
  55. package/src/helpers/serialize.ts +34 -14
  56. package/src/subtle.ts +1 -1
  57. package/src/vm/operations.ts +5 -5
  58. package/src/vm/types/any.ts +33 -0
  59. package/src/vm/types/array.ts +19 -0
  60. package/src/vm/types/callable.ts +10 -0
  61. package/src/vm/types/{checker.ts → const.ts} +7 -55
  62. package/src/vm/types/context.ts +5 -1
  63. package/src/vm/types/extern.ts +19 -5
  64. package/src/vm/types/immutable.ts +22 -0
  65. package/src/vm/types/index.ts +31 -83
  66. package/src/vm/types/primitive.ts +14 -0
  67. package/src/vm/types/record.ts +53 -0
  68. package/src/vm/types/value.ts +22 -0
  69. package/src/vm/types/wrapper.ts +1 -1
  70. package/dist/chunk-AGIXQM52.js +0 -916
  71. package/dist/chunk-AGIXQM52.js.map +0 -6
  72. package/dist/chunk-IKSSUVRE.js.map +0 -6
  73. package/dist/vm/types/checker.d.ts +0 -30
  74. package/dist/vm/types/checker.d.ts.map +0 -1
@@ -0,0 +1,33 @@
1
+ import { isVmConst } from './const.js';
2
+ import { isVmFunction } from './function.js';
3
+ import { isVmWrapper } from './wrapper.js';
4
+ import type { VmValue } from './value.js';
5
+
6
+ /** Mirascript 虚拟机内的值(包括未初始化变量) */
7
+ export type VmAny = VmValue | VmUninitialized;
8
+
9
+ /** Mirascript 虚拟机内的未初始化变量 */
10
+ export type VmUninitialized = undefined;
11
+
12
+ /**
13
+ * 检查是否为 Mirascript 值
14
+ */
15
+ export function isVmAny(value: unknown, checkDeep: boolean): value is VmAny {
16
+ switch (typeof value) {
17
+ case 'string':
18
+ case 'number':
19
+ case 'boolean':
20
+ case 'undefined':
21
+ return true;
22
+ case 'object':
23
+ if (value == null) return true;
24
+ if (isVmWrapper(value)) return true;
25
+ return isVmConst(value, checkDeep);
26
+ case 'function':
27
+ return isVmFunction(value);
28
+ case 'bigint':
29
+ case 'symbol':
30
+ default:
31
+ return false; // Other types are not valid
32
+ }
33
+ }
@@ -0,0 +1,19 @@
1
+ import { isArray } from '../../helpers/utils.js';
2
+ import type { VmAny, VmConst } from './index.js';
3
+
4
+ /**
5
+ * Mirascript 数组
6
+ * 数组中的 `undefined`、`null` 及 <empty slot> 均视作 `nil`
7
+ */
8
+ export type VmArray = ReadonlyArray<VmConst | undefined>;
9
+
10
+ export const VM_ARRAY_MAX_LENGTH = 2 ** 31 - 1;
11
+
12
+ /**
13
+ * 检查值是否为 Mirascript 数组
14
+ */
15
+ export function isVmArray(value: VmAny): value is VmArray {
16
+ if (!isArray(value)) return false;
17
+ value as VmArray satisfies VmArray;
18
+ return true;
19
+ }
@@ -0,0 +1,10 @@
1
+ import { isVmExtern, type VmExtern } from './extern.js';
2
+ import { isVmFunction, type VmFunction, type VmFunctionLike } from './function.js';
3
+
4
+ /** 检查值是否为 Mirascript 可调用值 */
5
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
6
+ export function isVmCallable<E extends Function, F extends VmFunctionLike>(
7
+ value: unknown,
8
+ ): value is VmFunction<F> | VmExtern<E> {
9
+ return isVmFunction<F>(value) || (isVmExtern<E>(value) && typeof value.value == 'function');
10
+ }
@@ -1,8 +1,12 @@
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';
1
5
  import { getPrototypeOf, isArray, values } from '../../helpers/utils.js';
2
- import type { VmAny, VmArray, VmConst, VmImmutable, VmRecord, VmValue } from './index.js';
3
6
  import { isVmWrapper } from './wrapper.js';
4
- import { isVmModule } from './module.js';
5
- import { isVmFunction } from './function.js';
7
+
8
+ /** Mirascript 虚拟机内的值语义值 */
9
+ export type VmConst = VmPrimitive | VmRecord | VmArray;
6
10
 
7
11
  const MAX_DEPTH = 32;
8
12
  /**
@@ -103,55 +107,3 @@ export function isVmConst(value: unknown, checkDeep = false): value is VmConst {
103
107
  return false; // Other types are not valid
104
108
  }
105
109
  }
106
- /**
107
- * 检查是否为 Mirascript 不可变值
108
- */
109
- export function isVmImmutable(value: VmAny): value is VmImmutable;
110
- /**
111
- * 检查是否为 Mirascript 不可变值
112
- */
113
- export function isVmImmutable(value: unknown, checkDeep: boolean): value is VmImmutable;
114
- /**
115
- * 检查是否为 Mirascript 不可变值
116
- */
117
- export function isVmImmutable(value: unknown, checkDeep = false): value is VmImmutable {
118
- return isVmModule(value) || isVmFunction(value) || isVmConst(value, checkDeep);
119
- }
120
- /**
121
- * 检查是否为 Mirascript 合法值
122
- */
123
- export function isVmValue(value: VmAny): value is VmValue;
124
- /**
125
- * 检查是否为 Mirascript 合法值
126
- */
127
- export function isVmValue(value: unknown, checkDeep: boolean): value is VmValue;
128
- /**
129
- * 检查是否为 Mirascript 合法值
130
- */
131
- export function isVmValue(value: unknown, checkDeep = false): value is VmValue {
132
- if (value === undefined) return false;
133
- return isVmAny(value, checkDeep);
134
- }
135
-
136
- /**
137
- * 检查是否为 Mirascript 值
138
- */
139
- export function isVmAny(value: unknown, checkDeep: boolean): value is VmAny {
140
- switch (typeof value) {
141
- case 'string':
142
- case 'number':
143
- case 'boolean':
144
- case 'undefined':
145
- return true;
146
- case 'object':
147
- if (value == null) return true;
148
- if (isVmWrapper(value)) return true;
149
- return isVmConst(value, checkDeep);
150
- case 'function':
151
- return isVmFunction(value);
152
- case 'bigint':
153
- case 'symbol':
154
- default:
155
- return false; // Other types are not valid
156
- }
157
- }
@@ -40,6 +40,8 @@ export interface VmContext {
40
40
  export type VmContextRecord = Record<string, VmValue | undefined>;
41
41
  export const VmSharedContext = create(null) as VmSharedContext;
42
42
 
43
+ let VmSharedContextKeys: readonly string[] | null = null;
44
+
43
45
  /** 定义在所有 MiraScript 执行上下文中共享的全局变量 */
44
46
  export function defineVmContextValue(
45
47
  name: string,
@@ -57,6 +59,7 @@ export function defineVmContextValue(
57
59
  v = value;
58
60
  }
59
61
  VmSharedContext[name] = v ?? null;
62
+ VmSharedContextKeys = null;
60
63
  }
61
64
 
62
65
  /** 无后备的实现 */
@@ -64,7 +67,8 @@ export const DefaultVmContext: VmContext = Object.freeze({
64
67
  [kVmContext]: true as const,
65
68
  /** @inheritdoc */
66
69
  keys(): Iterable<string> {
67
- return keys(VmSharedContext);
70
+ VmSharedContextKeys ??= Object.freeze(keys(VmSharedContext));
71
+ return VmSharedContextKeys;
68
72
  },
69
73
  /** @inheritdoc */
70
74
  get(key: string): VmValue {
@@ -1,14 +1,17 @@
1
1
  import { VmError } from '../error.js';
2
2
  import { VmWrapper } from './wrapper.js';
3
3
  import type { TypeName, VmAny, VmConst, VmPrimitive, VmValue } from './index.js';
4
- import { getPrototypeOf, hasOwn, apply } from '../../helpers/utils.js';
4
+ import { getPrototypeOf, hasOwn, apply, isArray } from '../../helpers/utils.js';
5
5
  import { unwrapFromVmValue, wrapToVmValue } from './boundary.js';
6
+ import { $InnerToString } from '../operations.js';
6
7
 
7
8
  const ObjectPrototype = Object.prototype;
8
9
  // eslint-disable-next-line @typescript-eslint/unbound-method
9
10
  const ObjectToString = ObjectPrototype.toString;
10
11
  // eslint-disable-next-line @typescript-eslint/unbound-method
11
12
  const FunctionToString = Function.prototype.toString;
13
+ const ArrayToString = Array.prototype.toString;
14
+ const ArrayMap = Array.prototype.map;
12
15
  /** 包装 Mirascript `extern` 类型的对象 */
13
16
  export class VmExtern<const T extends object = object> extends VmWrapper<T> {
14
17
  constructor(
@@ -88,16 +91,25 @@ export class VmExtern<const T extends object = object> extends VmWrapper<T> {
88
91
  return this.value === other.value && this.thisArg === other.thisArg;
89
92
  }
90
93
  /** @inheritdoc */
91
- override toString(): string {
94
+ override toString(useBraces: boolean): string {
92
95
  // eslint-disable-next-line @typescript-eslint/unbound-method
93
96
  const { toString } = this.value;
94
97
  if (typeof toString != 'function' || toString === ObjectToString || toString === FunctionToString) {
95
- return super.toString();
98
+ return super.toString(useBraces);
99
+ }
100
+ if (toString === ArrayToString && isArray(this.value)) {
101
+ const mapped = ArrayMap.call(this.value, (item: unknown) => {
102
+ if (item === undefined) return '';
103
+ return $InnerToString(wrapToVmValue(item ?? null, null), true);
104
+ });
105
+ const str = mapped.join(', ');
106
+ if (useBraces) return `[${str}]`;
107
+ return str;
96
108
  }
97
109
  try {
98
110
  return String(this.value);
99
111
  } catch {
100
- return super.toString();
112
+ return super.toString(useBraces);
101
113
  }
102
114
  }
103
115
  /** @inheritdoc */
@@ -107,7 +119,9 @@ export class VmExtern<const T extends object = object> extends VmWrapper<T> {
107
119
  /** @inheritdoc */
108
120
  override get describe(): string {
109
121
  const tag = ObjectToString.call(this.value).slice(8, -1);
110
- if (tag === 'Object') {
122
+ if (isArray(this.value)) {
123
+ return `${tag}(${this.value.length})`;
124
+ } else if (tag === 'Object') {
111
125
  const proto = getPrototypeOf(this.value);
112
126
  if (proto === ObjectPrototype) {
113
127
  return 'Object';
@@ -0,0 +1,22 @@
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,39 +1,8 @@
1
- import { isArray } from '../../helpers/utils.js';
2
- import { isVmExtern, VmExtern } from './extern.js';
3
- import { isVmFunction, VmFunction } from './function.js';
4
- import { VmModule, isVmModule } from './module.js';
5
- import { isVmWrapper } from './wrapper.js';
6
-
7
- /** Mirascript 原始值 */
8
- export type VmPrimitive = null | string | number | boolean;
9
- /**
10
- * Mirascript 记录
11
- * 仅拥有且可枚举的字符串键视作存在
12
- * 字段值 `undefined` 和 `null` 均视作 `nil`
13
- */
14
- export type VmRecord = {
15
- readonly [key: string]: VmConst | undefined;
16
- };
17
- /**
18
- * Mirascript 数组
19
- * 数组中的 `undefined`、`null` 及 <empty slot> 均视作 `nil`
20
- */
21
- export type VmArray = ReadonlyArray<VmConst | undefined>;
22
-
23
- /** Mirascript 虚拟机内的值语义值 */
24
- export type VmConst = VmPrimitive | VmRecord | VmArray;
25
-
26
- /** Mirascript 虚拟机内的不可变值 */
27
- export type VmImmutable = VmConst | VmFunction | VmModule;
28
-
29
- /** Mirascript 虚拟机内的合法值 */
30
- export type VmValue = VmImmutable | VmExtern;
31
-
32
- /** Mirascript 虚拟机内的未初始化变量 */
33
- export type VmUninitialized = undefined;
34
-
35
- /** Mirascript 虚拟机内的值(包括未初始化变量) */
36
- export type VmAny = VmValue | VmUninitialized;
1
+ import type { VmArray } from './array.js';
2
+ import type { VmExtern } from './extern.js';
3
+ import type { VmFunction } from './function.js';
4
+ import type { VmModule } from './module.js';
5
+ import type { VmRecord } from './record.js';
37
6
 
38
7
  /** 类型名称 */
39
8
  export type TypeName = keyof VmValueMap;
@@ -60,53 +29,32 @@ export interface VmValueMap {
60
29
  module: VmModule;
61
30
  }
62
31
 
63
- /**
64
- * 检查值是否为 Mirascript 数组
65
- */
66
- export function isVmArray(value: VmAny): value is VmArray {
67
- if (!isArray(value)) return false;
68
- value as VmArray satisfies VmArray;
69
- return true;
70
- }
71
-
72
- /**
73
- * 检查值是否为 Mirascript 记录
74
- */
75
- export function isVmRecord(value: VmAny): value is VmRecord {
76
- if (value == null || typeof value !== 'object') return false;
77
- if (isVmWrapper(value)) return false;
78
- if (isVmArray(value)) return false;
79
- value satisfies VmRecord;
80
- return true;
81
- }
82
-
83
- /**
84
- * 检查值是否为 Mirascript 原始值
85
- */
86
- export function isVmPrimitive(value: unknown): value is VmPrimitive {
87
- if (value === null || typeof value == 'number' || typeof value == 'string' || typeof value == 'boolean') {
88
- value as VmPrimitive satisfies typeof value;
89
- value satisfies VmPrimitive;
90
- return true;
91
- }
92
- return false;
93
- }
94
-
95
- export { VmFunction, isVmFunction, VmExtern, isVmExtern, VmModule, isVmModule, isVmWrapper };
96
32
  export { wrapToVmValue, unwrapFromVmValue, toVmFunctionProxy, fromVmFunctionProxy } from './boundary.js';
97
-
98
- /** 检查值是否为 Mirascript 可调用值 */
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
100
- export function isVmCallable(value: unknown): value is VmFunction | VmExtern<Function> {
101
- return isVmFunction(value) || (isVmExtern(value) && typeof value.value == 'function');
102
- }
103
-
104
- export { getVmFunctionInfo, type VmFunctionInfo, type VmFunctionLike, type VmFunctionOption } from './function.js';
105
-
106
33
  export { type VmContext, type VmSharedContext, isVmContext, defineVmContextValue, createVmContext } from './context.js';
107
-
108
34
  export { type VmScript, isVmScript } from './script.js';
109
-
110
- export { isVmAny, isVmConst, isVmImmutable, isVmValue } from './checker.js';
111
-
112
- export const VM_ARRAY_MAX_LENGTH = 2 ** 31 - 1;
35
+ export { isVmCallable } from './callable.js';
36
+
37
+ export { type VmArray, VM_ARRAY_MAX_LENGTH, isVmArray } from './array.js';
38
+ export {
39
+ type VmRecord,
40
+ isVmRecord,
41
+ isVmArrayLikeRecord,
42
+ isVmArrayLikeRecordByEntires,
43
+ isVmArrayLikeRecordByKeys,
44
+ } from './record.js';
45
+ export { type VmPrimitive, isVmPrimitive } from './primitive.js';
46
+ export { type VmConst, isVmConst } from './const.js';
47
+ export { type VmImmutable, isVmImmutable } from './immutable.js';
48
+ export { VmExtern, isVmExtern } from './extern.js';
49
+ export {
50
+ VmFunction,
51
+ isVmFunction,
52
+ getVmFunctionInfo,
53
+ type VmFunctionInfo,
54
+ type VmFunctionLike,
55
+ type VmFunctionOption,
56
+ } from './function.js';
57
+ export { VmModule, isVmModule } from './module.js';
58
+ export { isVmWrapper } from './wrapper.js';
59
+ export { type VmValue, isVmValue } from './value.js';
60
+ export { type VmAny, type VmUninitialized, isVmAny } from './any.js';
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,53 @@
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
+ }
@@ -0,0 +1,22 @@
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
+ }
@@ -22,7 +22,7 @@ export abstract class VmWrapper<T extends object> {
22
22
  return undefined;
23
23
  }
24
24
  /** 转为字符串 */
25
- toString(): string {
25
+ toString(useBraces: boolean): string {
26
26
  const { type, describe } = this;
27
27
  if (!describe) return `<${type}>`;
28
28
  return `<${type} ${describe}>`;