mustardscript 0.1.0 → 0.1.2
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 +65 -22
- package/SECURITY.md +1 -1
- package/dist/index.js +2 -0
- package/dist/lib/executor.js +16 -1
- package/dist/lib/policy.js +301 -22
- package/dist/lib/progress.js +499 -113
- package/dist/lib/runtime.js +109 -40
- package/dist/lib/structured.js +327 -11
- package/dist/native-loader.js +11 -12
- package/index.d.ts +54 -6
- package/mustard.d.ts +23 -1
- package/package.json +34 -25
- package/Cargo.lock +0 -1579
- package/Cargo.toml +0 -40
- package/crates/mustard/Cargo.toml +0 -31
- package/crates/mustard/src/cancellation.rs +0 -28
- package/crates/mustard/src/diagnostic.rs +0 -145
- package/crates/mustard/src/ir.rs +0 -435
- package/crates/mustard/src/lib.rs +0 -21
- package/crates/mustard/src/limits.rs +0 -22
- package/crates/mustard/src/parser/expressions.rs +0 -723
- package/crates/mustard/src/parser/mod.rs +0 -115
- package/crates/mustard/src/parser/operators.rs +0 -105
- package/crates/mustard/src/parser/patterns.rs +0 -123
- package/crates/mustard/src/parser/scope.rs +0 -107
- package/crates/mustard/src/parser/statements.rs +0 -298
- package/crates/mustard/src/parser/tests/acceptance.rs +0 -339
- package/crates/mustard/src/parser/tests/mod.rs +0 -2
- package/crates/mustard/src/parser/tests/rejections.rs +0 -107
- package/crates/mustard/src/runtime/accounting.rs +0 -613
- package/crates/mustard/src/runtime/api.rs +0 -192
- package/crates/mustard/src/runtime/async_runtime/mod.rs +0 -5
- package/crates/mustard/src/runtime/async_runtime/promises.rs +0 -246
- package/crates/mustard/src/runtime/async_runtime/reactions.rs +0 -400
- package/crates/mustard/src/runtime/async_runtime/scheduler.rs +0 -224
- package/crates/mustard/src/runtime/builtins/arrays.rs +0 -1205
- package/crates/mustard/src/runtime/builtins/collections.rs +0 -573
- package/crates/mustard/src/runtime/builtins/install.rs +0 -501
- package/crates/mustard/src/runtime/builtins/intl.rs +0 -553
- package/crates/mustard/src/runtime/builtins/mod.rs +0 -25
- package/crates/mustard/src/runtime/builtins/objects.rs +0 -405
- package/crates/mustard/src/runtime/builtins/primitives.rs +0 -859
- package/crates/mustard/src/runtime/builtins/promises.rs +0 -335
- package/crates/mustard/src/runtime/builtins/regexp.rs +0 -356
- package/crates/mustard/src/runtime/builtins/strings.rs +0 -803
- package/crates/mustard/src/runtime/builtins/support.rs +0 -561
- package/crates/mustard/src/runtime/bytecode.rs +0 -123
- package/crates/mustard/src/runtime/compiler/assignments.rs +0 -690
- package/crates/mustard/src/runtime/compiler/bindings.rs +0 -92
- package/crates/mustard/src/runtime/compiler/context.rs +0 -46
- package/crates/mustard/src/runtime/compiler/control.rs +0 -342
- package/crates/mustard/src/runtime/compiler/expressions.rs +0 -372
- package/crates/mustard/src/runtime/compiler/mod.rs +0 -173
- package/crates/mustard/src/runtime/compiler/statements.rs +0 -459
- package/crates/mustard/src/runtime/conversions/boundary.rs +0 -293
- package/crates/mustard/src/runtime/conversions/coercions.rs +0 -217
- package/crates/mustard/src/runtime/conversions/errors.rs +0 -118
- package/crates/mustard/src/runtime/conversions/mod.rs +0 -14
- package/crates/mustard/src/runtime/conversions/operators.rs +0 -334
- package/crates/mustard/src/runtime/env.rs +0 -355
- package/crates/mustard/src/runtime/exceptions.rs +0 -377
- package/crates/mustard/src/runtime/gc.rs +0 -595
- package/crates/mustard/src/runtime/mod.rs +0 -318
- package/crates/mustard/src/runtime/properties.rs +0 -1762
- package/crates/mustard/src/runtime/serialization.rs +0 -127
- package/crates/mustard/src/runtime/shared.rs +0 -108
- package/crates/mustard/src/runtime/snapshot_validation_tests.rs +0 -93
- package/crates/mustard/src/runtime/state.rs +0 -652
- package/crates/mustard/src/runtime/tests/async_host.rs +0 -104
- package/crates/mustard/src/runtime/tests/collections.rs +0 -50
- package/crates/mustard/src/runtime/tests/diagnostics.rs +0 -36
- package/crates/mustard/src/runtime/tests/exceptions.rs +0 -122
- package/crates/mustard/src/runtime/tests/execution.rs +0 -553
- package/crates/mustard/src/runtime/tests/gc.rs +0 -533
- package/crates/mustard/src/runtime/tests/mod.rs +0 -56
- package/crates/mustard/src/runtime/tests/serialization.rs +0 -170
- package/crates/mustard/src/runtime/validation/bytecode.rs +0 -484
- package/crates/mustard/src/runtime/validation/mod.rs +0 -14
- package/crates/mustard/src/runtime/validation/policy.rs +0 -94
- package/crates/mustard/src/runtime/validation/snapshot.rs +0 -406
- package/crates/mustard/src/runtime/validation/walk.rs +0 -206
- package/crates/mustard/src/runtime/vm.rs +0 -1016
- package/crates/mustard/src/span.rs +0 -22
- package/crates/mustard/src/structured.rs +0 -107
- package/crates/mustard-bridge/Cargo.toml +0 -17
- package/crates/mustard-bridge/src/codec.rs +0 -46
- package/crates/mustard-bridge/src/dto.rs +0 -99
- package/crates/mustard-bridge/src/lib.rs +0 -12
- package/crates/mustard-bridge/src/operations.rs +0 -142
- package/crates/mustard-node/Cargo.toml +0 -24
- package/crates/mustard-node/build.rs +0 -3
- package/crates/mustard-node/src/lib.rs +0 -236
- package/crates/mustard-sidecar/Cargo.toml +0 -21
- package/crates/mustard-sidecar/src/lib.rs +0 -134
- package/crates/mustard-sidecar/src/main.rs +0 -36
- package/dist/install.js +0 -117
|
@@ -1,652 +0,0 @@
|
|
|
1
|
-
use std::collections::{HashSet, VecDeque};
|
|
2
|
-
|
|
3
|
-
use indexmap::IndexMap;
|
|
4
|
-
use num_bigint::BigInt;
|
|
5
|
-
use serde::{Deserialize, Serialize};
|
|
6
|
-
use slotmap::{SlotMap, new_key_type};
|
|
7
|
-
|
|
8
|
-
use crate::{
|
|
9
|
-
cancellation::CancellationToken, limits::RuntimeLimits, span::SourceSpan,
|
|
10
|
-
structured::StructuredValue,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
use super::{api::ExecutionStep, bytecode::BytecodeProgram};
|
|
14
|
-
|
|
15
|
-
new_key_type! { pub(super) struct EnvKey; }
|
|
16
|
-
new_key_type! { pub(super) struct CellKey; }
|
|
17
|
-
new_key_type! { pub(super) struct ObjectKey; }
|
|
18
|
-
new_key_type! { pub(super) struct ArrayKey; }
|
|
19
|
-
new_key_type! { pub(super) struct MapKey; }
|
|
20
|
-
new_key_type! { pub(super) struct SetKey; }
|
|
21
|
-
new_key_type! { pub(super) struct IteratorKey; }
|
|
22
|
-
new_key_type! { pub(super) struct ClosureKey; }
|
|
23
|
-
new_key_type! { pub(super) struct PromiseKey; }
|
|
24
|
-
|
|
25
|
-
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
26
|
-
pub(super) enum Value {
|
|
27
|
-
#[default]
|
|
28
|
-
Undefined,
|
|
29
|
-
Null,
|
|
30
|
-
Bool(bool),
|
|
31
|
-
Number(f64),
|
|
32
|
-
String(String),
|
|
33
|
-
Object(ObjectKey),
|
|
34
|
-
Array(ArrayKey),
|
|
35
|
-
Map(MapKey),
|
|
36
|
-
Set(SetKey),
|
|
37
|
-
Iterator(IteratorKey),
|
|
38
|
-
Closure(ClosureKey),
|
|
39
|
-
Promise(PromiseKey),
|
|
40
|
-
BuiltinFunction(BuiltinFunction),
|
|
41
|
-
HostFunction(String),
|
|
42
|
-
BigInt(BigInt),
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
|
46
|
-
pub(super) enum BuiltinFunction {
|
|
47
|
-
FunctionCtor,
|
|
48
|
-
FunctionCall,
|
|
49
|
-
FunctionApply,
|
|
50
|
-
FunctionBind,
|
|
51
|
-
ArrayCtor,
|
|
52
|
-
ArrayFrom,
|
|
53
|
-
ArrayOf,
|
|
54
|
-
ArrayIsArray,
|
|
55
|
-
ArrayPush,
|
|
56
|
-
ArrayPop,
|
|
57
|
-
ArraySlice,
|
|
58
|
-
ArraySplice,
|
|
59
|
-
ArrayConcat,
|
|
60
|
-
ArrayAt,
|
|
61
|
-
ArrayJoin,
|
|
62
|
-
ArrayIncludes,
|
|
63
|
-
ArrayIndexOf,
|
|
64
|
-
ArrayLastIndexOf,
|
|
65
|
-
ArrayReverse,
|
|
66
|
-
ArrayFill,
|
|
67
|
-
ArraySort,
|
|
68
|
-
ArrayValues,
|
|
69
|
-
ArrayKeys,
|
|
70
|
-
ArrayEntries,
|
|
71
|
-
ArrayForEach,
|
|
72
|
-
ArrayMap,
|
|
73
|
-
ArrayFilter,
|
|
74
|
-
ArrayFind,
|
|
75
|
-
ArrayFindIndex,
|
|
76
|
-
ArraySome,
|
|
77
|
-
ArrayEvery,
|
|
78
|
-
ArrayFlat,
|
|
79
|
-
ArrayFlatMap,
|
|
80
|
-
ArrayReduce,
|
|
81
|
-
ArrayReduceRight,
|
|
82
|
-
ArrayFindLast,
|
|
83
|
-
ArrayFindLastIndex,
|
|
84
|
-
ObjectCtor,
|
|
85
|
-
ObjectAssign,
|
|
86
|
-
ObjectCreate,
|
|
87
|
-
ObjectFreeze,
|
|
88
|
-
ObjectSeal,
|
|
89
|
-
ObjectFromEntries,
|
|
90
|
-
ObjectKeys,
|
|
91
|
-
ObjectValues,
|
|
92
|
-
ObjectEntries,
|
|
93
|
-
ObjectHasOwn,
|
|
94
|
-
MapCtor,
|
|
95
|
-
MapGet,
|
|
96
|
-
MapSet,
|
|
97
|
-
MapHas,
|
|
98
|
-
MapDelete,
|
|
99
|
-
MapClear,
|
|
100
|
-
MapEntries,
|
|
101
|
-
MapKeys,
|
|
102
|
-
MapValues,
|
|
103
|
-
MapForEach,
|
|
104
|
-
SetCtor,
|
|
105
|
-
SetAdd,
|
|
106
|
-
SetHas,
|
|
107
|
-
SetDelete,
|
|
108
|
-
SetClear,
|
|
109
|
-
SetEntries,
|
|
110
|
-
SetKeys,
|
|
111
|
-
SetValues,
|
|
112
|
-
SetForEach,
|
|
113
|
-
IteratorNext,
|
|
114
|
-
PromiseCtor,
|
|
115
|
-
PromiseResolve,
|
|
116
|
-
PromiseReject,
|
|
117
|
-
PromiseResolveFunction(PromiseKey),
|
|
118
|
-
PromiseRejectFunction(PromiseKey),
|
|
119
|
-
PromiseThen,
|
|
120
|
-
PromiseCatch,
|
|
121
|
-
PromiseFinally,
|
|
122
|
-
PromiseAll,
|
|
123
|
-
PromiseRace,
|
|
124
|
-
PromiseAny,
|
|
125
|
-
PromiseAllSettled,
|
|
126
|
-
RegExpCtor,
|
|
127
|
-
RegExpExec,
|
|
128
|
-
RegExpTest,
|
|
129
|
-
ErrorCtor,
|
|
130
|
-
TypeErrorCtor,
|
|
131
|
-
ReferenceErrorCtor,
|
|
132
|
-
RangeErrorCtor,
|
|
133
|
-
SyntaxErrorCtor,
|
|
134
|
-
NumberCtor,
|
|
135
|
-
NumberParseInt,
|
|
136
|
-
NumberParseFloat,
|
|
137
|
-
NumberIsNaN,
|
|
138
|
-
NumberIsFinite,
|
|
139
|
-
NumberIsInteger,
|
|
140
|
-
NumberIsSafeInteger,
|
|
141
|
-
DateCtor,
|
|
142
|
-
DateNow,
|
|
143
|
-
DateGetTime,
|
|
144
|
-
DateValueOf,
|
|
145
|
-
DateToISOString,
|
|
146
|
-
DateToJSON,
|
|
147
|
-
DateGetUTCFullYear,
|
|
148
|
-
DateGetUTCMonth,
|
|
149
|
-
DateGetUTCDate,
|
|
150
|
-
DateGetUTCHours,
|
|
151
|
-
DateGetUTCMinutes,
|
|
152
|
-
DateGetUTCSeconds,
|
|
153
|
-
IntlDateTimeFormatCtor,
|
|
154
|
-
IntlNumberFormatCtor,
|
|
155
|
-
IntlDateTimeFormatFormat,
|
|
156
|
-
IntlDateTimeFormatResolvedOptions,
|
|
157
|
-
IntlNumberFormatFormat,
|
|
158
|
-
IntlNumberFormatResolvedOptions,
|
|
159
|
-
StringCtor,
|
|
160
|
-
StringTrim,
|
|
161
|
-
StringTrimStart,
|
|
162
|
-
StringTrimEnd,
|
|
163
|
-
StringIncludes,
|
|
164
|
-
StringStartsWith,
|
|
165
|
-
StringEndsWith,
|
|
166
|
-
StringIndexOf,
|
|
167
|
-
StringLastIndexOf,
|
|
168
|
-
StringCharAt,
|
|
169
|
-
StringAt,
|
|
170
|
-
StringSlice,
|
|
171
|
-
StringSubstring,
|
|
172
|
-
StringToLowerCase,
|
|
173
|
-
StringToUpperCase,
|
|
174
|
-
StringRepeat,
|
|
175
|
-
StringConcat,
|
|
176
|
-
StringPadStart,
|
|
177
|
-
StringPadEnd,
|
|
178
|
-
StringSplit,
|
|
179
|
-
StringReplace,
|
|
180
|
-
StringReplaceAll,
|
|
181
|
-
StringSearch,
|
|
182
|
-
StringMatch,
|
|
183
|
-
StringMatchAll,
|
|
184
|
-
StringToString,
|
|
185
|
-
StringValueOf,
|
|
186
|
-
BooleanCtor,
|
|
187
|
-
BooleanToString,
|
|
188
|
-
BooleanValueOf,
|
|
189
|
-
NumberToString,
|
|
190
|
-
NumberValueOf,
|
|
191
|
-
MathAbs,
|
|
192
|
-
MathMax,
|
|
193
|
-
MathMin,
|
|
194
|
-
MathFloor,
|
|
195
|
-
MathCeil,
|
|
196
|
-
MathRound,
|
|
197
|
-
MathPow,
|
|
198
|
-
MathSqrt,
|
|
199
|
-
MathTrunc,
|
|
200
|
-
MathSign,
|
|
201
|
-
MathLog,
|
|
202
|
-
MathExp,
|
|
203
|
-
MathLog2,
|
|
204
|
-
MathLog10,
|
|
205
|
-
MathSin,
|
|
206
|
-
MathCos,
|
|
207
|
-
MathAtan2,
|
|
208
|
-
MathHypot,
|
|
209
|
-
MathCbrt,
|
|
210
|
-
MathRandom,
|
|
211
|
-
JsonStringify,
|
|
212
|
-
JsonParse,
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
216
|
-
pub(super) struct Env {
|
|
217
|
-
pub(super) parent: Option<EnvKey>,
|
|
218
|
-
pub(super) bindings: IndexMap<String, CellKey>,
|
|
219
|
-
#[serde(skip, default)]
|
|
220
|
-
pub(super) accounted_bytes: usize,
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
224
|
-
pub(super) struct Cell {
|
|
225
|
-
pub(super) value: Value,
|
|
226
|
-
pub(super) mutable: bool,
|
|
227
|
-
pub(super) initialized: bool,
|
|
228
|
-
#[serde(skip, default)]
|
|
229
|
-
pub(super) accounted_bytes: usize,
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
233
|
-
pub(super) struct PlainObject {
|
|
234
|
-
pub(super) properties: IndexMap<String, Value>,
|
|
235
|
-
pub(super) kind: ObjectKind,
|
|
236
|
-
#[serde(skip, default)]
|
|
237
|
-
pub(super) accounted_bytes: usize,
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
241
|
-
pub(super) enum ObjectKind {
|
|
242
|
-
Plain,
|
|
243
|
-
Global,
|
|
244
|
-
Math,
|
|
245
|
-
Json,
|
|
246
|
-
Console,
|
|
247
|
-
Intl,
|
|
248
|
-
FunctionPrototype(Value),
|
|
249
|
-
BoundFunction(BoundFunctionData),
|
|
250
|
-
Error(String),
|
|
251
|
-
Date(DateObject),
|
|
252
|
-
RegExp(RegExpObject),
|
|
253
|
-
NumberObject(f64),
|
|
254
|
-
StringObject(String),
|
|
255
|
-
BooleanObject(bool),
|
|
256
|
-
IntlDateTimeFormat(IntlDateTimeFormatObject),
|
|
257
|
-
IntlNumberFormat(IntlNumberFormatObject),
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
261
|
-
pub(super) struct BoundFunctionData {
|
|
262
|
-
pub(super) target: Value,
|
|
263
|
-
pub(super) this_value: Value,
|
|
264
|
-
pub(super) args: Vec<Value>,
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
268
|
-
pub(super) struct DateObject {
|
|
269
|
-
pub(super) timestamp_ms: f64,
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
273
|
-
pub(super) struct IntlDateTimeFormatObject {
|
|
274
|
-
pub(super) locale: String,
|
|
275
|
-
pub(super) time_zone: String,
|
|
276
|
-
pub(super) year: Option<IntlFieldStyle>,
|
|
277
|
-
pub(super) month: Option<IntlFieldStyle>,
|
|
278
|
-
pub(super) day: Option<IntlFieldStyle>,
|
|
279
|
-
pub(super) hour: Option<IntlFieldStyle>,
|
|
280
|
-
pub(super) minute: Option<IntlFieldStyle>,
|
|
281
|
-
pub(super) second: Option<IntlFieldStyle>,
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
285
|
-
pub(super) struct IntlNumberFormatObject {
|
|
286
|
-
pub(super) locale: String,
|
|
287
|
-
pub(super) style: IntlNumberStyle,
|
|
288
|
-
pub(super) currency: Option<String>,
|
|
289
|
-
pub(super) minimum_fraction_digits: usize,
|
|
290
|
-
pub(super) maximum_fraction_digits: usize,
|
|
291
|
-
pub(super) use_grouping: bool,
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
|
295
|
-
pub(super) enum IntlFieldStyle {
|
|
296
|
-
Numeric,
|
|
297
|
-
TwoDigit,
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
|
301
|
-
pub(super) enum IntlNumberStyle {
|
|
302
|
-
Decimal,
|
|
303
|
-
Percent,
|
|
304
|
-
Currency,
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
308
|
-
pub(super) struct RegExpObject {
|
|
309
|
-
pub(super) pattern: String,
|
|
310
|
-
pub(super) flags: String,
|
|
311
|
-
pub(super) last_index: usize,
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
315
|
-
pub(super) struct ArrayObject {
|
|
316
|
-
pub(super) elements: Vec<Option<Value>>,
|
|
317
|
-
pub(super) properties: IndexMap<String, Value>,
|
|
318
|
-
#[serde(skip, default)]
|
|
319
|
-
pub(super) accounted_bytes: usize,
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
323
|
-
pub(super) struct MapObject {
|
|
324
|
-
pub(super) entries: Vec<MapEntry>,
|
|
325
|
-
#[serde(skip, default)]
|
|
326
|
-
pub(super) accounted_bytes: usize,
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
330
|
-
pub(super) struct MapEntry {
|
|
331
|
-
pub(super) key: Value,
|
|
332
|
-
pub(super) value: Value,
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
336
|
-
pub(super) struct SetObject {
|
|
337
|
-
pub(super) entries: Vec<Value>,
|
|
338
|
-
#[serde(skip, default)]
|
|
339
|
-
pub(super) accounted_bytes: usize,
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
343
|
-
pub(super) struct IteratorObject {
|
|
344
|
-
pub(super) state: IteratorState,
|
|
345
|
-
#[serde(skip, default)]
|
|
346
|
-
pub(super) accounted_bytes: usize,
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
350
|
-
pub(super) enum IteratorState {
|
|
351
|
-
Array(ArrayIteratorState),
|
|
352
|
-
ArrayKeys(ArrayIteratorState),
|
|
353
|
-
ArrayEntries(ArrayIteratorState),
|
|
354
|
-
String(StringIteratorState),
|
|
355
|
-
MapEntries(MapIteratorState),
|
|
356
|
-
MapKeys(MapIteratorState),
|
|
357
|
-
MapValues(MapIteratorState),
|
|
358
|
-
SetEntries(SetIteratorState),
|
|
359
|
-
SetValues(SetIteratorState),
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
363
|
-
pub(super) struct ArrayIteratorState {
|
|
364
|
-
pub(super) array: ArrayKey,
|
|
365
|
-
pub(super) next_index: usize,
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
369
|
-
pub(super) struct StringIteratorState {
|
|
370
|
-
pub(super) value: String,
|
|
371
|
-
pub(super) next_index: usize,
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
375
|
-
pub(super) struct MapIteratorState {
|
|
376
|
-
pub(super) map: MapKey,
|
|
377
|
-
pub(super) next_index: usize,
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
381
|
-
pub(super) struct SetIteratorState {
|
|
382
|
-
pub(super) set: SetKey,
|
|
383
|
-
pub(super) next_index: usize,
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
387
|
-
pub(super) struct Closure {
|
|
388
|
-
pub(super) function_id: usize,
|
|
389
|
-
pub(super) env: EnvKey,
|
|
390
|
-
#[serde(default)]
|
|
391
|
-
pub(super) name: Option<String>,
|
|
392
|
-
#[serde(default)]
|
|
393
|
-
pub(super) this_value: Value,
|
|
394
|
-
#[serde(default)]
|
|
395
|
-
pub(super) prototype: Option<ObjectKey>,
|
|
396
|
-
#[serde(default)]
|
|
397
|
-
pub(super) properties: IndexMap<String, Value>,
|
|
398
|
-
#[serde(skip, default)]
|
|
399
|
-
pub(super) accounted_bytes: usize,
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
403
|
-
pub(super) struct PromiseObject {
|
|
404
|
-
pub(super) state: PromiseState,
|
|
405
|
-
pub(super) awaiters: Vec<AsyncContinuation>,
|
|
406
|
-
pub(super) dependents: Vec<PromiseKey>,
|
|
407
|
-
pub(super) reactions: Vec<PromiseReaction>,
|
|
408
|
-
pub(super) driver: Option<PromiseDriver>,
|
|
409
|
-
#[serde(skip, default)]
|
|
410
|
-
pub(super) accounted_bytes: usize,
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
414
|
-
pub(super) enum PromiseState {
|
|
415
|
-
Pending,
|
|
416
|
-
Fulfilled(Value),
|
|
417
|
-
Rejected(PromiseRejection),
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
421
|
-
pub(super) struct PromiseRejection {
|
|
422
|
-
pub(super) value: Value,
|
|
423
|
-
pub(super) span: Option<SourceSpan>,
|
|
424
|
-
pub(super) traceback: Vec<TraceFrameSnapshot>,
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
428
|
-
pub(super) struct TraceFrameSnapshot {
|
|
429
|
-
pub(super) function_name: Option<String>,
|
|
430
|
-
pub(super) span: SourceSpan,
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
434
|
-
pub(super) struct AsyncContinuation {
|
|
435
|
-
pub(super) frames: Vec<Frame>,
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
439
|
-
pub(super) enum PromiseOutcome {
|
|
440
|
-
Fulfilled(Value),
|
|
441
|
-
Rejected(PromiseRejection),
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
445
|
-
pub(super) enum PromiseReaction {
|
|
446
|
-
Then {
|
|
447
|
-
target: PromiseKey,
|
|
448
|
-
on_fulfilled: Option<Value>,
|
|
449
|
-
on_rejected: Option<Value>,
|
|
450
|
-
},
|
|
451
|
-
Finally {
|
|
452
|
-
target: PromiseKey,
|
|
453
|
-
callback: Option<Value>,
|
|
454
|
-
},
|
|
455
|
-
FinallyPassThrough {
|
|
456
|
-
target: PromiseKey,
|
|
457
|
-
original_outcome: PromiseOutcome,
|
|
458
|
-
},
|
|
459
|
-
Combinator {
|
|
460
|
-
target: PromiseKey,
|
|
461
|
-
index: usize,
|
|
462
|
-
kind: PromiseCombinatorKind,
|
|
463
|
-
},
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
|
467
|
-
pub(super) enum PromiseCombinatorKind {
|
|
468
|
-
All,
|
|
469
|
-
AllSettled,
|
|
470
|
-
Any,
|
|
471
|
-
Race,
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
475
|
-
pub(super) enum PromiseDriver {
|
|
476
|
-
Thenable {
|
|
477
|
-
value: Value,
|
|
478
|
-
},
|
|
479
|
-
All {
|
|
480
|
-
remaining: usize,
|
|
481
|
-
values: Vec<Option<Value>>,
|
|
482
|
-
},
|
|
483
|
-
AllSettled {
|
|
484
|
-
remaining: usize,
|
|
485
|
-
results: Vec<Option<PromiseSettledResult>>,
|
|
486
|
-
},
|
|
487
|
-
Any {
|
|
488
|
-
remaining: usize,
|
|
489
|
-
reasons: Vec<Option<Value>>,
|
|
490
|
-
},
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
494
|
-
pub(super) enum PromiseSettledResult {
|
|
495
|
-
Fulfilled(Value),
|
|
496
|
-
Rejected(Value),
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
500
|
-
pub(super) enum MicrotaskJob {
|
|
501
|
-
ResumeAsync {
|
|
502
|
-
continuation: AsyncContinuation,
|
|
503
|
-
outcome: PromiseOutcome,
|
|
504
|
-
},
|
|
505
|
-
PromiseReaction {
|
|
506
|
-
reaction: PromiseReaction,
|
|
507
|
-
outcome: PromiseOutcome,
|
|
508
|
-
},
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
512
|
-
pub(super) struct PendingHostCall {
|
|
513
|
-
pub(super) capability: String,
|
|
514
|
-
pub(super) args: Vec<StructuredValue>,
|
|
515
|
-
pub(super) promise: Option<PromiseKey>,
|
|
516
|
-
pub(super) resume_behavior: ResumeBehavior,
|
|
517
|
-
pub(super) traceback: Vec<TraceFrameSnapshot>,
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
521
|
-
pub(super) struct Frame {
|
|
522
|
-
pub(super) function_id: usize,
|
|
523
|
-
pub(super) ip: usize,
|
|
524
|
-
pub(super) env: EnvKey,
|
|
525
|
-
pub(super) scope_stack: Vec<EnvKey>,
|
|
526
|
-
pub(super) stack: Vec<Value>,
|
|
527
|
-
pub(super) handlers: Vec<ExceptionHandler>,
|
|
528
|
-
pub(super) pending_exception: Option<Value>,
|
|
529
|
-
pub(super) pending_completions: Vec<CompletionRecord>,
|
|
530
|
-
pub(super) active_finally: Vec<ActiveFinallyState>,
|
|
531
|
-
pub(super) async_promise: Option<PromiseKey>,
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
535
|
-
pub(super) struct ExceptionHandler {
|
|
536
|
-
pub(super) catch: Option<usize>,
|
|
537
|
-
pub(super) finally: Option<usize>,
|
|
538
|
-
pub(super) env: EnvKey,
|
|
539
|
-
pub(super) scope_stack_len: usize,
|
|
540
|
-
pub(super) stack_len: usize,
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
544
|
-
pub(super) enum CompletionRecord {
|
|
545
|
-
Jump {
|
|
546
|
-
target: usize,
|
|
547
|
-
target_handler_depth: usize,
|
|
548
|
-
target_scope_depth: usize,
|
|
549
|
-
},
|
|
550
|
-
Return(Value),
|
|
551
|
-
Throw(Value),
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
555
|
-
pub(super) struct ActiveFinallyState {
|
|
556
|
-
pub(super) completion_index: usize,
|
|
557
|
-
pub(super) exit: usize,
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
561
|
-
pub(super) struct Runtime {
|
|
562
|
-
pub(super) program: BytecodeProgram,
|
|
563
|
-
pub(super) limits: RuntimeLimits,
|
|
564
|
-
pub(super) globals: EnvKey,
|
|
565
|
-
pub(super) envs: SlotMap<EnvKey, Env>,
|
|
566
|
-
pub(super) cells: SlotMap<CellKey, Cell>,
|
|
567
|
-
pub(super) objects: SlotMap<ObjectKey, PlainObject>,
|
|
568
|
-
pub(super) arrays: SlotMap<ArrayKey, ArrayObject>,
|
|
569
|
-
pub(super) maps: SlotMap<MapKey, MapObject>,
|
|
570
|
-
pub(super) sets: SlotMap<SetKey, SetObject>,
|
|
571
|
-
pub(super) iterators: SlotMap<IteratorKey, IteratorObject>,
|
|
572
|
-
pub(super) closures: SlotMap<ClosureKey, Closure>,
|
|
573
|
-
pub(super) promises: SlotMap<PromiseKey, PromiseObject>,
|
|
574
|
-
pub(super) frames: Vec<Frame>,
|
|
575
|
-
pub(super) root_result: Option<Value>,
|
|
576
|
-
pub(super) microtasks: VecDeque<MicrotaskJob>,
|
|
577
|
-
pub(super) pending_host_calls: VecDeque<PendingHostCall>,
|
|
578
|
-
pub(super) suspended_host_call: Option<PendingHostCall>,
|
|
579
|
-
#[serde(default)]
|
|
580
|
-
pub(super) builtin_prototypes: IndexMap<BuiltinFunction, ObjectKey>,
|
|
581
|
-
#[serde(default)]
|
|
582
|
-
pub(super) builtin_function_objects: IndexMap<BuiltinFunction, ObjectKey>,
|
|
583
|
-
#[serde(default)]
|
|
584
|
-
pub(super) host_function_objects: IndexMap<String, ObjectKey>,
|
|
585
|
-
pub(super) snapshot_nonce: u64,
|
|
586
|
-
pub(super) instruction_counter: usize,
|
|
587
|
-
#[serde(skip, default)]
|
|
588
|
-
pub(super) heap_bytes_used: usize,
|
|
589
|
-
#[serde(skip, default)]
|
|
590
|
-
pub(super) allocation_count: usize,
|
|
591
|
-
#[serde(skip, default)]
|
|
592
|
-
pub(super) cancellation_token: Option<CancellationToken>,
|
|
593
|
-
#[serde(skip, default)]
|
|
594
|
-
pub(super) pending_internal_exception: Option<PromiseRejection>,
|
|
595
|
-
#[serde(skip, default)]
|
|
596
|
-
pub(super) snapshot_policy_required: bool,
|
|
597
|
-
pub(super) pending_resume_behavior: ResumeBehavior,
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
pub(super) enum RunState {
|
|
601
|
-
Completed(Value),
|
|
602
|
-
PushedFrame,
|
|
603
|
-
StartedAsync(Value),
|
|
604
|
-
Suspended {
|
|
605
|
-
capability: String,
|
|
606
|
-
args: Vec<StructuredValue>,
|
|
607
|
-
resume_behavior: ResumeBehavior,
|
|
608
|
-
},
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
|
612
|
-
pub(super) enum ResumeBehavior {
|
|
613
|
-
Value,
|
|
614
|
-
Undefined,
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
pub(super) enum StepAction {
|
|
618
|
-
Continue,
|
|
619
|
-
Return(ExecutionStep),
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
#[derive(Debug, Default)]
|
|
623
|
-
pub(super) struct GarbageCollectionMarks {
|
|
624
|
-
pub(super) envs: HashSet<EnvKey>,
|
|
625
|
-
pub(super) cells: HashSet<CellKey>,
|
|
626
|
-
pub(super) objects: HashSet<ObjectKey>,
|
|
627
|
-
pub(super) arrays: HashSet<ArrayKey>,
|
|
628
|
-
pub(super) maps: HashSet<MapKey>,
|
|
629
|
-
pub(super) sets: HashSet<SetKey>,
|
|
630
|
-
pub(super) iterators: HashSet<IteratorKey>,
|
|
631
|
-
pub(super) closures: HashSet<ClosureKey>,
|
|
632
|
-
pub(super) promises: HashSet<PromiseKey>,
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
#[derive(Debug, Default)]
|
|
636
|
-
pub(super) struct GarbageCollectionWorklist {
|
|
637
|
-
pub(super) envs: Vec<EnvKey>,
|
|
638
|
-
pub(super) cells: Vec<CellKey>,
|
|
639
|
-
pub(super) objects: Vec<ObjectKey>,
|
|
640
|
-
pub(super) arrays: Vec<ArrayKey>,
|
|
641
|
-
pub(super) maps: Vec<MapKey>,
|
|
642
|
-
pub(super) sets: Vec<SetKey>,
|
|
643
|
-
pub(super) iterators: Vec<IteratorKey>,
|
|
644
|
-
pub(super) closures: Vec<ClosureKey>,
|
|
645
|
-
pub(super) promises: Vec<PromiseKey>,
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
649
|
-
pub(super) struct GarbageCollectionStats {
|
|
650
|
-
pub(super) reclaimed_bytes: usize,
|
|
651
|
-
pub(super) reclaimed_allocations: usize,
|
|
652
|
-
}
|