@opencode/codemode 0.0.0-dev-892 → 0.0.0-dev-900
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/README.md +3 -0
- package/dist/codemode.d.ts +2 -0
- package/dist/codemode.js +10 -4
- package/dist/vm/async.d.ts +78 -0
- package/dist/vm/async.js +335 -0
- package/dist/vm/code.d.ts +122 -0
- package/dist/vm/code.js +407 -0
- package/dist/vm/compiler/compile.d.ts +13 -0
- package/dist/vm/compiler/compile.js +1477 -0
- package/dist/vm/compiler/scope.d.ts +74 -0
- package/dist/vm/compiler/scope.js +515 -0
- package/dist/vm/data.d.ts +7 -0
- package/dist/vm/data.js +13 -0
- package/dist/vm/generators.d.ts +42 -0
- package/dist/vm/generators.js +413 -0
- package/dist/vm/host.d.ts +103 -0
- package/dist/vm/host.js +226 -0
- package/dist/vm/index.d.ts +3 -0
- package/dist/vm/index.js +3 -0
- package/dist/vm/internal-prelude.d.ts +45 -0
- package/dist/vm/internal-prelude.js +534 -0
- package/dist/vm/opcodes.d.ts +222 -0
- package/dist/vm/opcodes.js +235 -0
- package/dist/vm/prelude/bytecode.d.ts +18 -0
- package/dist/vm/prelude/bytecode.js +31 -0
- package/dist/vm/prelude/bytecode.json +1 -0
- package/dist/vm/prelude/helpers.d.ts +8 -0
- package/dist/vm/prelude/helpers.js +258 -0
- package/dist/vm/prelude/prelude.d.ts +21 -0
- package/dist/vm/prelude/prelude.js +53 -0
- package/dist/vm/prelude/source.d.ts +1 -0
- package/dist/vm/prelude/source.js +652 -0
- package/dist/vm/runtime/callback.d.ts +25 -0
- package/dist/vm/runtime/callback.js +51 -0
- package/dist/vm/runtime/driver.d.ts +41 -0
- package/dist/vm/runtime/driver.js +142 -0
- package/dist/vm/runtime/errors.d.ts +23 -0
- package/dist/vm/runtime/errors.js +169 -0
- package/dist/vm/runtime/execute.d.ts +22 -0
- package/dist/vm/runtime/execute.js +278 -0
- package/dist/vm/runtime/extensions.d.ts +16 -0
- package/dist/vm/runtime/extensions.js +270 -0
- package/dist/vm/runtime/generators.d.ts +6 -0
- package/dist/vm/runtime/generators.js +44 -0
- package/dist/vm/runtime/globals.d.ts +6 -0
- package/dist/vm/runtime/globals.js +137 -0
- package/dist/vm/runtime/interpreter.d.ts +50 -0
- package/dist/vm/runtime/interpreter.js +94 -0
- package/dist/vm/runtime/intrinsic-names.d.ts +56 -0
- package/dist/vm/runtime/intrinsic-names.js +166 -0
- package/dist/vm/runtime/intrinsics.d.ts +15 -0
- package/dist/vm/runtime/intrinsics.js +111 -0
- package/dist/vm/runtime/limits.d.ts +10 -0
- package/dist/vm/runtime/limits.js +19 -0
- package/dist/vm/runtime/model.d.ts +58 -0
- package/dist/vm/runtime/model.js +57 -0
- package/dist/vm/runtime/modules.d.ts +4 -0
- package/dist/vm/runtime/modules.js +33 -0
- package/dist/vm/runtime/native.d.ts +19 -0
- package/dist/vm/runtime/native.js +41 -0
- package/dist/vm/runtime/objects.d.ts +403 -0
- package/dist/vm/runtime/objects.js +784 -0
- package/dist/vm/runtime/operations.d.ts +49 -0
- package/dist/vm/runtime/operations.js +288 -0
- package/dist/vm/runtime/promises.d.ts +55 -0
- package/dist/vm/runtime/promises.js +232 -0
- package/dist/vm/runtime/references.d.ts +8 -0
- package/dist/vm/runtime/references.js +51 -0
- package/dist/vm/runtime/signals.d.ts +69 -0
- package/dist/vm/runtime/signals.js +68 -0
- package/dist/vm/runtime/source.d.ts +29 -0
- package/dist/vm/runtime/source.js +63 -0
- package/dist/vm/runtime/table.d.ts +43 -0
- package/dist/vm/runtime/table.js +132 -0
- package/dist/vm/scheduler.d.ts +178 -0
- package/dist/vm/scheduler.js +63 -0
- package/dist/vm/snapshot/codec.d.ts +88 -0
- package/dist/vm/snapshot/codec.js +752 -0
- package/dist/vm/snapshot/snapshot.d.ts +39 -0
- package/dist/vm/snapshot/snapshot.js +69 -0
- package/dist/vm/snapshot.d.ts +29 -0
- package/dist/vm/snapshot.js +304 -0
- package/dist/vm/stdlib/array.d.ts +16 -0
- package/dist/vm/stdlib/array.js +311 -0
- package/dist/vm/stdlib/bytes.d.ts +11 -0
- package/dist/vm/stdlib/bytes.js +222 -0
- package/dist/vm/stdlib/collections.d.ts +7 -0
- package/dist/vm/stdlib/collections.js +188 -0
- package/dist/vm/stdlib/console.d.ts +6 -0
- package/dist/vm/stdlib/console.js +93 -0
- package/dist/vm/stdlib/date.d.ts +2 -0
- package/dist/vm/stdlib/date.js +123 -0
- package/dist/vm/stdlib/headers.d.ts +2 -0
- package/dist/vm/stdlib/headers.js +92 -0
- package/dist/vm/stdlib/iterator.d.ts +2 -0
- package/dist/vm/stdlib/iterator.js +30 -0
- package/dist/vm/stdlib/json.d.ts +3 -0
- package/dist/vm/stdlib/json.js +42 -0
- package/dist/vm/stdlib/math.d.ts +3 -0
- package/dist/vm/stdlib/math.js +73 -0
- package/dist/vm/stdlib/number.d.ts +3 -0
- package/dist/vm/stdlib/number.js +72 -0
- package/dist/vm/stdlib/object.d.ts +6 -0
- package/dist/vm/stdlib/object.js +201 -0
- package/dist/vm/stdlib/regexp.d.ts +8 -0
- package/dist/vm/stdlib/regexp.js +119 -0
- package/dist/vm/stdlib/string.d.ts +2 -0
- package/dist/vm/stdlib/string.js +272 -0
- package/dist/vm/stdlib/url.d.ts +25 -0
- package/dist/vm/stdlib/url.js +255 -0
- package/dist/vm/stdlib/value.d.ts +6 -0
- package/dist/vm/stdlib/value.js +32 -0
- package/dist/vm/stdlib/web.d.ts +5 -0
- package/dist/vm/stdlib/web.js +97 -0
- package/dist/vm/vm.d.ts +224 -0
- package/dist/vm/vm.js +2921 -0
- package/package.json +5 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Expression, MemberExpression, NewExpression, Super } from "acorn";
|
|
2
|
+
import { ToolReference } from "../../tool-runtime.js";
|
|
3
|
+
import { type AstNode } from "./model.js";
|
|
4
|
+
import { type Builtins } from "./intrinsics.js";
|
|
5
|
+
import { type Cursor, Obj, type Value } from "./objects.js";
|
|
6
|
+
import type { Interpreter } from "./interpreter.js";
|
|
7
|
+
/** ToPropertyKey on a primitive (or an opaque value, which keeps its built-in string form). */
|
|
8
|
+
export declare const propertyKey: (value: Value) => PropertyKey;
|
|
9
|
+
/** The TypeError for calling a value that is not a function. */
|
|
10
|
+
export declare const notAFunction: (callee: Expression | Super | undefined, node: AstNode | undefined) => import("./model.js").PendingThrow;
|
|
11
|
+
/** The TypeError for `new` on a callee that cannot be constructed. */
|
|
12
|
+
export declare const notConstructible: (callee: Value, node: NewExpression) => import("./model.js").PendingThrow;
|
|
13
|
+
export declare const instanceofValue: (lhs: Value, rhs: Value, node: AstNode) => boolean;
|
|
14
|
+
export declare const applyBinaryOperator: (operator: string, lhs: Value, rhs: Value, node: AstNode) => Value;
|
|
15
|
+
/**
|
|
16
|
+
* How an operator with an object operand converts: `in` with a data object on the left asks ToPropertyKey of it,
|
|
17
|
+
* a converting operator asks ToPrimitive of both operands with `hint`, and anything else needs no conversion.
|
|
18
|
+
*/
|
|
19
|
+
export declare const operatorConversion: (operator: string, lhs: Value, rhs: Value) => {
|
|
20
|
+
readonly kind: "key";
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "primitive";
|
|
23
|
+
readonly hint: "default" | "number";
|
|
24
|
+
} | undefined;
|
|
25
|
+
export type { CustomIterator } from "./objects.js";
|
|
26
|
+
/** A resolved member: the object to read through and the receiver that inherited accessors see. */
|
|
27
|
+
type MemberReference = {
|
|
28
|
+
target: Obj;
|
|
29
|
+
key: PropertyKey;
|
|
30
|
+
receiver: Value;
|
|
31
|
+
};
|
|
32
|
+
export declare const isThenable: (value: Value) => boolean;
|
|
33
|
+
/** A built-in iterator over `value` that needs no program code to start: an iterator object, a string, a collection. */
|
|
34
|
+
export declare const builtinCursor: (builtins: Builtins, value: Value) => Cursor | undefined;
|
|
35
|
+
export declare const requireIteratorObject: (value: Value, context: string, node?: AstNode) => Obj;
|
|
36
|
+
export declare const requireIteratorMethod: (value: Value, context: string, node?: AstNode) => Value;
|
|
37
|
+
export declare const forInKeys: <R>(ctx: Interpreter<R>, value: Value, node: AstNode) => Array<string>;
|
|
38
|
+
export declare const requireMemberBase: (node: MemberExpression, objectValue: Value, keyValue: Value) => void;
|
|
39
|
+
export declare const resolveProperty: (builtins: Builtins, objectValue: Value, key: PropertyKey, objectNode: AstNode, propertyNode: AstNode) => MemberReference | ToolReference | {
|
|
40
|
+
value: Value;
|
|
41
|
+
};
|
|
42
|
+
export declare const destructuredProperty: (builtins: Builtins, source: Value, key: PropertyKey, node: AstNode) => Value;
|
|
43
|
+
export declare const readReference: (reference: MemberReference, node: MemberExpression) => Value;
|
|
44
|
+
export declare const readProperty: (target: Obj, key: PropertyKey, node: AstNode | undefined, receiver?: Value) => Value;
|
|
45
|
+
/** The reference an assignment or update writes through: only a data field of an object. */
|
|
46
|
+
export declare const writableReference: (reference: MemberReference | ToolReference | {
|
|
47
|
+
value: Value;
|
|
48
|
+
} | symbol, node: MemberExpression) => MemberReference;
|
|
49
|
+
export declare const assignToReference: (target: Obj, key: PropertyKey, next: Value, node: AstNode) => void;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { ToolReference } from "../../tool-runtime.js";
|
|
2
|
+
import { invalidData, typeError } from "./model.js";
|
|
3
|
+
import { checkStringLength } from "./limits.js";
|
|
4
|
+
import { locate } from "./errors.js";
|
|
5
|
+
import { primitivePrototype } from "./intrinsics.js";
|
|
6
|
+
import { Arr, Builtin, Callable, Fn, get, has, hasOwn, hasPrototype, IteratorObj, keys, Obj, parseArrayIndex, Position, PromiseObj, set, coerceToString, } from "./objects.js";
|
|
7
|
+
import { isOpaque, rejectCircularInsertion, typeofValue } from "./references.js";
|
|
8
|
+
import { enumerableSource } from "../stdlib/object.js";
|
|
9
|
+
// The synchronous semantics the VM's ops share: operators, property references, and the checks around them. Nothing
|
|
10
|
+
// here runs program code.
|
|
11
|
+
/** The binary operators that convert object operands through ToPrimitive before acting on primitives. */
|
|
12
|
+
const primitiveOperators = new Set([
|
|
13
|
+
"+",
|
|
14
|
+
"-",
|
|
15
|
+
"*",
|
|
16
|
+
"/",
|
|
17
|
+
"%",
|
|
18
|
+
"**",
|
|
19
|
+
"<",
|
|
20
|
+
"<=",
|
|
21
|
+
">",
|
|
22
|
+
">=",
|
|
23
|
+
"&",
|
|
24
|
+
"|",
|
|
25
|
+
"^",
|
|
26
|
+
"<<",
|
|
27
|
+
">>",
|
|
28
|
+
">>>",
|
|
29
|
+
]);
|
|
30
|
+
/** ToPropertyKey on a primitive (or an opaque value, which keeps its built-in string form). */
|
|
31
|
+
export const propertyKey = (value) => typeof value === "string" || typeof value === "number" || typeof value === "symbol" ? value : coerceToString(value);
|
|
32
|
+
// Native engines name the callee (`search(...).catch is not a function`), including call chains. Returns
|
|
33
|
+
// undefined when a link cannot be named, so a chain is either named completely or not at all.
|
|
34
|
+
const calleeDescription = (node) => {
|
|
35
|
+
if (node?.type === "Identifier")
|
|
36
|
+
return node.name;
|
|
37
|
+
if (node?.type === "CallExpression") {
|
|
38
|
+
const target = calleeDescription(node.callee);
|
|
39
|
+
return target === undefined ? undefined : `${target}(...)`;
|
|
40
|
+
}
|
|
41
|
+
if (node?.type !== "MemberExpression")
|
|
42
|
+
return undefined;
|
|
43
|
+
const property = node.property;
|
|
44
|
+
const key = !node.computed && property.type === "Identifier"
|
|
45
|
+
? property.name
|
|
46
|
+
: property.type === "Literal" && typeof property.value === "string"
|
|
47
|
+
? property.value
|
|
48
|
+
: undefined;
|
|
49
|
+
if (key === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
const object = calleeDescription(node.object);
|
|
52
|
+
return object === undefined ? undefined : `${object}.${key}`;
|
|
53
|
+
};
|
|
54
|
+
/** The TypeError for calling a value that is not a function. */
|
|
55
|
+
export const notAFunction = (callee, node) => typeError(`${calleeDescription(callee) ?? "The called value"} is not a function.`, callee ?? node);
|
|
56
|
+
/** The TypeError for `new` on a callee that cannot be constructed. */
|
|
57
|
+
export const notConstructible = (callee, node) => {
|
|
58
|
+
// `new` itself is supported, so a non-constructible callee is a TypeError like JS rather than
|
|
59
|
+
// unsupported syntax. Built-ins like Number are real constructors in JS, so do not claim
|
|
60
|
+
// otherwise; say `new` is unsupported for them and point at the plain call.
|
|
61
|
+
const name = calleeDescription(node.callee) ?? "The called value";
|
|
62
|
+
const message = callee instanceof Fn
|
|
63
|
+
? `${name} cannot be constructed: user-defined constructors and classes are not supported. Call it as a function that returns a plain object instead.`
|
|
64
|
+
: callee instanceof Builtin
|
|
65
|
+
? `new ${name}(...) is not supported; call ${name}(...) without new instead.`
|
|
66
|
+
: `${name} is not a constructor.`;
|
|
67
|
+
return typeError(message, node);
|
|
68
|
+
};
|
|
69
|
+
// OrdinaryHasInstance: walk the left operand's chain looking for the constructor's `prototype`.
|
|
70
|
+
export const instanceofValue = (lhs, rhs, node) => {
|
|
71
|
+
if (!(rhs instanceof Callable)) {
|
|
72
|
+
throw typeError("The right-hand side of 'instanceof' is not callable.", node);
|
|
73
|
+
}
|
|
74
|
+
const prototype = get(rhs, "prototype");
|
|
75
|
+
if (!(prototype instanceof Obj)) {
|
|
76
|
+
throw typeError("The right-hand side of 'instanceof' has no 'prototype' object.", node);
|
|
77
|
+
}
|
|
78
|
+
return hasPrototype(lhs, prototype);
|
|
79
|
+
};
|
|
80
|
+
export const applyBinaryOperator = (operator, lhs, rhs, node) => {
|
|
81
|
+
if (operator === "===")
|
|
82
|
+
return lhs === rhs;
|
|
83
|
+
if (operator === "!==")
|
|
84
|
+
return lhs !== rhs;
|
|
85
|
+
if (operator === "==")
|
|
86
|
+
return looselyEqual(lhs, rhs, node);
|
|
87
|
+
if (operator === "!=")
|
|
88
|
+
return !looselyEqual(lhs, rhs, node);
|
|
89
|
+
if (operator === "in" && rhs instanceof Obj && !isOpaque(lhs))
|
|
90
|
+
return has(rhs, propertyKey(lhs));
|
|
91
|
+
if (isOpaque(lhs) || isOpaque(rhs)) {
|
|
92
|
+
throw invalidData("Binary operators require data values.", node);
|
|
93
|
+
}
|
|
94
|
+
// Object operands were already converted through ToPrimitive; only primitives reach the arithmetic below.
|
|
95
|
+
switch (operator) {
|
|
96
|
+
case "+": {
|
|
97
|
+
const sum = lhs + rhs;
|
|
98
|
+
if (typeof sum === "string")
|
|
99
|
+
checkStringLength(sum.length);
|
|
100
|
+
return sum;
|
|
101
|
+
}
|
|
102
|
+
case "-":
|
|
103
|
+
return lhs - rhs;
|
|
104
|
+
case "*":
|
|
105
|
+
return lhs * rhs;
|
|
106
|
+
case "/":
|
|
107
|
+
return lhs / rhs;
|
|
108
|
+
case "%":
|
|
109
|
+
return lhs % rhs;
|
|
110
|
+
case "**":
|
|
111
|
+
return lhs ** rhs;
|
|
112
|
+
case "<":
|
|
113
|
+
return lhs < rhs;
|
|
114
|
+
case "<=":
|
|
115
|
+
return lhs <= rhs;
|
|
116
|
+
case ">":
|
|
117
|
+
return lhs > rhs;
|
|
118
|
+
case ">=":
|
|
119
|
+
return lhs >= rhs;
|
|
120
|
+
case "&":
|
|
121
|
+
return lhs & rhs;
|
|
122
|
+
case "|":
|
|
123
|
+
return lhs | rhs;
|
|
124
|
+
case "^":
|
|
125
|
+
return lhs ^ rhs;
|
|
126
|
+
case "<<":
|
|
127
|
+
return lhs << rhs;
|
|
128
|
+
case ">>":
|
|
129
|
+
return lhs >> rhs;
|
|
130
|
+
case ">>>":
|
|
131
|
+
return lhs >>> rhs;
|
|
132
|
+
case "in":
|
|
133
|
+
throw typeError("The 'in' operator requires a data object on the right-hand side.", node);
|
|
134
|
+
default:
|
|
135
|
+
throw typeError(`Unsupported binary operator '${operator}'.`, node);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
// IsLooselyEqual: objects (including functions and tool references) compare by identity, and a nullish
|
|
139
|
+
// primitive never equals an object.
|
|
140
|
+
const looselyEqual = (lhs, rhs, node) => {
|
|
141
|
+
const lhsObject = lhs !== null && typeof lhs === "object";
|
|
142
|
+
const rhsObject = rhs !== null && typeof rhs === "object";
|
|
143
|
+
if (lhsObject === rhsObject)
|
|
144
|
+
return lhsObject ? lhs === rhs : lhs == rhs;
|
|
145
|
+
const primitive = lhsObject ? rhs : lhs;
|
|
146
|
+
if (primitive === null || primitive === undefined)
|
|
147
|
+
return false;
|
|
148
|
+
// Data objects were converted through ToPrimitive, so only an opaque reference facing a primitive gets here.
|
|
149
|
+
throw invalidData("Binary operators require data values.", node);
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* How an operator with an object operand converts: `in` with a data object on the left asks ToPropertyKey of it,
|
|
153
|
+
* a converting operator asks ToPrimitive of both operands with `hint`, and anything else needs no conversion.
|
|
154
|
+
*/
|
|
155
|
+
export const operatorConversion = (operator, lhs, rhs) => {
|
|
156
|
+
// `in` checks the right operand before ToPropertyKey on the left, so a bad right side wins over a bad key.
|
|
157
|
+
if (operator === "in" && lhs instanceof Obj && !isOpaque(lhs) && rhs instanceof Obj)
|
|
158
|
+
return { kind: "key" };
|
|
159
|
+
// IsLooselyEqual converts only an object facing a non-nullish primitive; two objects (including tool
|
|
160
|
+
// references, which are not Obj) compare by identity.
|
|
161
|
+
const equality = operator === "==" || operator === "!=";
|
|
162
|
+
const other = lhs instanceof Obj ? rhs : lhs;
|
|
163
|
+
const converts = primitiveOperators.has(operator) || (equality && other !== null && other !== undefined && typeof other !== "object");
|
|
164
|
+
if (!converts)
|
|
165
|
+
return undefined;
|
|
166
|
+
return { kind: "primitive", hint: operator === "+" || equality ? "default" : "number" };
|
|
167
|
+
};
|
|
168
|
+
// A thenable the program's implicit async body adopts before copy-out.
|
|
169
|
+
export const isThenable = (value) => value instanceof PromiseObj || (value instanceof Obj && typeofValue(get(value, "then")) === "function");
|
|
170
|
+
/** A built-in iterator over `value` that needs no program code to start: an iterator object, a string, a collection. */
|
|
171
|
+
export const builtinCursor = (builtins, value) => {
|
|
172
|
+
if (value instanceof IteratorObj)
|
|
173
|
+
return value.cursor;
|
|
174
|
+
if (typeof value === "string")
|
|
175
|
+
return new Position(value, "values", builtins.Array);
|
|
176
|
+
return value instanceof Obj ? value.iterator(builtins) : undefined;
|
|
177
|
+
};
|
|
178
|
+
export const requireIteratorObject = (value, context, node) => {
|
|
179
|
+
if (value instanceof Obj)
|
|
180
|
+
return value;
|
|
181
|
+
throw typeError(`${context} must be an object.`, node);
|
|
182
|
+
};
|
|
183
|
+
export const requireIteratorMethod = (value, context, node) => {
|
|
184
|
+
if (typeofValue(value) === "function")
|
|
185
|
+
return value;
|
|
186
|
+
throw typeError(`${context} must be a function.`, node);
|
|
187
|
+
};
|
|
188
|
+
// for...in over null/undefined iterates nothing, like JS. After the own keys come each prototype's enumerable
|
|
189
|
+
// string keys, skipping any key a nearer level has, even as a non-enumerable property.
|
|
190
|
+
export const forInKeys = (ctx, value, node) => {
|
|
191
|
+
if (value instanceof ToolReference)
|
|
192
|
+
return [...ctx.tools.keys(value.path)];
|
|
193
|
+
if (value === null || value === undefined)
|
|
194
|
+
return [];
|
|
195
|
+
const source = enumerableSource(ctx, "for...in", value, node);
|
|
196
|
+
const chain = [source];
|
|
197
|
+
// A string's characters stand in an array, but its prototype is String.prototype.
|
|
198
|
+
let proto = primitivePrototype(ctx.builtins, value) ?? source.proto;
|
|
199
|
+
while (proto !== null) {
|
|
200
|
+
chain.push(proto);
|
|
201
|
+
proto = proto.proto;
|
|
202
|
+
}
|
|
203
|
+
return chain.flatMap((target, depth) => {
|
|
204
|
+
const nearer = chain.slice(0, depth);
|
|
205
|
+
return keys(target).filter((key) => !nearer.some((level) => hasOwn(level, key)));
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
// GetValue applies ToObject to the base before ToPropertyKey, so a nullish base throws before the key's own
|
|
209
|
+
// toString runs.
|
|
210
|
+
export const requireMemberBase = (node, objectValue, keyValue) => {
|
|
211
|
+
if (objectValue === null || objectValue === undefined) {
|
|
212
|
+
throw typeError(`Cannot read properties of ${objectValue} (reading '${coerceToString(keyValue)}').`, node.object);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
export const resolveProperty = (builtins, objectValue, key, objectNode, propertyNode) => {
|
|
216
|
+
if (objectValue instanceof ToolReference) {
|
|
217
|
+
if (typeof key !== "string") {
|
|
218
|
+
throw typeError("Tool paths must use string property names.", propertyNode);
|
|
219
|
+
}
|
|
220
|
+
return new ToolReference([...objectValue.path, key]);
|
|
221
|
+
}
|
|
222
|
+
if (objectValue instanceof Obj)
|
|
223
|
+
return { target: objectValue, key, receiver: objectValue };
|
|
224
|
+
// Strings own length and indexes; every other primitive property reads through the wrapper prototype.
|
|
225
|
+
if (typeof objectValue === "string") {
|
|
226
|
+
if (key === "length")
|
|
227
|
+
return { value: objectValue.length };
|
|
228
|
+
const index = typeof key === "symbol" ? undefined : parseArrayIndex(key);
|
|
229
|
+
if (index !== undefined)
|
|
230
|
+
return { value: objectValue[index] };
|
|
231
|
+
}
|
|
232
|
+
const proto = primitivePrototype(builtins, objectValue);
|
|
233
|
+
if (proto !== undefined)
|
|
234
|
+
return { target: proto, key, receiver: objectValue };
|
|
235
|
+
if (objectValue === null || objectValue === undefined) {
|
|
236
|
+
throw typeError(`Cannot read properties of ${objectValue} (reading '${String(key)}').`, objectNode);
|
|
237
|
+
}
|
|
238
|
+
throw typeError("Cannot access a property on a non-object value.", objectNode);
|
|
239
|
+
};
|
|
240
|
+
// One destructured property, read the way a member expression would read it (primitives use their prototype).
|
|
241
|
+
export const destructuredProperty = (builtins, source, key, node) => {
|
|
242
|
+
const reference = resolveProperty(builtins, source, key, node, node);
|
|
243
|
+
if (reference instanceof ToolReference)
|
|
244
|
+
return reference;
|
|
245
|
+
if ("value" in reference)
|
|
246
|
+
return reference.value;
|
|
247
|
+
return readProperty(reference.target, reference.key, node, reference.receiver);
|
|
248
|
+
};
|
|
249
|
+
export const readReference = (reference, node) => {
|
|
250
|
+
// Reject unknown promise properties so a missing await cannot hide.
|
|
251
|
+
if (reference.target instanceof PromiseObj && !has(reference.target, reference.key)) {
|
|
252
|
+
throw invalidData("This value is an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.", node.object);
|
|
253
|
+
}
|
|
254
|
+
return readProperty(reference.target, reference.key, node, reference.receiver);
|
|
255
|
+
};
|
|
256
|
+
// Accessors throw without a location; the member or pattern that read them supplies it.
|
|
257
|
+
export const readProperty = (target, key, node, receiver = target) => {
|
|
258
|
+
try {
|
|
259
|
+
return get(target, key, receiver);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
throw locate(error, node);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
/** The reference an assignment or update writes through: only a data field of an object. */
|
|
266
|
+
export const writableReference = (reference, node) => {
|
|
267
|
+
if (typeof reference === "symbol" || reference instanceof ToolReference || "value" in reference) {
|
|
268
|
+
throw typeError("Only data fields may be assigned.", node);
|
|
269
|
+
}
|
|
270
|
+
if (reference.receiver !== reference.target) {
|
|
271
|
+
throw typeError(`Cannot create property '${String(reference.key)}' on ${typeof reference.receiver} '${String(reference.receiver)}'.`, node);
|
|
272
|
+
}
|
|
273
|
+
return reference;
|
|
274
|
+
};
|
|
275
|
+
export const assignToReference = (target, key, next, node) => {
|
|
276
|
+
const written = (() => {
|
|
277
|
+
try {
|
|
278
|
+
rejectCircularInsertion(target, next, target instanceof Arr ? "Array assignment result" : "Object assignment result");
|
|
279
|
+
return set(target, key, next);
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
throw locate(error, node);
|
|
283
|
+
}
|
|
284
|
+
})();
|
|
285
|
+
if (written)
|
|
286
|
+
return;
|
|
287
|
+
throw typeError(`Cannot assign to read only property '${String(key)}'.`, node);
|
|
288
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type AstNode } from "./model.js";
|
|
2
|
+
import { Callable, Obj, PromiseObj, type Value } from "./objects.js";
|
|
3
|
+
import type { Interpreter } from "./interpreter.js";
|
|
4
|
+
import { type Completion } from "./signals.js";
|
|
5
|
+
import type { Combination, Reaction, Resolving } from "../scheduler.js";
|
|
6
|
+
/**
|
|
7
|
+
* NewPromiseCapability(%Promise%): a pending promise with what settles it once. A built-in's own failure that rejects
|
|
8
|
+
* it is located at `site`, the call that created it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const capability: <R>(ctx: Interpreter<R>, site: AstNode | undefined) => Resolving;
|
|
11
|
+
/**
|
|
12
|
+
* Runs a settled promise's reaction as a job: it finishes at once, or returns the call into program code the VM makes
|
|
13
|
+
* for it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const react: <R>(ctx: Interpreter<R>, reaction: Exclude<Reaction, {
|
|
16
|
+
readonly kind: "await" | "asyncFromSync";
|
|
17
|
+
}>, settled: Completion) => JobCall | void;
|
|
18
|
+
/**
|
|
19
|
+
* A job that calls program code once, which the VM runs (`VmScheduler.beginJob`), counted toward the depth limit:
|
|
20
|
+
* - `thenable` (PromiseResolveThenableJob): calls the thenable's `then` with the resolving functions; a throw rejects
|
|
21
|
+
* `resolving`.
|
|
22
|
+
* - `handler` (PromiseReactionJob): a `then`/`catch` handler; its result or failure settles `derived`.
|
|
23
|
+
* - `finally` (PromiseFinallyJob): a `finally` cleanup; once its own result settles, the original outcome passes on to
|
|
24
|
+
* `made` (the spec chains `then(valueThunk)` onto the cleanup's promise: one more job), and a failing cleanup wins.
|
|
25
|
+
*/
|
|
26
|
+
export type JobCall = {
|
|
27
|
+
readonly kind: "thenable";
|
|
28
|
+
readonly resolving: Resolving;
|
|
29
|
+
readonly then: Value;
|
|
30
|
+
readonly thenable: Obj;
|
|
31
|
+
readonly functions: Array<Value>;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: "handler";
|
|
34
|
+
readonly derived: Resolving;
|
|
35
|
+
readonly handler: Callable;
|
|
36
|
+
readonly argument: Value;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: "finally";
|
|
39
|
+
readonly made: Resolving;
|
|
40
|
+
readonly cleanup: Callable;
|
|
41
|
+
readonly site: AstNode | undefined;
|
|
42
|
+
readonly outcome: Completion;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* NewPromiseResolveThenableJob: the work that calls the thenable's `then`. Adopting a native promise through the
|
|
46
|
+
* intrinsic `then` takes the same jobs as calling it, and keeps the rejection as thrown so its diagnostic survives.
|
|
47
|
+
*/
|
|
48
|
+
export declare const adoptThenable: <R>(ctx: Interpreter<R>, promise: PromiseObj, thenable: Obj, then: Value) => JobCall | void;
|
|
49
|
+
export declare const finishCombination: <R>(ctx: Interpreter<R>, combination: Combination) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Lets a synchronous object result also be awaited or chained like a Promise. It inherits non-enumerable
|
|
52
|
+
* then/catch/finally that settle with a plain copy, so data views never show them and awaiting does not recurse.
|
|
53
|
+
*/
|
|
54
|
+
export declare const promiseLike: <R>(ctx: Interpreter<R>, value: Value) => Value;
|
|
55
|
+
export declare const promiseGlobal: <R>(ctx: Interpreter<R>) => import("./objects.js").Native;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Throw, typeError } from "./model.js";
|
|
2
|
+
import { Callable, changed, define, hidden, Arr, Fn, Obj, PromiseObj, record, Resolver } from "./objects.js";
|
|
3
|
+
import { constructor, methods, native, receiver, requiresNew } from "./native.js";
|
|
4
|
+
import { createAggregateErrorValue, materialize } from "./errors.js";
|
|
5
|
+
import { describeValue, typeofValue } from "./references.js";
|
|
6
|
+
import { isSupportedCallback } from "./callback.js";
|
|
7
|
+
import { Interruption, Push } from "./signals.js";
|
|
8
|
+
import { finishAwaitReturn } from "../generators.js";
|
|
9
|
+
// A `resolve`/`reject` handed to an executor or thenable: calling it settles the capability.
|
|
10
|
+
const resolvingFunctions = (ctx, resolving) => ({
|
|
11
|
+
resolve: new Resolver(ctx.builtins.Function, "resolve", resolving, "resolve"),
|
|
12
|
+
reject: new Resolver(ctx.builtins.Function, "reject", resolving, "reject"),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* NewPromiseCapability(%Promise%): a pending promise with what settles it once. A built-in's own failure that rejects
|
|
16
|
+
* it is located at `site`, the call that created it.
|
|
17
|
+
*/
|
|
18
|
+
export const capability = (ctx, site) => ctx.vm.scheduler.resolving(ctx.vm.scheduler.newPromise(), site);
|
|
19
|
+
/** Settles `resolving` with a completion: a fulfillment value is resolved, so a thenable is adopted. */
|
|
20
|
+
const settleWith = (resolving, completion) => completion.ok ? resolving.resolve(completion.value) : resolving.reject(completion.error);
|
|
21
|
+
/**
|
|
22
|
+
* Runs a settled promise's reaction as a job: it finishes at once, or returns the call into program code the VM makes
|
|
23
|
+
* for it.
|
|
24
|
+
*/
|
|
25
|
+
export const react = (ctx, reaction, settled) => {
|
|
26
|
+
switch (reaction.kind) {
|
|
27
|
+
case "settle":
|
|
28
|
+
return settleWith(reaction.target, settled);
|
|
29
|
+
case "handler":
|
|
30
|
+
return handle(ctx, reaction, settled);
|
|
31
|
+
case "combinator":
|
|
32
|
+
return combine(ctx, reaction, settled);
|
|
33
|
+
case "finally":
|
|
34
|
+
return cleanUp(ctx, reaction, settled);
|
|
35
|
+
case "finallyCleaned":
|
|
36
|
+
return settled.ok ? reaction.target.resolve(undefined) : reaction.target.reject(settled.error);
|
|
37
|
+
case "finallyOutcome":
|
|
38
|
+
return settleWith(reaction.target, settled.ok ? reaction.outcome : settled);
|
|
39
|
+
case "awaitReturn":
|
|
40
|
+
return finishAwaitReturn(ctx.vm, reaction.generator, settled);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* NewPromiseResolveThenableJob: the work that calls the thenable's `then`. Adopting a native promise through the
|
|
45
|
+
* intrinsic `then` takes the same jobs as calling it, and keeps the rejection as thrown so its diagnostic survives.
|
|
46
|
+
*/
|
|
47
|
+
export const adoptThenable = (ctx, promise, thenable, then) => {
|
|
48
|
+
const vm = ctx.vm;
|
|
49
|
+
const resolving = vm.scheduler.resolving(promise);
|
|
50
|
+
if (then === vm.scheduler.intrinsicThen && thenable instanceof PromiseObj) {
|
|
51
|
+
vm.scheduler.then(thenable, { kind: "settle", target: resolving });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const proto = ctx.builtins.Function;
|
|
55
|
+
const resolve = new Resolver(proto, "", resolving, "resolve");
|
|
56
|
+
const reject = new Resolver(proto, "", resolving, "reject");
|
|
57
|
+
return { kind: "thenable", resolving, then, thenable, functions: [resolve, reject] };
|
|
58
|
+
};
|
|
59
|
+
// A `then`/`catch` reaction calls program code: the handler runs as a job, and its result or failure settles the
|
|
60
|
+
// derived promise. A missing handler passes the outcome through.
|
|
61
|
+
const handle = (ctx, reaction, settled) => {
|
|
62
|
+
const handler = settled.ok ? reaction.onFulfilled : reaction.onRejected;
|
|
63
|
+
const derived = reaction.derived;
|
|
64
|
+
if (handler === undefined || (!settled.ok && settled.error instanceof Interruption)) {
|
|
65
|
+
return settleWith(derived, settled);
|
|
66
|
+
}
|
|
67
|
+
const argument = settled.ok ? settled.value : materialize(ctx, settled.error);
|
|
68
|
+
return { kind: "handler", derived, handler, argument };
|
|
69
|
+
};
|
|
70
|
+
const promiseStatics = ["all", "allSettled", "race", "any", "resolve", "reject", "withResolvers", "try"];
|
|
71
|
+
const invokePromiseMethod = (ctx, name, args, site) => {
|
|
72
|
+
if (name === "resolve")
|
|
73
|
+
return ctx.vm.scheduler.promiseResolve(args[0]);
|
|
74
|
+
if (name === "reject") {
|
|
75
|
+
const made = capability(ctx, site);
|
|
76
|
+
made.reject(new Throw(args[0]));
|
|
77
|
+
return made.promise;
|
|
78
|
+
}
|
|
79
|
+
if (name === "withResolvers") {
|
|
80
|
+
const made = capability(ctx, site);
|
|
81
|
+
const functions = resolvingFunctions(ctx, made);
|
|
82
|
+
return record(ctx.builtins.Object, { promise: made.promise, resolve: functions.resolve, reject: functions.reject });
|
|
83
|
+
}
|
|
84
|
+
if (name === "try") {
|
|
85
|
+
if (typeofValue(args[0]) !== "function") {
|
|
86
|
+
throw typeError(`Promise.try expects a function, received ${describeValue(args[0])}.`);
|
|
87
|
+
}
|
|
88
|
+
return new Push("Promise.try", [capability(ctx, site), args[0], args.slice(1)]);
|
|
89
|
+
}
|
|
90
|
+
return new Push("Promise combinator", [capability(ctx, site), name, args[0]]);
|
|
91
|
+
};
|
|
92
|
+
// Promise.all, allSettled, race, and any: the prelude iterates the input (`$vmCombine`), resolving each element to a
|
|
93
|
+
// promise observed through a reaction, so the result settles in the job where the deciding element's reaction runs,
|
|
94
|
+
// or at once for an empty input. A failure while iterating rejects the result.
|
|
95
|
+
// One member settled. Once the result settles early, the remaining members' reactions can do nothing: they are
|
|
96
|
+
// detached so a member that stays pending for the rest of the program does not keep them.
|
|
97
|
+
const combine = (ctx, reaction, settled) => {
|
|
98
|
+
if (reaction.called)
|
|
99
|
+
return;
|
|
100
|
+
reaction.called = true;
|
|
101
|
+
const combination = reaction.combination;
|
|
102
|
+
const made = combination.made;
|
|
103
|
+
const name = combination.name;
|
|
104
|
+
if (name === "race" || (!settled.ok && settled.error instanceof Interruption)) {
|
|
105
|
+
settleWith(made, settled);
|
|
106
|
+
return detachAll(ctx, combination);
|
|
107
|
+
}
|
|
108
|
+
if (name === "all") {
|
|
109
|
+
if (!settled.ok) {
|
|
110
|
+
made.reject(settled.error);
|
|
111
|
+
return detachAll(ctx, combination);
|
|
112
|
+
}
|
|
113
|
+
combination.values[reaction.index] = settled.value;
|
|
114
|
+
return finishCombination(ctx, combination);
|
|
115
|
+
}
|
|
116
|
+
if (name === "any") {
|
|
117
|
+
if (settled.ok) {
|
|
118
|
+
made.resolve(settled.value);
|
|
119
|
+
return detachAll(ctx, combination);
|
|
120
|
+
}
|
|
121
|
+
combination.reasons[reaction.index] = materialize(ctx, settled.error);
|
|
122
|
+
return finishCombination(ctx, combination);
|
|
123
|
+
}
|
|
124
|
+
combination.values[reaction.index] = settled.ok
|
|
125
|
+
? record(ctx.builtins.Object, { status: "fulfilled", value: settled.value })
|
|
126
|
+
: record(ctx.builtins.Object, { status: "rejected", reason: materialize(ctx, settled.error) });
|
|
127
|
+
finishCombination(ctx, combination);
|
|
128
|
+
};
|
|
129
|
+
const detachAll = (ctx, combination) => {
|
|
130
|
+
for (const [item, reaction] of combination.attached)
|
|
131
|
+
ctx.vm.scheduler.detach(item, reaction);
|
|
132
|
+
};
|
|
133
|
+
export const finishCombination = (ctx, combination) => {
|
|
134
|
+
if (--combination.remaining > 0)
|
|
135
|
+
return;
|
|
136
|
+
if (combination.name === "any") {
|
|
137
|
+
combination.made.reject(new Throw(createAggregateErrorValue(ctx, combination.reasons, "All promises were rejected")));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
combination.made.resolve(new Arr(ctx.builtins.Array, combination.values));
|
|
141
|
+
};
|
|
142
|
+
const instanceMethod = (ctx, name, thisValue, args, site) => {
|
|
143
|
+
const method = `Promise.prototype.${name}`;
|
|
144
|
+
const promise = receiver(PromiseObj, thisValue, method);
|
|
145
|
+
if (name === "finally")
|
|
146
|
+
return chainFinally(ctx, promise, reactionHandler(args[0], method), site);
|
|
147
|
+
const onFulfilled = name === "then" ? reactionHandler(args[0], method) : undefined;
|
|
148
|
+
const onRejected = reactionHandler(name === "then" ? args[1] : args[0], method);
|
|
149
|
+
const made = capability(ctx, site);
|
|
150
|
+
ctx.vm.scheduler.then(promise, { kind: "handler", onFulfilled, onRejected, derived: made });
|
|
151
|
+
return made.promise;
|
|
152
|
+
};
|
|
153
|
+
// Promise.prototype.finally: the cleanup runs as a reaction, then the original outcome passes through once the
|
|
154
|
+
// cleanup's own result settles; a failing cleanup wins.
|
|
155
|
+
const chainFinally = (ctx, source, cleanup, site) => {
|
|
156
|
+
const made = capability(ctx, site);
|
|
157
|
+
ctx.vm.scheduler.then(source, cleanup === undefined ? { kind: "settle", target: made } : { kind: "finally", cleanup, target: made, site });
|
|
158
|
+
return made.promise;
|
|
159
|
+
};
|
|
160
|
+
const cleanUp = (_ctx, reaction, settled) => {
|
|
161
|
+
const made = reaction.target;
|
|
162
|
+
if (!settled.ok && settled.error instanceof Interruption)
|
|
163
|
+
return made.reject(settled.error);
|
|
164
|
+
return { kind: "finally", made, cleanup: reaction.cleanup, site: reaction.site, outcome: settled };
|
|
165
|
+
};
|
|
166
|
+
const reactionHandler = (value, method) => {
|
|
167
|
+
if (isSupportedCallback(value))
|
|
168
|
+
return value;
|
|
169
|
+
if (typeofValue(value) === "function") {
|
|
170
|
+
throw typeError(`${method} cannot use this callable as a handler; wrap it in an arrow function, e.g. (value) => tools.ns.tool(value).`);
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
};
|
|
174
|
+
const constructPromise = (ctx, executor, site) => {
|
|
175
|
+
if (!(executor instanceof Fn)) {
|
|
176
|
+
throw typeError("new Promise(...) expects an executor function (e.g. new Promise((resolve, reject) => { ... })).");
|
|
177
|
+
}
|
|
178
|
+
const made = capability(ctx, site);
|
|
179
|
+
const functions = resolvingFunctions(ctx, made);
|
|
180
|
+
return new Push("Promise executor", [made, executor, [functions.resolve, functions.reject]]);
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Lets a synchronous object result also be awaited or chained like a Promise. It inherits non-enumerable
|
|
184
|
+
* then/catch/finally that settle with a plain copy, so data views never show them and awaiting does not recurse.
|
|
185
|
+
*/
|
|
186
|
+
export const promiseLike = (ctx, value) => {
|
|
187
|
+
if (!(value instanceof Obj) || value.proto !== ctx.builtins.Object)
|
|
188
|
+
return value;
|
|
189
|
+
changed(value);
|
|
190
|
+
value.proto = ctx.builtins.PromiseLike;
|
|
191
|
+
return value;
|
|
192
|
+
};
|
|
193
|
+
const promiseLikeMethods = (ctx) => {
|
|
194
|
+
const settled = (thisValue, name) => {
|
|
195
|
+
const source = receiver(Obj, thisValue, name);
|
|
196
|
+
const copy = new Obj(ctx.builtins.Object);
|
|
197
|
+
for (const [key, slot] of source.props)
|
|
198
|
+
copy.props.set(key, { ...slot });
|
|
199
|
+
return ctx.vm.scheduler.promiseResolve(copy);
|
|
200
|
+
};
|
|
201
|
+
methods(ctx.builtins, ctx.builtins.PromiseLike, ["then", "catch", "finally"].map((name) => [
|
|
202
|
+
name,
|
|
203
|
+
name === "then" ? 2 : 1,
|
|
204
|
+
(thisValue, args, site) => instanceMethod(ctx, name, settled(thisValue, name), args, site),
|
|
205
|
+
]));
|
|
206
|
+
};
|
|
207
|
+
export const promiseGlobal = (ctx) => {
|
|
208
|
+
const builtins = ctx.builtins;
|
|
209
|
+
const proto = builtins.Promise;
|
|
210
|
+
const promise = constructor(builtins, proto, {
|
|
211
|
+
name: "Promise",
|
|
212
|
+
length: 1,
|
|
213
|
+
call: requiresNew("Promise"),
|
|
214
|
+
construct: (args, _, site) => constructPromise(ctx, args[0], site),
|
|
215
|
+
});
|
|
216
|
+
// Combinators are not callbacks: `[p].map(Promise.resolve)` must ask for an arrow function.
|
|
217
|
+
for (const name of promiseStatics) {
|
|
218
|
+
define(promise, name, native(builtins, {
|
|
219
|
+
name,
|
|
220
|
+
length: 1,
|
|
221
|
+
call: (_, args, site) => invokePromiseMethod(ctx, name, args, site),
|
|
222
|
+
callback: false,
|
|
223
|
+
}), hidden);
|
|
224
|
+
}
|
|
225
|
+
methods(builtins, proto, [
|
|
226
|
+
["then", 2, (thisValue, args, site) => instanceMethod(ctx, "then", thisValue, args, site)],
|
|
227
|
+
["catch", 1, (thisValue, args, site) => instanceMethod(ctx, "catch", thisValue, args, site)],
|
|
228
|
+
["finally", 1, (thisValue, args, site) => instanceMethod(ctx, "finally", thisValue, args, site)],
|
|
229
|
+
]);
|
|
230
|
+
promiseLikeMethods(ctx);
|
|
231
|
+
return promise;
|
|
232
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Obj, type Value } from "./objects.js";
|
|
2
|
+
/** Interpreter machinery that is never data, unlike a Date or Map, which cross some boundaries as copies. */
|
|
3
|
+
export declare const isOpaque: (value: Value) => boolean;
|
|
4
|
+
export declare const containsRuntimeReference: (value: Value) => boolean;
|
|
5
|
+
export declare const containsOpaqueReference: (value: Value) => boolean;
|
|
6
|
+
export declare const rejectCircularInsertion: (container: Obj, value: Value, label: string, seen?: Set<object>) => void;
|
|
7
|
+
export declare const describeValue: (value: Value) => string;
|
|
8
|
+
export declare const typeofValue: (value: Value) => string;
|