@velarscript/compiler 0.12.0 → 0.13.0
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/advisory-suppression.d.ts +62 -0
- package/dist/advisory-suppression.d.ts.map +1 -0
- package/dist/advisory-suppression.js +179 -0
- package/dist/advisory-suppression.js.map +1 -0
- package/dist/analyzer.d.ts +405 -17
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +1755 -211
- package/dist/analyzer.js.map +1 -1
- package/dist/ast.d.ts +6 -3
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js.map +1 -1
- package/dist/binding-stability.d.ts +22 -0
- package/dist/binding-stability.d.ts.map +1 -0
- package/dist/binding-stability.js +63 -0
- package/dist/binding-stability.js.map +1 -0
- package/dist/collection-lowering-runtime.d.ts +1 -1
- package/dist/collection-lowering-runtime.d.ts.map +1 -1
- package/dist/collection-lowering-runtime.js +183 -56
- package/dist/collection-lowering-runtime.js.map +1 -1
- package/dist/diagnostic.d.ts +34 -0
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +11 -1
- package/dist/diagnostic.js.map +1 -1
- package/dist/embedded-javascript.d.ts +12 -1
- package/dist/embedded-javascript.d.ts.map +1 -1
- package/dist/embedded-javascript.js +111 -2
- package/dist/embedded-javascript.js.map +1 -1
- package/dist/embedded-module.d.ts.map +1 -1
- package/dist/embedded-module.js +22 -0
- package/dist/embedded-module.js.map +1 -1
- package/dist/emitter.d.ts +83 -1
- package/dist/emitter.d.ts.map +1 -1
- package/dist/emitter.js +518 -41
- package/dist/emitter.js.map +1 -1
- package/dist/error-runtime.d.ts +9 -0
- package/dist/error-runtime.d.ts.map +1 -1
- package/dist/error-runtime.js +21 -0
- package/dist/error-runtime.js.map +1 -1
- package/dist/extension.d.ts +5 -2
- package/dist/extension.d.ts.map +1 -1
- package/dist/extension.js +2 -1
- package/dist/extension.js.map +1 -1
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +222 -91
- package/dist/formatter.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -5
- package/dist/index.js.map +1 -1
- package/dist/interpolated-string.d.ts.map +1 -1
- package/dist/interpolated-string.js +29 -2
- package/dist/interpolated-string.js.map +1 -1
- package/dist/json-runtime.d.ts.map +1 -1
- package/dist/json-runtime.js +27 -3
- package/dist/json-runtime.js.map +1 -1
- package/dist/lexer.d.ts +217 -1
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +799 -37
- package/dist/lexer.js.map +1 -1
- package/dist/limits.d.ts +9 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +9 -0
- package/dist/limits.js.map +1 -1
- package/dist/mechanical-fix.d.ts.map +1 -1
- package/dist/mechanical-fix.js +38 -0
- package/dist/mechanical-fix.js.map +1 -1
- package/dist/parser.d.ts +30 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +137 -21
- package/dist/parser.js.map +1 -1
- package/dist/promise-runtime.d.ts +20 -1
- package/dist/promise-runtime.d.ts.map +1 -1
- package/dist/promise-runtime.js +38 -3
- package/dist/promise-runtime.js.map +1 -1
- package/dist/reactive-bridge-runtime.d.ts.map +1 -1
- package/dist/reactive-bridge-runtime.js +7 -1
- package/dist/reactive-bridge-runtime.js.map +1 -1
- package/dist/runtime-abi.d.ts +21 -1
- package/dist/runtime-abi.d.ts.map +1 -1
- package/dist/runtime-abi.js +23 -3
- package/dist/runtime-abi.js.map +1 -1
- package/dist/source-names.d.ts +26 -0
- package/dist/source-names.d.ts.map +1 -1
- package/dist/source-names.js +49 -5
- package/dist/source-names.js.map +1 -1
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +13 -0
- package/dist/source.js.map +1 -1
- package/dist/stable-order.d.ts +16 -0
- package/dist/stable-order.d.ts.map +1 -0
- package/dist/stable-order.js +18 -0
- package/dist/stable-order.js.map +1 -0
- package/dist/text-runtime.d.ts.map +1 -1
- package/dist/text-runtime.js +182 -41
- package/dist/text-runtime.js.map +1 -1
- package/dist/token.d.ts +11 -0
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js.map +1 -1
- package/dist/type-registry-runtime.d.ts.map +1 -1
- package/dist/type-registry-runtime.js +8 -1
- package/dist/type-registry-runtime.js.map +1 -1
- package/dist/type-validation-runtime.d.ts.map +1 -1
- package/dist/type-validation-runtime.js +129 -1
- package/dist/type-validation-runtime.js.map +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +161 -17
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,9 @@ export const VELAR_COLLECTION_LOWERING_EXPORTS = [
|
|
|
8
8
|
"__velarSameValueZero",
|
|
9
9
|
"__velarEquals",
|
|
10
10
|
"__velarValidateDenseList",
|
|
11
|
+
// COL-P1: the emitter names this one directly, for the empty List literal
|
|
12
|
+
// whose ownership only the compiler can vouch for.
|
|
13
|
+
"__velarAdoptList",
|
|
11
14
|
"__velarReactiveListIterator",
|
|
12
15
|
"__velarReactiveSetIterator",
|
|
13
16
|
"__velarReactiveMapKeyIterator",
|
|
@@ -130,7 +133,30 @@ const __velarListWeakMapSetOperation = __velarCollectionListGetOwnPropertyDescri
|
|
|
130
133
|
// check. Without the memo every index read on a List the compiler did not
|
|
131
134
|
// build (a literal, anything velar/collections returns) revalidated every
|
|
132
135
|
// element, making 'for i in range(n): values[i]' quadratic.
|
|
133
|
-
|
|
136
|
+
//
|
|
137
|
+
// COL-P1: the memo also records who wrote the elements, because that is what
|
|
138
|
+
// decides how much a later read still has to prove. An *owned* List holds only
|
|
139
|
+
// elements this runtime wrote: it either allocated and filled the array itself
|
|
140
|
+
// (every copy, map, filter, slice, and sorted result) or started from the empty
|
|
141
|
+
// List literal the compiler emitted __velarAdoptList for and took every element
|
|
142
|
+
// since through a List mutation. Every slot is then an ordinary data element by
|
|
143
|
+
// construction, and reading one is a plain load -- the same load List.sorted
|
|
144
|
+
// already performs on its own copy. A *checked* List held elements this runtime
|
|
145
|
+
// did not write when it first saw it, so every element read re-proves the slot
|
|
146
|
+
// with a descriptor, and an accessor installed after validation is still
|
|
147
|
+
// refused. Every array that arrives from JavaScript is checked, including one
|
|
148
|
+
// handed over empty: the runtime cannot tell that array from a List literal, so
|
|
149
|
+
// only the compiler ever adopts an empty array.
|
|
150
|
+
//
|
|
151
|
+
// Before the split every element read of every List allocated two property
|
|
152
|
+
// descriptors, so summing a 1,000,000-element List by index ran ~7x slower
|
|
153
|
+
// than the identical plain-JavaScript loop and 'for x in xs' ~9x slower.
|
|
154
|
+
//
|
|
155
|
+
// One registry answers both halves in one lookup, because a second WeakMap read
|
|
156
|
+
// on the checked tier cost every literal-built List ~10% for nothing: an owned
|
|
157
|
+
// List records the proved length, a checked List records its bitwise
|
|
158
|
+
// complement, and a length is never negative, so the sign is the tier.
|
|
159
|
+
const __velarListMemos = new __velarListNativeWeakMap();
|
|
134
160
|
const __velarListIsFrozenOperation = __velarCollectionListGetOwnPropertyDescriptor(__velarCollectionNativeObject, "isFrozen")?.value;
|
|
135
161
|
// COL-U4: a frozen host array fails every mutability probe below; without
|
|
136
162
|
// this check the author sees "requires ordinary mutable List data elements"
|
|
@@ -141,46 +167,121 @@ function __velarListRejectFrozen(value, name) {
|
|
|
141
167
|
throw new __velarCollectionNativeTypeError(name + " received a frozen JavaScript array; copy it on the JavaScript side — [...values] — before passing it to VelarScript");
|
|
142
168
|
}
|
|
143
169
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
170
|
+
function __velarListMemo(value) { return __velarCollectionHostCall(__velarListWeakMapGetOperation, __velarListMemos, [value]); }
|
|
171
|
+
// The owned half of __velarListTier, for the callers that have already
|
|
172
|
+
// validated the List and only need to know which element read to use.
|
|
173
|
+
function __velarListIsOwned(value) { const memo = __velarListMemo(value); return memo !== undefined && memo === value.length; }
|
|
174
|
+
function __velarAdoptList(value) { __velarCollectionHostCall(__velarListWeakMapSetOperation, __velarListMemos, [value, value.length]); return value; }
|
|
175
|
+
function __velarMarkCheckedList(value) { __velarCollectionHostCall(__velarListWeakMapSetOperation, __velarListMemos, [value, ~value.length]); return value; }
|
|
176
|
+
// A mutation re-records the proved length; it never changes which side of the
|
|
177
|
+
// boundary the List came from, so a host List stays checked for its whole life.
|
|
178
|
+
function __velarMarkOwnedList(value) {
|
|
179
|
+
const memo = __velarListMemo(value);
|
|
180
|
+
return memo !== undefined && memo < 0 ? __velarMarkCheckedList(value) : __velarAdoptList(value);
|
|
181
|
+
}
|
|
182
|
+
// COL-U4/COL-P1: freezing is the one foreign change that revokes the right to
|
|
183
|
+
// mutate without moving the length, so it survives every memo hit. Every
|
|
184
|
+
// operation that writes re-proves this descriptor -- one descriptor per
|
|
185
|
+
// operation, never per element -- and no read has to, because reading a slot
|
|
186
|
+
// does not require a mutable length. Without it a frozen List answers append,
|
|
187
|
+
// index assignment, and pop with the host's own "Cannot assign to read only
|
|
188
|
+
// property 'length'" instead of a VelarScript refusal.
|
|
189
|
+
function __velarListRequireMutableLength(value, name) {
|
|
190
|
+
const lengthDescriptor = __velarCollectionListGetOwnPropertyDescriptor(value, "length");
|
|
191
|
+
if (!lengthDescriptor || !lengthDescriptor.writable || lengthDescriptor.enumerable || lengthDescriptor.configurable || !("value" in lengthDescriptor)) throw new __velarCollectionNativeTypeError(name + " requires an ordinary mutable List length");
|
|
192
|
+
}
|
|
146
193
|
function __velarValidateDenseList(value, name) {
|
|
147
194
|
value = __velarReactiveRaw(value);
|
|
148
195
|
if (!__velarCollectionListIsArray(value) || value.length > __velarMaxCollectionItems || __velarCollectionListOwnSymbols(value).length > 0 || __velarCollectionListOwnNames(value).length !== value.length + 1) {
|
|
149
196
|
throw new __velarCollectionNativeTypeError(name + " requires a dense VelarScript List");
|
|
150
197
|
}
|
|
151
198
|
__velarListRejectFrozen(value, name);
|
|
152
|
-
|
|
153
|
-
if (!lengthDescriptor || !lengthDescriptor.writable || lengthDescriptor.enumerable || lengthDescriptor.configurable || !("value" in lengthDescriptor)) throw new __velarCollectionNativeTypeError(name + " requires an ordinary mutable List length");
|
|
199
|
+
__velarListRequireMutableLength(value, name);
|
|
154
200
|
for (let index = 0; index < value.length; index += 1) {
|
|
155
201
|
const descriptor = __velarCollectionListGetOwnPropertyDescriptor(value, index);
|
|
156
202
|
if (!descriptor?.enumerable || !descriptor.configurable || !descriptor.writable || !("value" in descriptor)) throw new __velarCollectionNativeTypeError(name + " requires ordinary mutable List data elements");
|
|
157
203
|
}
|
|
158
|
-
|
|
204
|
+
// COL-P1: this runtime can vouch for a slot it wrote and for no other, and
|
|
205
|
+
// full validation only ever runs on an array whose slots it did not write --
|
|
206
|
+
// one that arrived from JavaScript, or one whose length moved behind its
|
|
207
|
+
// back, which is itself proof the host is holding the array. The arrays this
|
|
208
|
+
// runtime did write are adopted where they are built, and the empty List
|
|
209
|
+
// literal is adopted by the code the compiler emitted for it, so nothing that
|
|
210
|
+
// reaches here is owned, including an array the host handed over empty.
|
|
211
|
+
return __velarMarkCheckedList(value);
|
|
212
|
+
}
|
|
213
|
+
// 0 = no memo this runtime can still stand behind, 1 = owned, 2 = checked.
|
|
214
|
+
// The registry answers undefined for a primitive, and the recorded length is
|
|
215
|
+
// only compared once it exists, so the length is never read off a non-object.
|
|
216
|
+
function __velarListTier(value) {
|
|
217
|
+
const memo = __velarListMemo(value);
|
|
218
|
+
if (memo === undefined) return 0;
|
|
219
|
+
if (memo === value.length) return 1;
|
|
220
|
+
return ~memo === value.length ? 2 : 0;
|
|
221
|
+
}
|
|
222
|
+
function __velarValidateListTier(value, name, tier) {
|
|
223
|
+
// An owned memo hit answers every probe below at once: this runtime wrote
|
|
224
|
+
// every element, proved the array dense with an ordinary mutable length, and
|
|
225
|
+
// re-recorded the length after each of its own mutations since. Reading is
|
|
226
|
+
// all this entry point promises, so it does not re-prove the mutable length;
|
|
227
|
+
// __velarValidateMutableList is the entry point for everything that writes.
|
|
228
|
+
if (tier === 1) return value;
|
|
229
|
+
if (tier === 0) return __velarValidateDenseList(value, name);
|
|
230
|
+
// A checked memo hit already proved the array dense and in range; the length
|
|
231
|
+
// descriptor is the one part of that verdict a foreign write can undo
|
|
232
|
+
// without moving the length itself.
|
|
233
|
+
__velarListRequireMutableLength(value, name);
|
|
234
|
+
return value;
|
|
159
235
|
}
|
|
160
236
|
function __velarValidateOwnedList(value, name) {
|
|
161
237
|
value = __velarReactiveRaw(value);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
238
|
+
return __velarValidateListTier(value, name, __velarListTier(value));
|
|
239
|
+
}
|
|
240
|
+
// The entry point for every operation that writes: it proves what a read
|
|
241
|
+
// proves and re-proves the mutable length on top of it, on both memo tiers, so
|
|
242
|
+
// a frozen List refuses in the same voice whoever built it.
|
|
243
|
+
function __velarValidateMutableList(value, name) {
|
|
244
|
+
value = __velarReactiveRaw(value);
|
|
245
|
+
const tier = __velarListTier(value);
|
|
246
|
+
if (tier === 0) return __velarValidateDenseList(value, name);
|
|
247
|
+
__velarListRequireMutableLength(value, name);
|
|
166
248
|
return value;
|
|
167
249
|
}
|
|
168
|
-
function
|
|
250
|
+
function __velarCheckedListElement(value, index, name) {
|
|
169
251
|
const descriptor = __velarCollectionListGetOwnPropertyDescriptor(value, index);
|
|
170
252
|
if (!descriptor?.enumerable || !descriptor.configurable || !descriptor.writable || !("value" in descriptor)) throw new __velarCollectionNativeTypeError(name + " requires ordinary mutable List data elements");
|
|
171
253
|
return descriptor.value;
|
|
172
254
|
}
|
|
173
|
-
|
|
255
|
+
// The load is the whole check on an owned List: this runtime wrote every slot,
|
|
256
|
+
// so there is nothing left to prove about the shape of one. A slot that reads
|
|
257
|
+
// as undefined is the one tamper the load still notices for free -- no List
|
|
258
|
+
// element is ever undefined -- so that case pays for the descriptor probe and
|
|
259
|
+
// reports the same refusal a checked List would. What it notices is a value
|
|
260
|
+
// the load cannot account for, not every foreign edit: a host that keeps a
|
|
261
|
+
// reference to a List this runtime owns and then rewrites a slot, installs an
|
|
262
|
+
// accessor on it, or empties it while a polluted array prototype answers for
|
|
263
|
+
// that index, gets its own value back. That is the residual the split accepts,
|
|
264
|
+
// the same one a plain foreign write always had, and [COL-P1] pins it.
|
|
265
|
+
function __velarOwnedListElement(value, index, name) {
|
|
266
|
+
const element = value[index];
|
|
267
|
+
return element === undefined ? __velarCheckedListElement(value, index, name) : element;
|
|
268
|
+
}
|
|
269
|
+
function __velarListElement(value, index, name, owned) {
|
|
270
|
+
return owned ? __velarOwnedListElement(value, index, name) : __velarCheckedListElement(value, index, name);
|
|
271
|
+
}
|
|
272
|
+
function* __velarReactiveListIterator(value) { __velarReactiveCollectionTrack(value); value = __velarValidateOwnedList(value, "List iteration"); const owned = __velarListIsOwned(value); for (let index = 0; index < value.length; index += 1) yield __velarReactiveCollectionRead(value, __velarReactiveIterateKey, __velarListElement(value, index, "List iteration", owned)); }
|
|
174
273
|
function* __velarReactiveSetIterator(value) { const size = __velarCollectionSetMapSetSize(value); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items"); __velarReactiveCollectionTrack(value); const iterator = __velarCollectionSetMapSetValues(value); while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) return; yield __velarReactiveCollectionRead(value, __velarReactiveIterateKey, step.value); } }
|
|
175
274
|
function* __velarReactiveMapKeyIterator(value) { const size = __velarCollectionSetMapMapSize(value); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries"); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey); const iterator = __velarCollectionSetMapMapKeys(value); while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return; yield __velarReactiveCollectionRead(value, __velarReactiveStructureKey, step.value); } }
|
|
176
275
|
function* __velarReactiveRecordIterator(value) { const fields = __velarRecordFields(value, "Record iteration"); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey); for (let index = 0; index < fields.length; index += 1) yield __velarReactiveCollectionRead(value, __velarReactiveStructureKey, fields[index]); }
|
|
177
276
|
function __velarCopyList(value, name) {
|
|
178
|
-
// Every callback operation snapshots through here, so
|
|
179
|
-
// what
|
|
277
|
+
// Every callback operation snapshots through here, so this loop is what
|
|
278
|
+
// decides what map costs before its first call: the ownership memo answers
|
|
279
|
+
// the whole-List validation, and on an owned List each element is a load.
|
|
180
280
|
value = __velarValidateOwnedList(value, name);
|
|
281
|
+
const owned = __velarListIsOwned(value);
|
|
181
282
|
const output = [];
|
|
182
|
-
for (let index = 0; index < value.length; index += 1) output[index] = __velarCollectionValue(
|
|
183
|
-
return
|
|
283
|
+
for (let index = 0; index < value.length; index += 1) output[index] = __velarCollectionValue(__velarListElement(value, index, name, owned));
|
|
284
|
+
return __velarAdoptList(output);
|
|
184
285
|
}
|
|
185
286
|
// TXT-D1: ordered string comparison is code-point order (= UTF-8 binary
|
|
186
287
|
// order) everywhere. UTF-16 code-unit order agrees exactly when neither
|
|
@@ -306,10 +407,11 @@ function __velarCreateList(parts) {
|
|
|
306
407
|
continue;
|
|
307
408
|
}
|
|
308
409
|
const values = __velarValidateOwnedList(read(), "List spread");
|
|
410
|
+
const spreadOwned = __velarListIsOwned(values);
|
|
309
411
|
if (output.length + values.length > __velarMaxCollectionItems) throw new __velarCollectionListNativeRangeError("A List cannot exceed 1000000 items");
|
|
310
|
-
for (let index = 0; index < values.length; index += 1) output[output.length] = __velarCollectionValue(
|
|
412
|
+
for (let index = 0; index < values.length; index += 1) output[output.length] = __velarCollectionValue(__velarListElement(values, index, "List spread", spreadOwned));
|
|
311
413
|
}
|
|
312
|
-
return
|
|
414
|
+
return __velarAdoptList(output);
|
|
313
415
|
}
|
|
314
416
|
async function __velarCreateListAsync(parts) {
|
|
315
417
|
const output = [];
|
|
@@ -325,10 +427,11 @@ async function __velarCreateListAsync(parts) {
|
|
|
325
427
|
continue;
|
|
326
428
|
}
|
|
327
429
|
const values = __velarValidateOwnedList(asynchronous ? await read() : read(), "List spread");
|
|
430
|
+
const spreadOwned = __velarListIsOwned(values);
|
|
328
431
|
if (output.length + values.length > __velarMaxCollectionItems) throw new __velarCollectionListNativeRangeError("A List cannot exceed 1000000 items");
|
|
329
|
-
for (let index = 0; index < values.length; index += 1) output[output.length] = __velarCollectionValue(
|
|
432
|
+
for (let index = 0; index < values.length; index += 1) output[output.length] = __velarCollectionValue(__velarListElement(values, index, "List spread", spreadOwned));
|
|
330
433
|
}
|
|
331
|
-
return
|
|
434
|
+
return __velarAdoptList(output);
|
|
332
435
|
}
|
|
333
436
|
|
|
334
437
|
// Members and keys are stored raw. Every membership and key lookup unwraps
|
|
@@ -339,7 +442,7 @@ function __velarCreateSet(value) {
|
|
|
339
442
|
const output = new __velarCollectionNativeSet();
|
|
340
443
|
if (value === undefined) return output;
|
|
341
444
|
value = __velarReactiveRaw(value);
|
|
342
|
-
if (__velarCollectionListIsArray(value)) { const values = __velarValidateOwnedList(value, "Set construction"); for (let index = 0; index < values.length; index += 1) __velarCollectionSetMapSetAdd(output, __velarCollectionValue(__velarReactiveRaw(
|
|
445
|
+
if (__velarCollectionListIsArray(value)) { const values = __velarValidateOwnedList(value, "Set construction"); const owned = __velarListIsOwned(values); for (let index = 0; index < values.length; index += 1) __velarCollectionSetMapSetAdd(output, __velarCollectionValue(__velarReactiveRaw(__velarListElement(values, index, "Set construction", owned)))); return output; }
|
|
343
446
|
if (!__velarIsSet(value)) throw new __velarCollectionNativeTypeError("Set construction requires a List or Set");
|
|
344
447
|
if (__velarCollectionSetMapSetSize(value) > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items");
|
|
345
448
|
const iterator = __velarCollectionSetMapSetValues(value); while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) return output; __velarCollectionSetMapSetAdd(output, __velarCollectionValue(__velarReactiveRaw(step.value))); }
|
|
@@ -355,10 +458,12 @@ function __velarCreateMap(value) {
|
|
|
355
458
|
}
|
|
356
459
|
if (__velarCollectionListIsArray(value)) {
|
|
357
460
|
const entries = __velarValidateOwnedList(value, "Map construction");
|
|
461
|
+
const entriesOwned = __velarListIsOwned(entries);
|
|
358
462
|
for (let index = 0; index < entries.length; index += 1) {
|
|
359
|
-
const entry = __velarValidateOwnedList(
|
|
463
|
+
const entry = __velarValidateOwnedList(__velarListElement(entries, index, "Map construction", entriesOwned), "Map entry construction");
|
|
360
464
|
if (entry.length !== 2) throw new __velarCollectionNativeTypeError("Map entry construction requires exactly [key, value]");
|
|
361
|
-
|
|
465
|
+
const entryOwned = __velarListIsOwned(entry);
|
|
466
|
+
__velarCollectionSetMapMapSet(output, __velarCollectionValue(__velarReactiveRaw(__velarListElement(entry, 0, "Map entry construction", entryOwned))), __velarCollectionValue(__velarReactiveRaw(__velarListElement(entry, 1, "Map entry construction", entryOwned))));
|
|
362
467
|
}
|
|
363
468
|
return output;
|
|
364
469
|
}
|
|
@@ -381,7 +486,7 @@ function __velarListGet(value, key) {
|
|
|
381
486
|
value = __velarValidateOwnedList(value, "List.get");
|
|
382
487
|
if (!__velarCollectionListIsInteger(key)) throw new __VelarIndexError("List.get index must be an integer");
|
|
383
488
|
const index = key < 0 ? value.length + key : key;
|
|
384
|
-
if (index >= 0 && index < value.length) return __velarReactiveCollectionRead(value, index,
|
|
489
|
+
if (index >= 0 && index < value.length) return __velarReactiveCollectionRead(value, index, __velarListElement(value, index, "List.get", __velarListIsOwned(value)));
|
|
385
490
|
__velarReactiveCollectionTrack(value, key < 0 ? __velarReactiveIterateKey : index);
|
|
386
491
|
__velarReactiveCollectionTrack(value);
|
|
387
492
|
return null;
|
|
@@ -421,9 +526,10 @@ function __velarCollectionSlice(value, start = 0, end = null) {
|
|
|
421
526
|
const length = value.length;
|
|
422
527
|
const first = start < 0 ? __velarCollectionListMaximum(length + start, 0) : __velarCollectionListMinimum(start, length);
|
|
423
528
|
const last = end < 0 ? __velarCollectionListMaximum(length + end, 0) : __velarCollectionListMinimum(end, length);
|
|
529
|
+
const owned = __velarListIsOwned(value);
|
|
424
530
|
const output = [];
|
|
425
|
-
for (let index = first; index < __velarCollectionListMaximum(first, last); index += 1) output[output.length] = __velarReactiveCollectionRead(value, index,
|
|
426
|
-
return
|
|
531
|
+
for (let index = first; index < __velarCollectionListMaximum(first, last); index += 1) output[output.length] = __velarReactiveCollectionRead(value, index, __velarListElement(value, index, "List.slice", owned));
|
|
532
|
+
return __velarAdoptList(output);
|
|
427
533
|
}
|
|
428
534
|
|
|
429
535
|
class __VelarIndexError extends __velarCollectionListNativeRangeError {
|
|
@@ -442,9 +548,20 @@ function __velarStrictListIndex(value, requested) {
|
|
|
442
548
|
return index;
|
|
443
549
|
}
|
|
444
550
|
function __velarListIndexGet(value, index) {
|
|
445
|
-
value =
|
|
551
|
+
value = __velarReactiveRaw(value);
|
|
552
|
+
// The hottest read in the language, so it resolves the tier itself rather
|
|
553
|
+
// than through __velarValidateOwnedList, which would read the owned registry
|
|
554
|
+
// a second time. Past this branch the List is checked: a tier-0 value that
|
|
555
|
+
// full validation adopts as owned was empty, and an empty List has no index
|
|
556
|
+
// to read.
|
|
557
|
+
const tier = __velarListTier(value);
|
|
558
|
+
if (tier === 1) {
|
|
559
|
+
index = __velarStrictListIndex(value, index);
|
|
560
|
+
return __velarReactiveCollectionRead(value, index, __velarOwnedListElement(value, index, "List index"));
|
|
561
|
+
}
|
|
562
|
+
value = __velarValidateListTier(value, "List index", tier);
|
|
446
563
|
index = __velarStrictListIndex(value, index);
|
|
447
|
-
return __velarReactiveCollectionRead(value, index,
|
|
564
|
+
return __velarReactiveCollectionRead(value, index, __velarCheckedListElement(value, index, "List index"));
|
|
448
565
|
}
|
|
449
566
|
function __velarRecordIndexGet(value, index) {
|
|
450
567
|
value = __velarReactiveRaw(value);
|
|
@@ -461,9 +578,9 @@ function __velarOptionalIndex(value, index) {
|
|
|
461
578
|
return value == null ? null : __velarIndex(value, index());
|
|
462
579
|
}
|
|
463
580
|
function __velarListIndexSet(value, index, next) {
|
|
464
|
-
value =
|
|
581
|
+
value = __velarValidateMutableList(value, "List index assignment");
|
|
465
582
|
index = __velarStrictListIndex(value, index);
|
|
466
|
-
const previous =
|
|
583
|
+
const previous = __velarListElement(value, index, "List index assignment", __velarListIsOwned(value));
|
|
467
584
|
next = __velarReactiveRaw(next);
|
|
468
585
|
if (__velarCollectionListObjectIs(__velarReactiveRaw(previous), next)) return next;
|
|
469
586
|
value[index] = next;
|
|
@@ -494,7 +611,7 @@ function __velarSetIndex(value, index, next) {
|
|
|
494
611
|
}
|
|
495
612
|
|
|
496
613
|
function __velarListAppend(value, item) {
|
|
497
|
-
value =
|
|
614
|
+
value = __velarValidateMutableList(value, "List.append");
|
|
498
615
|
if (value.length >= __velarMaxCollectionItems) throw new __velarCollectionListNativeRangeError("A List cannot exceed 1000000 items");
|
|
499
616
|
item = __velarReactiveRaw(item);
|
|
500
617
|
const index = value.length;
|
|
@@ -506,26 +623,31 @@ function __velarListAppend(value, item) {
|
|
|
506
623
|
}
|
|
507
624
|
|
|
508
625
|
function __velarListExtend(value, items) {
|
|
509
|
-
value =
|
|
626
|
+
value = __velarValidateMutableList(value, "List.extend");
|
|
510
627
|
items = __velarValidateOwnedList(items, "List.extend");
|
|
511
628
|
if (value.length + items.length > __velarMaxCollectionItems) throw new __velarCollectionListNativeRangeError("A List cannot exceed 1000000 items");
|
|
512
629
|
const start = value.length;
|
|
513
630
|
const count = items.length;
|
|
514
|
-
|
|
631
|
+
const itemsOwned = __velarListIsOwned(items);
|
|
632
|
+
for (let index = 0; index < count; index += 1) { const item = __velarReactiveRaw(__velarListElement(items, index, "List.extend", itemsOwned)); __velarCollectionListDefineProperty(value, value.length, { value: item, writable: true, enumerable: true, configurable: true }); __velarReactiveCollectionLink(value, item); }
|
|
515
633
|
if (count > 0) __velarReactiveCollectionTrigger(value, start, true, true, start);
|
|
516
634
|
__velarMarkOwnedList(value);
|
|
517
635
|
return null;
|
|
518
636
|
}
|
|
519
637
|
|
|
520
638
|
function __velarListInsert(value, index, item) {
|
|
521
|
-
value =
|
|
639
|
+
value = __velarValidateMutableList(value, "List.insert");
|
|
522
640
|
// COL-I2: every List position error is an IndexError, and the accepted
|
|
523
641
|
// range 0..size (inclusive) is the charter's insert contract.
|
|
524
642
|
if (!__velarCollectionListIsInteger(index) || index < 0 || index > value.length) throw new __VelarIndexError("List.insert index must be an integer from 0 through size");
|
|
525
643
|
if (value.length >= __velarMaxCollectionItems) throw new __velarCollectionListNativeRangeError("A List cannot exceed 1000000 items");
|
|
526
644
|
item = __velarReactiveRaw(item);
|
|
645
|
+
// COL-P1: the tier is read before the new slot lands, because appending it
|
|
646
|
+
// moves the length past the recorded one, and every shift below would then
|
|
647
|
+
// take the descriptor path on a List this runtime wrote in full.
|
|
648
|
+
const owned = __velarListIsOwned(value);
|
|
527
649
|
__velarCollectionListDefineProperty(value, value.length, { value: item, writable: true, enumerable: true, configurable: true });
|
|
528
|
-
for (let cursor = value.length - 1; cursor > index; cursor -= 1) value[cursor] =
|
|
650
|
+
for (let cursor = value.length - 1; cursor > index; cursor -= 1) value[cursor] = __velarListElement(value, cursor - 1, "List.insert", owned);
|
|
529
651
|
value[index] = item;
|
|
530
652
|
__velarMarkOwnedList(value);
|
|
531
653
|
__velarReactiveCollectionLink(value, item);
|
|
@@ -534,30 +656,31 @@ function __velarListInsert(value, index, item) {
|
|
|
534
656
|
}
|
|
535
657
|
|
|
536
658
|
function __velarListPop(value, requested = -1) {
|
|
537
|
-
value =
|
|
659
|
+
value = __velarValidateMutableList(value, "List.pop");
|
|
538
660
|
if (!__velarCollectionListIsInteger(requested)) throw new __VelarIndexError("List.pop index must be an integer");
|
|
539
661
|
const index = requested < 0 ? value.length + requested : requested;
|
|
540
662
|
if (value.length === 0) throw new __VelarIndexError("List.pop requires a non-empty List");
|
|
541
663
|
if (index < 0 || index >= value.length) throw new __VelarIndexError("List.pop index must be an in-range integer");
|
|
542
|
-
const
|
|
543
|
-
|
|
664
|
+
const owned = __velarListIsOwned(value);
|
|
665
|
+
const item = __velarListElement(value, index, "List.pop", owned);
|
|
666
|
+
for (let cursor = index; cursor < value.length - 1; cursor += 1) value[cursor] = __velarListElement(value, cursor + 1, "List.pop", owned);
|
|
544
667
|
value.length -= 1;
|
|
545
668
|
__velarMarkOwnedList(value);
|
|
546
669
|
__velarReactiveCollectionUnlink(value, item);
|
|
547
670
|
__velarReactiveCollectionTrigger(value, index, true, true, index);
|
|
548
671
|
return item;
|
|
549
672
|
}
|
|
550
|
-
function __velarListRemove(value, item) { value = __velarValidateOwnedList(value, "List.remove"); item = __velarReactiveRaw(item); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(
|
|
673
|
+
function __velarListRemove(value, item) { value = __velarValidateOwnedList(value, "List.remove"); item = __velarReactiveRaw(item); const owned = __velarListIsOwned(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(__velarListElement(value, index, "List.remove", owned)), item)) { __velarListPop(value, index); return true; } return false; }
|
|
551
674
|
function __velarListCopy(value) { __velarReactiveCollectionTrack(value); return __velarCopyList(value, "List.copy"); }
|
|
552
|
-
function __velarListCount(value, item) { value = __velarValidateOwnedList(value, "List.count"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); let count = 0; for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(
|
|
675
|
+
function __velarListCount(value, item) { value = __velarValidateOwnedList(value, "List.count"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); const owned = __velarListIsOwned(value); let count = 0; for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(__velarListElement(value, index, "List.count", owned)), item)) count += 1; return count; }
|
|
553
676
|
function __velarListFind(value, predicate) { const items = __velarCopyList(value, "List.find"); __velarReactiveCollectionTrack(value); for (let index = 0; index < items.length; index += 1) { const item = __velarReactiveCollectionRead(value, index, items[index]); const accepted = predicate(item); if (typeof accepted !== "boolean") throw new __velarCollectionNativeTypeError("List.find predicate must return bool"); if (accepted) return item; } return null; }
|
|
554
|
-
function __velarListIndex(value, item) { value = __velarValidateOwnedList(value, "List.index"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(
|
|
677
|
+
function __velarListIndex(value, item) { value = __velarValidateOwnedList(value, "List.index"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); const owned = __velarListIsOwned(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(__velarListElement(value, index, "List.index", owned)), item)) return index; return null; }
|
|
555
678
|
function __velarListSome(value, predicate) { const items = __velarCopyList(value, "List.some"); __velarReactiveCollectionTrack(value); for (let index = 0; index < items.length; index += 1) { const accepted = predicate(__velarReactiveCollectionRead(value, index, items[index])); if (typeof accepted !== "boolean") throw new __velarCollectionNativeTypeError("List.some predicate must return bool"); if (accepted) return true; } return false; }
|
|
556
679
|
function __velarListEvery(value, predicate) { const items = __velarCopyList(value, "List.every"); __velarReactiveCollectionTrack(value); for (let index = 0; index < items.length; index += 1) { const accepted = predicate(__velarReactiveCollectionRead(value, index, items[index])); if (typeof accepted !== "boolean") throw new __velarCollectionNativeTypeError("List.every predicate must return bool"); if (!accepted) return false; } return true; }
|
|
557
|
-
function __velarListMap(value, transform) { const items = __velarCopyList(value, "List.map"); __velarReactiveCollectionTrack(value); const output = new __velarCollectionNativeArray(items.length); for (let index = 0; index < items.length; index += 1) { const item = transform(__velarReactiveCollectionRead(value, index, items[index])); output[index] = item === undefined ? null : __velarReactiveRaw(item); } return
|
|
558
|
-
function __velarListFilter(value, predicate) { const items = __velarCopyList(value, "List.filter"); __velarReactiveCollectionTrack(value); const output = []; for (let index = 0; index < items.length; index += 1) { const item = __velarReactiveCollectionRead(value, index, items[index]); const accepted = predicate(item); if (typeof accepted !== "boolean") throw new __velarCollectionNativeTypeError("List.filter predicate must return bool"); if (accepted) output[output.length] = __velarReactiveRaw(item); } return
|
|
680
|
+
function __velarListMap(value, transform) { const items = __velarCopyList(value, "List.map"); __velarReactiveCollectionTrack(value); const output = new __velarCollectionNativeArray(items.length); for (let index = 0; index < items.length; index += 1) { const item = transform(__velarReactiveCollectionRead(value, index, items[index])); output[index] = item === undefined ? null : __velarReactiveRaw(item); } return __velarAdoptList(output); }
|
|
681
|
+
function __velarListFilter(value, predicate) { const items = __velarCopyList(value, "List.filter"); __velarReactiveCollectionTrack(value); const output = []; for (let index = 0; index < items.length; index += 1) { const item = __velarReactiveCollectionRead(value, index, items[index]); const accepted = predicate(item); if (typeof accepted !== "boolean") throw new __velarCollectionNativeTypeError("List.filter predicate must return bool"); if (accepted) output[output.length] = __velarReactiveRaw(item); } return __velarAdoptList(output); }
|
|
559
682
|
function __velarListReduce(value, combine, initial) { const items = __velarCopyList(value, "List.reduce"); __velarReactiveCollectionTrack(value); let result = initial; for (let index = 0; index < items.length; index += 1) { const next = combine(result, __velarReactiveCollectionRead(value, index, items[index])); result = next === undefined ? null : next; } return result; }
|
|
560
|
-
function __velarListJoin(value, separator = "") { value = __velarValidateOwnedList(value, "List.join"); __velarReactiveCollectionTrack(value); if (typeof separator !== "string") throw new __velarCollectionNativeTypeError("List.join separator must be string"); for (let index = 0; index < value.length; index += 1) if (typeof
|
|
683
|
+
function __velarListJoin(value, separator = "") { value = __velarValidateOwnedList(value, "List.join"); __velarReactiveCollectionTrack(value); if (typeof separator !== "string") throw new __velarCollectionNativeTypeError("List.join separator must be string"); const owned = __velarListIsOwned(value); for (let index = 0; index < value.length; index += 1) if (typeof __velarListElement(value, index, "List.join", owned) !== "string") throw new __velarCollectionNativeTypeError("List.join requires string values"); return __velarCollectionListHostJoin(value, separator); }
|
|
561
684
|
function __velarOrderedListValue(value, name, kind = null) { const current = typeof value; if (current === "number" && __velarCollectionListIsNaN(value)) throw new __velarCollectionNativeTypeError(name + " found NaN, which has no ordering; drop it with filter(x => not x.isNaN()) or fix the upstream computation"); if ((current !== "string" && current !== "number") || (kind !== null && current !== kind)) throw new __velarCollectionNativeTypeError(name + " requires uniform numbers or strings"); return current; }
|
|
562
685
|
function __velarListSorted(value, compare = null, by = null) {
|
|
563
686
|
if (compare !== null && by !== null) throw new __velarCollectionNativeTypeError("List.sorted accepts either a comparator or by, not both");
|
|
@@ -572,7 +695,7 @@ function __velarListSorted(value, compare = null, by = null) {
|
|
|
572
695
|
__velarCollectionListHostSort(decorated, (left, right) => __velarOrderedCompare(kind, left.key, right.key));
|
|
573
696
|
const selected = new __velarCollectionNativeArray(decorated.length);
|
|
574
697
|
for (let index = 0; index < decorated.length; index += 1) selected[index] = decorated[index].item;
|
|
575
|
-
return
|
|
698
|
+
return __velarAdoptList(selected);
|
|
576
699
|
}
|
|
577
700
|
let kind = null;
|
|
578
701
|
if (compare === null) { for (let index = 0; index < output.length; index += 1) kind = __velarOrderedListValue(output[index], "List.sorted()", kind); }
|
|
@@ -594,10 +717,11 @@ function __velarListFlatMap(value, transform) {
|
|
|
594
717
|
for (let index = 0; index < items.length; index += 1) {
|
|
595
718
|
const part = transform(__velarReactiveCollectionRead(value, index, items[index]));
|
|
596
719
|
const values = __velarValidateOwnedList(part, "List.flatMap transform result");
|
|
720
|
+
const partOwned = __velarListIsOwned(values);
|
|
597
721
|
if (output.length + values.length > __velarMaxCollectionItems) throw new __velarCollectionListNativeRangeError("A List cannot exceed 1000000 items");
|
|
598
|
-
for (let cursor = 0; cursor < values.length; cursor += 1) output[output.length] = __velarCollectionValue(__velarReactiveRaw(
|
|
722
|
+
for (let cursor = 0; cursor < values.length; cursor += 1) output[output.length] = __velarCollectionValue(__velarReactiveRaw(__velarListElement(values, cursor, "List.flatMap", partOwned)));
|
|
599
723
|
}
|
|
600
|
-
return
|
|
724
|
+
return __velarAdoptList(output);
|
|
601
725
|
}
|
|
602
726
|
|
|
603
727
|
function __velarSetAdd(value, item) {
|
|
@@ -737,7 +861,7 @@ function __velarRecordCopy(value) {
|
|
|
737
861
|
return output;
|
|
738
862
|
}
|
|
739
863
|
|
|
740
|
-
function __velarListHas(value, item) { value = __velarValidateOwnedList(value, "List.has"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(
|
|
864
|
+
function __velarListHas(value, item) { value = __velarValidateOwnedList(value, "List.has"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); const owned = __velarListIsOwned(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(__velarListElement(value, index, "List.has", owned)), item)) return true; return false; }
|
|
741
865
|
function __velarRecordHas(value, item) { value = __velarReactiveRaw(value); item = __velarReactiveRaw(item); if (typeof item !== "string") throw new __velarCollectionNativeTypeError("Record.has requires a string key"); __velarRecordFields(value, "Record.has"); __velarReactiveCollectionTrack(value, item); return __velarCollectionRecordGetOwnPropertyDescriptor(value, item) !== undefined; }
|
|
742
866
|
function __velarMapHas(value, item) { value = __velarReactiveRaw(value); item = __velarReactiveRaw(item); const size = __velarCheckedMapSize(value, "Map.has"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries"); __velarReactiveCollectionTrack(value, item); return __velarCollectionSetMapMapHas(value, item); }
|
|
743
867
|
function __velarSetHas(value, item) { value = __velarReactiveRaw(value); item = __velarReactiveRaw(item); const size = __velarCheckedSetSize(value, "Set.has"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items"); __velarReactiveCollectionTrack(value, item); return __velarCollectionSetMapSetHas(value, item); }
|
|
@@ -796,8 +920,10 @@ function __velarEqualsVisit(left, right, active, depth) {
|
|
|
796
920
|
__velarReactiveCollectionTrack(leftList);
|
|
797
921
|
__velarReactiveCollectionTrack(rightList);
|
|
798
922
|
if (leftList.length !== rightList.length) return false;
|
|
923
|
+
const leftOwned = __velarListIsOwned(leftList);
|
|
924
|
+
const rightOwned = __velarListIsOwned(rightList);
|
|
799
925
|
for (let index = 0; index < leftList.length; index += 1) {
|
|
800
|
-
if (!__velarEqualsVisit(
|
|
926
|
+
if (!__velarEqualsVisit(__velarListElement(leftList, index, "equals", leftOwned), __velarListElement(rightList, index, "equals", rightOwned), active, depth + 1)) return false;
|
|
801
927
|
}
|
|
802
928
|
return true;
|
|
803
929
|
}
|
|
@@ -966,6 +1092,7 @@ function __velarListClear(value) {
|
|
|
966
1092
|
value = __velarReactiveRaw(value);
|
|
967
1093
|
const previous = __velarCopyList(value, "List.clear");
|
|
968
1094
|
if (previous.length === 0) return null;
|
|
1095
|
+
__velarListRequireMutableLength(value, "List.clear");
|
|
969
1096
|
value.length = 0;
|
|
970
1097
|
__velarMarkOwnedList(value);
|
|
971
1098
|
for (let index = 0; index < previous.length; index += 1) __velarReactiveCollectionUnlink(value, previous[index]);
|
|
@@ -1024,14 +1151,14 @@ function __velarRecordKeys(value) {
|
|
|
1024
1151
|
const fields = __velarRecordFields(value, "Record.keys");
|
|
1025
1152
|
const output = new __velarCollectionNativeArray(fields.length);
|
|
1026
1153
|
for (let index = 0; index < fields.length; index += 1) output[index] = __velarReactiveCollectionRead(value, __velarReactiveStructureKey, fields[index]);
|
|
1027
|
-
return
|
|
1154
|
+
return __velarAdoptList(output);
|
|
1028
1155
|
}
|
|
1029
1156
|
function __velarMapKeys(value) {
|
|
1030
1157
|
value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey);
|
|
1031
1158
|
const size = __velarCheckedMapSize(value, "Map.keys");
|
|
1032
1159
|
if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
|
|
1033
1160
|
const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapKeys(value); let index = 0;
|
|
1034
|
-
while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return
|
|
1161
|
+
while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarAdoptList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveStructureKey, step.value); }
|
|
1035
1162
|
}
|
|
1036
1163
|
function __velarCollectionKeys(value) { value = __velarReactiveRaw(value); return __velarIsRecord(value) ? __velarRecordKeys(value) : __velarMapKeys(value); }
|
|
1037
1164
|
|
|
@@ -1039,19 +1166,19 @@ function __velarRecordValues(value) {
|
|
|
1039
1166
|
value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
|
|
1040
1167
|
const fields = __velarRecordFields(value, "Record.values"); const output = new __velarCollectionNativeArray(fields.length);
|
|
1041
1168
|
for (let index = 0; index < fields.length; index += 1) { const field = fields[index]; output[index] = __velarReactiveCollectionRead(value, field, __velarCollectionRecordGetOwnPropertyDescriptor(value, field).value); }
|
|
1042
|
-
return
|
|
1169
|
+
return __velarAdoptList(output);
|
|
1043
1170
|
}
|
|
1044
1171
|
function __velarMapValues(value) {
|
|
1045
1172
|
value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
|
|
1046
1173
|
const size = __velarCheckedMapSize(value, "Map.values"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
|
|
1047
1174
|
const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapValues(value); let index = 0;
|
|
1048
|
-
while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return
|
|
1175
|
+
while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarAdoptList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveIterateKey, step.value); }
|
|
1049
1176
|
}
|
|
1050
1177
|
function __velarSetValues(value) {
|
|
1051
1178
|
value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
|
|
1052
1179
|
const size = __velarCheckedSetSize(value, "Set.values"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items");
|
|
1053
1180
|
const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapSetValues(value); let index = 0;
|
|
1054
|
-
while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) return
|
|
1181
|
+
while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) return __velarAdoptList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveIterateKey, step.value); }
|
|
1055
1182
|
}
|
|
1056
1183
|
function __velarCollectionValues(value) {
|
|
1057
1184
|
value = __velarReactiveRaw(value);
|
|
@@ -1064,13 +1191,13 @@ function __velarRecordEntries(value) {
|
|
|
1064
1191
|
value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
|
|
1065
1192
|
const fields = __velarRecordFields(value, "Record.entries"); const output = new __velarCollectionNativeArray(fields.length);
|
|
1066
1193
|
for (let index = 0; index < fields.length; index += 1) { const field = fields[index]; output[index] = __velarCollectionRecordFreeze({ key: __velarReactiveCollectionRead(value, __velarReactiveIterateKey, field), value: __velarReactiveCollectionRead(value, field, __velarCollectionRecordGetOwnPropertyDescriptor(value, field).value) }); }
|
|
1067
|
-
return
|
|
1194
|
+
return __velarAdoptList(output);
|
|
1068
1195
|
}
|
|
1069
1196
|
function __velarMapEntries(value) {
|
|
1070
1197
|
value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
|
|
1071
1198
|
const size = __velarCheckedMapSize(value, "Map.entries"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
|
|
1072
1199
|
const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapEntries(value); let index = 0;
|
|
1073
|
-
while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return
|
|
1200
|
+
while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarAdoptList(output); const entry = step.value; output[index++] = __velarCollectionSetMapFreeze({ key: __velarReactiveCollectionRead(value, __velarReactiveIterateKey, entry[0]), value: __velarReactiveCollectionRead(value, entry[0], entry[1]) }); }
|
|
1074
1201
|
}
|
|
1075
1202
|
function __velarCollectionEntries(value) { value = __velarReactiveRaw(value); return __velarIsRecord(value) ? __velarRecordEntries(value) : __velarMapEntries(value); }
|
|
1076
1203
|
function __velarOptionalCollection(value, operation) { return value == null ? null : operation(value); }`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-lowering-runtime.js","sourceRoot":"","sources":["../src/collection-lowering-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E,MAAM,CAAC,MAAM,gCAAgC,GAAG,+CAA+C,CAAC;AAEhG,qEAAqE;AACrE,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,2BAA2B;IAC3B,wBAAwB;IACxB,sBAAsB;IACtB,eAAe;IACf,0BAA0B;IAC1B,6BAA6B;IAC7B,4BAA4B;IAC5B,+BAA+B;IAC/B,+BAA+B;IAC/B,gCAAgC;IAChC,mCAAmC;IACnC,2BAA2B;IAC3B,+BAA+B;IAC/B,iBAAiB;IACjB,yBAAyB;IACzB,mBAAmB;IACnB,wBAAwB;IACxB,kBAAkB;IAClB,kBAAkB;IAClB,uBAAuB;IACvB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,wBAAwB;IACxB,6EAA6E;IAC7E,uEAAuE;IACvE,4EAA4E;IAC5E,0EAA0E;IAC1E,qBAAqB;IACrB,mBAAmB;IACnB,cAAc;IACd,qBAAqB;IACrB,uBAAuB;IACvB,sBAAsB;IACtB,iBAAiB;IACjB,qBAAqB;IACrB,uBAAuB;IACvB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,kBAAkB;IAClB,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;IACjB,mBAAmB;IACnB,qBAAqB;IACrB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,wBAAwB;IACxB,sBAAsB;IACtB,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,qBAAqB;IACrB,kBAAkB;IAClB,mBAAmB;IACnB,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,iBAAiB;IACjB,yBAAyB;IACzB,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;IACrB,wBAAwB;IACxB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,oBAAoB;IACpB,uBAAuB;IACvB,gBAAgB;IAChB,mBAAmB;IACnB,yBAAyB;IACzB,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;IACrB,0BAA0B;IAC1B,mBAAmB;IACnB,sBAAsB;IACtB,2BAA2B;CACnB,CAAC;AAEX,MAAM,CAAC,MAAM,sCAAsC,GAAG;IACpD,4BAA4B;IAC5B,4BAA4B;CACpB,CAAC;AAEX,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"collection-lowering-runtime.js","sourceRoot":"","sources":["../src/collection-lowering-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E,MAAM,CAAC,MAAM,gCAAgC,GAAG,+CAA+C,CAAC;AAEhG,qEAAqE;AACrE,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,2BAA2B;IAC3B,wBAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yGA2jC8C,CAAC;AAE1G,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC,GAAG,CAAA;;EAE/D,6BAA6B,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SAC7D,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC;;;;;;;;;;SAU5C,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC;EACnD,iCAAiC;;EAEjC,iCAAiC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;CAEzE,CAAC,SAAS,EAAE,CAAC"}
|
package/dist/diagnostic.d.ts
CHANGED
|
@@ -34,9 +34,43 @@ export interface Diagnostic {
|
|
|
34
34
|
}
|
|
35
35
|
export declare function diagnostic(code: string, message: string, span: Span, fix?: DiagnosticFix): Diagnostic;
|
|
36
36
|
export declare function recoveredDiagnostic(code: string, message: string, span: Span, fix?: DiagnosticFix): Diagnostic;
|
|
37
|
+
/**
|
|
38
|
+
* D89: the second diagnostic channel. An advisory names a spelling VelarScript
|
|
39
|
+
* accepts with a different meaning than the Python or JavaScript reflex that
|
|
40
|
+
* wrote it, so it can be neither silenced nor rejected. It never blocks code
|
|
41
|
+
* generation: `index.ts` gates emission on `diagnostics.length === 0`, and an
|
|
42
|
+
* advisory is physically incapable of reaching that expression.
|
|
43
|
+
*
|
|
44
|
+
* This is a separate type rather than a `severity` field on `Diagnostic`
|
|
45
|
+
* because the analyzer reads `this.diagnostics.length` as a cursor:
|
|
46
|
+
* `analyzer.ts:3496` and `:3549` hand the length to `reanalyzeLoopBackEdge` as
|
|
47
|
+
* the first diagnostic of a loop body, `:6964`/`:6967` compare two lengths to
|
|
48
|
+
* decide `calleeAlreadyDiagnosed` (which suppresses three reports at `:7058`),
|
|
49
|
+
* `:12573` pairs with `deduplicateDiagnostics`, and `web/analyzer.ts:1063`
|
|
50
|
+
* rewrites message text by index over the same range. Every one of those reads
|
|
51
|
+
* the array's length or index, never the items, so a severity field cannot
|
|
52
|
+
* keep an interleaved advisory from being mistaken for a diagnostic and
|
|
53
|
+
* deleting the real error behind it. Separate arrays make that impossible.
|
|
54
|
+
*
|
|
55
|
+
* The `tier` discriminant is required so TypeScript rejects an advisory passed
|
|
56
|
+
* into any `readonly Diagnostic[]` in the repository, which is what keeps the
|
|
57
|
+
* two channels from merging by accident.
|
|
58
|
+
*/
|
|
59
|
+
export interface Advisory {
|
|
60
|
+
readonly tier: "advisory";
|
|
61
|
+
/** The advisory roster id, e.g. "A1". Deliberately not the VELxxxx family. */
|
|
62
|
+
readonly code: string;
|
|
63
|
+
readonly message: string;
|
|
64
|
+
readonly span: Span;
|
|
65
|
+
/** The mechanical rewrite this advisory names, when it names exactly one. */
|
|
66
|
+
readonly fix?: DiagnosticFix;
|
|
67
|
+
}
|
|
68
|
+
export declare function advisory(code: string, message: string, span: Span, fix?: DiagnosticFix): Advisory;
|
|
37
69
|
/** Builds the one-edit mechanical rewrite of `span` to `text`. */
|
|
38
70
|
export declare function mechanicalFix(span: Span, text: string, title: string): DiagnosticFix;
|
|
39
71
|
/** Builds a mechanical rewrite whose one spelling change needs more than one edit. */
|
|
40
72
|
export declare function mechanicalEdits(edits: readonly DiagnosticEdit[], title: string): DiagnosticFix;
|
|
41
73
|
export declare function formatDiagnostic(source: SourceText, item: Diagnostic): string;
|
|
74
|
+
/** The diagnostic block with `advisory` where the label reads `error`. */
|
|
75
|
+
export declare function formatAdvisory(source: SourceText, item: Advisory): string;
|
|
42
76
|
//# sourceMappingURL=diagnostic.d.ts.map
|
package/dist/diagnostic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,iJAAiJ;IACjJ,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC;CAC9B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM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,GAAG,MAAM,CAEzE"}
|
package/dist/diagnostic.js
CHANGED
|
@@ -4,6 +4,9 @@ export function diagnostic(code, message, span, fix) {
|
|
|
4
4
|
export function recoveredDiagnostic(code, message, span, fix) {
|
|
5
5
|
return fix ? { code, message, span, recovered: true, fix } : { code, message, span, recovered: true };
|
|
6
6
|
}
|
|
7
|
+
export function advisory(code, message, span, fix) {
|
|
8
|
+
return fix ? { tier: "advisory", code, message, span, fix } : { tier: "advisory", code, message, span };
|
|
9
|
+
}
|
|
7
10
|
/** Builds the one-edit mechanical rewrite of `span` to `text`. */
|
|
8
11
|
export function mechanicalFix(span, text, title) {
|
|
9
12
|
return { edits: [{ span, text }], title };
|
|
@@ -13,6 +16,13 @@ export function mechanicalEdits(edits, title) {
|
|
|
13
16
|
return { edits, title };
|
|
14
17
|
}
|
|
15
18
|
export function formatDiagnostic(source, item) {
|
|
19
|
+
return formatReport(source, item, "error");
|
|
20
|
+
}
|
|
21
|
+
/** The diagnostic block with `advisory` where the label reads `error`. */
|
|
22
|
+
export function formatAdvisory(source, item) {
|
|
23
|
+
return formatReport(source, item, "advisory");
|
|
24
|
+
}
|
|
25
|
+
function formatReport(source, item, label) {
|
|
16
26
|
const location = source.location(item.span.start);
|
|
17
27
|
const maximumLine = 240;
|
|
18
28
|
const rawLine = source.lineText(location.line);
|
|
@@ -28,7 +38,7 @@ export function formatDiagnostic(source, item) {
|
|
|
28
38
|
const markerSource = clipped.slice(localColumn, localColumn + Math.max(1, item.span.end - item.span.start));
|
|
29
39
|
const marker = `${" ".repeat(terminalTextWidth(prefix + clipped.slice(0, localColumn)))}${"^".repeat(Math.max(1, terminalTextWidth(markerSource)))}`;
|
|
30
40
|
return [
|
|
31
|
-
`${source.path.replaceAll("\\", "/")}:${location.line}:${location.column}
|
|
41
|
+
`${source.path.replaceAll("\\", "/")}:${location.line}:${location.column} ${label} ${item.code}: ${item.message}`,
|
|
32
42
|
line,
|
|
33
43
|
marker,
|
|
34
44
|
].join("\n");
|