From 5d365b8b08cdf8dd03e3cdf7b395d5e7cfe51dfb Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:52:34 -0800 Subject: [PATCH 1/4] chore(quest): claim quest/m3/ts-refcell-debug.md Quest-Claim: cc1e5a93388463b3 From a18f62061b565cb20495204e8c4ab6b2e4ac238e Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 2 Nov 2026 21:09:02 -0800 Subject: [PATCH 2/4] feat(ts): translate Debug of cells and locks, keeping a held value's effects in order Co-Authored-By: Claude Opus 5.5 --- quest/m3/README.md | 1 - quest/m3/ts-refcell-debug.md | 17 --- ts/README.md | 5 +- .../codec/expected/coding/encode.Encoder.ts | 3 +- ts/fixtures/codec/expected/harness.ts | 3 +- ts/fixtures/lang/arrays/expected/arrays.ts | 17 ++- ts/fixtures/lang/borrows/caller.ts | 10 +- .../lang/borrows/expected/borrows.Shown.ts | 20 ++++ ts/fixtures/lang/borrows/expected/borrows.ts | 102 +++++++++++++++++- .../lang/borrows/expected/core/bool.ts | 7 ++ ts/fixtures/lang/borrows/expected/lib.ts | 4 +- ts/fixtures/lang/borrows/src/borrows.rs | 81 +++++++++++++- ts/fixtures/lang/borrows/src/lib.rs | 1 + .../lang/capacity/expected/capacity.ts | 2 +- .../lang/collections/expected/collections.ts | 2 +- .../lang/conversions/expected/conversions.ts | 62 +++++------ ts/fixtures/lang/cows/expected/cows.ts | 3 +- .../lang/durations/expected/durations.ts | 2 +- ts/fixtures/lang/dyns/expected/dyns.ts | 6 +- ts/fixtures/lang/fields/expected/fields.ts | 3 +- ts/fixtures/lang/heap/expected/heap.ts | 3 +- ts/fixtures/lang/iters/expected/iters.ts | 42 ++++---- ts/fixtures/lang/locks/caller.ts | 5 +- ts/fixtures/lang/locks/expected/lib.ts | 18 ++-- ts/fixtures/lang/locks/expected/locks.ts | 53 +++++++++ ts/fixtures/lang/locks/src/lib.rs | 1 + ts/fixtures/lang/locks/src/locks.rs | 35 +++++- ts/fixtures/lang/nested/expected/nested.ts | 3 +- ts/fixtures/lang/refs/expected/refs.ts | 3 +- ts/fixtures/lang/shapes/expected/fmt.ts | 15 ++- ts/fixtures/lang/shapes/expected/shapes.ts | 3 +- ts/fixtures/lang/slices/expected/slices.ts | 35 +++--- ts/fixtures/lang/strs/expected/strs.ts | 3 +- ts/fixtures/stock/expected/buf.ts | 57 ++++------ ts/runtime/rt/task.ts | 29 ++++- ts/src/lower/fmt.rs | 15 +++ ts/src/lower/mir/mod.rs | 8 +- 37 files changed, 489 insertions(+), 190 deletions(-) delete mode 100644 quest/m3/ts-refcell-debug.md create mode 100644 ts/fixtures/lang/borrows/expected/borrows.Shown.ts diff --git a/quest/m3/README.md b/quest/m3/README.md index df312b5ab..23a5c612f 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -22,7 +22,6 @@ generic std gap is planned here even when moq never calls it. - [bytes' Chain as a Buf object](/quest/m3/ts-buf-chain.md) - `Chain::copy_to_bytes` across both halves translates, and with it a `Chain` as a `dyn Buf` - [A Buf object's size](/quest/m3/ts-dyn-buf-size.md) - a `dyn Buf` object holds only the methods some call dispatches to - [A boxed iterator folds as std's box does](/quest/m3/ts-box-folds.md) - a `Box` reads by `next` where std's `Iterator` for `Box` forwards nothing else -- [Debug of a RefCell or a Cell](/quest/m3/ts-refcell-debug.md) - `{:?}` of a `RefCell`, `Ref`, `RefMut`, and `Cell` translates as std's writes them - [Placeholders written to a crate's own fmt::Write](/quest/m3/ts-fmt-calls.md) - `write!` with placeholders into a crate's own writer translates, its `write_str` seeing each call std makes - [Waiting: drop the lang fixture's mul_add allowance](/quest/m3/ts-fma-allowance.md) - the differential fails on any `mul_add` difference again once wasm32's `fma` rounds exactly - [Waiting: type-check in process with tsrs](/quest/m3/ts-tsrs.md) - rust2-ts checks bindings through tsrs instead of `tsc` once it is a stable library diff --git a/quest/m3/ts-refcell-debug.md b/quest/m3/ts-refcell-debug.md deleted file mode 100644 index 45cc894a6..000000000 --- a/quest/m3/ts-refcell-debug.md +++ /dev/null @@ -1,17 +0,0 @@ -# [XS] Debug of a RefCell or a Cell - -## Goal - -[rust2-ts](/ts/README.md) translates `{:?}` of a `RefCell` and its `Ref` and `RefMut`, -writing `RefCell { value: .. }` and `` while mutably borrowed as std's does, and -of a `Cell` of a `Copy` value, writing `Cell { value: .. }`, proven by a differential test -against native Rust. - -## Plan - -Found writing [`Box`](https://github.com/moq-dev/rust2/pull/445): it is an -"unsupported call to `> as Debug>::fmt`". `Cell`'s, found writing -[`&mut dyn Debug`](https://github.com/moq-dev/rust2/pull/453), is the same; the -maintainer chose on 2026-11-02 to cover both here. - -Public API: the translator's output. diff --git a/ts/README.md b/ts/README.md index 9c11e89fa..50a00a375 100644 --- a/ts/README.md +++ b/ts/README.md @@ -258,7 +258,10 @@ and of their iterators and `Chars` the items each has left, in std's wrapper; a swap them, and its `Drain` its counts; a list's `Iter` and `IterMut` write what is left and its length, as std's do. `Debug` of `Bound`, `Ordering`, `Reverse`, and `ControlFlow` is their derived one, whichever way each is held, and a guard of a cell or a lock, mapped or -not, writes what it lends by its own `Debug` and `Display`. A caller prints a +not, writes what it lends by its own `Debug` and `Display`. `Debug` of a `Cell`, a +`RefCell`, a `Mutex`, and an `RwLock` writes what each holds, or `` and +`` while a guard keeps it from being read, as std's do; an `UnsafeCell` writes only +its name. A caller prints a `printable` type as `to_string()` and `format!("{err:?}")` would: `rt.fmtToString((f) => DecodeError.fmt$fmt_Display(err, f))` and `rt.fmtFormat([(f) => DecodeError.fmt$fmt_Debug(err, f)])`, after diff --git a/ts/fixtures/codec/expected/coding/encode.Encoder.ts b/ts/fixtures/codec/expected/coding/encode.Encoder.ts index 141dc3be7..345bffb38 100644 --- a/ts/fixtures/codec/expected/coding/encode.Encoder.ts +++ b/ts/fixtures/codec/expected/coding/encode.Encoder.ts @@ -128,8 +128,7 @@ export function fill(self: Encoder, prefix: Prefix.Prefix): rt.Result = rt.stringFromUtf8(rt.byteSliceToByteVec(rt.byteSliceFrom(rt.u64ToBeBytes(value)))); diff --git a/ts/fixtures/lang/arrays/expected/arrays.ts b/ts/fixtures/lang/arrays/expected/arrays.ts index 1a318d622..65bbd0832 100644 --- a/ts/fixtures/lang/arrays/expected/arrays.ts +++ b/ts/fixtures/lang/arrays/expected/arrays.ts @@ -695,8 +695,8 @@ export function givenN$0(data: rt.ByteSlice, out: rt.ByteVec): void { _173.v = 238; } put$0(out, [copy$array_u8(b)]); - const _192: rt.ByteSlice = rt.byteSliceFrom(a); const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + const _192: rt.ByteSlice = rt.byteSliceFrom(a); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => { @@ -750,9 +750,8 @@ export function givenN$1(data: rt.ByteSlice, out: rt.ByteVec): void { const swapped2 = rt.byteSliceToArray(_50); _50.data.set(rt.byteSliceToArray(_52), _50.start); _52.data.set(swapped2, _52.start); - const at2 = rt.idx(v, 2); + const _54: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 2)]); const _56: Uint8Array = copy$array_u8(b); - const _54: rt.ByteSlice = rt.byteSliceFrom(v[at2]); const old3 = rt.byteSliceToArray(_54); _54.data.set(_56, _54.start); const old: Uint8Array = old3; @@ -813,8 +812,8 @@ export function givenN$1(data: rt.ByteSlice, out: rt.ByteVec): void { _173.v = 238; } put$1(out, [copy$array_u8(b)]); - const _192: rt.ByteSlice = rt.byteSliceFrom(a); const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + const _192: rt.ByteSlice = rt.byteSliceFrom(a); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => { @@ -868,9 +867,8 @@ export function givenN$3(data: rt.ByteSlice, out: rt.ByteVec): void { const swapped2 = rt.byteSliceToArray(_50); _50.data.set(rt.byteSliceToArray(_52), _50.start); _52.data.set(swapped2, _52.start); - const at2 = rt.idx(v, 2); + const _54: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 2)]); const _56: Uint8Array = copy$array_u8(b); - const _54: rt.ByteSlice = rt.byteSliceFrom(v[at2]); const old3 = rt.byteSliceToArray(_54); _54.data.set(_56, _54.start); const old: Uint8Array = old3; @@ -931,8 +929,8 @@ export function givenN$3(data: rt.ByteSlice, out: rt.ByteVec): void { _173.v = 238; } put$3(out, [copy$array_u8(b)]); - const _192: rt.ByteSlice = rt.byteSliceFrom(a); const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + const _192: rt.ByteSlice = rt.byteSliceFrom(a); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => { @@ -986,9 +984,8 @@ export function givenN$40(data: rt.ByteSlice, out: rt.ByteVec): void { const swapped2 = rt.byteSliceToArray(_50); _50.data.set(rt.byteSliceToArray(_52), _50.start); _52.data.set(swapped2, _52.start); - const at2 = rt.idx(v, 2); + const _54: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 2)]); const _56: Uint8Array = copy$array_u8(b); - const _54: rt.ByteSlice = rt.byteSliceFrom(v[at2]); const old3 = rt.byteSliceToArray(_54); _54.data.set(_56, _54.start); const old: Uint8Array = old3; @@ -1049,8 +1046,8 @@ export function givenN$40(data: rt.ByteSlice, out: rt.ByteVec): void { _173.v = 238; } put$40(out, [copy$array_u8(b)]); - const _192: rt.ByteSlice = rt.byteSliceFrom(a); const _190: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + const _192: rt.ByteSlice = rt.byteSliceFrom(a); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_192), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(_190, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); if (isSomeAnd$09tpccf(rt.byteSliceFirst(data), (d2: rt.u8): boolean => { diff --git a/ts/fixtures/lang/borrows/caller.ts b/ts/fixtures/lang/borrows/caller.ts index cae44a6b8..972de77cd 100644 --- a/ts/fixtures/lang/borrows/caller.ts +++ b/ts/fixtures/lang/borrows/caller.ts @@ -49,4 +49,12 @@ const leaks = [[0x00, 0x01, 0x02, 0xf1, 0xf2, 0x04, 0x05, 0x03, 0x06], [0xe3], [ Uint8Array.of(...op("borrows::leaks"), 0, ...bytes), ); -export const cases: Uint8Array[] = [...guards, ...maps, ...tries, ...leaks]; +/** + * `borrows::printed` scripts: each cell printed, free, shared, and borrowed exclusively, + * nested and through guards, more than once so that what each holds grows. + */ +const printed = [[0x00, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x18, 0xf1, 0x12, 0xfb, 0x24, 0x2d], []].map((bytes) => + Uint8Array.of(...op("borrows::printed"), 0, ...bytes), +); + +export const cases: Uint8Array[] = [...guards, ...maps, ...tries, ...leaks, ...printed]; diff --git a/ts/fixtures/lang/borrows/expected/borrows.Shown.ts b/ts/fixtures/lang/borrows/expected/borrows.Shown.ts new file mode 100644 index 000000000..48a06186b --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/borrows.Shown.ts @@ -0,0 +1,20 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; + +export function fmt$fmt_Debug(self: Shown, f: rt.Formatter): rt.Result { + const _3: string = "Shown"; + const _4: string = "cell"; + const _5: rt.Fmt = (f: rt.Formatter) => rt.cellDebug(self.cell, f, rt.u8Debug); + const _7: string = "refcell"; + const _8: rt.Fmt = (f: rt.Formatter) => rt.refCellDebug(self.refcell, f, (value: rt.ByteVec, f: rt.Formatter) => rt.fmtList(rt.byteVecView(value), f, rt.u8Debug)); + return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); +} + +/** What a derived `Debug` writes each cell of as its field. */ +export interface Shown { + cell: rt.Cell; + refcell: rt.RefCell; +} + +//# sourceMappingURL=borrows.Shown.ts.map diff --git a/ts/fixtures/lang/borrows/expected/borrows.ts b/ts/fixtures/lang/borrows/expected/borrows.ts index 7ddb438eb..7a13c1354 100644 --- a/ts/fixtures/lang/borrows/expected/borrows.ts +++ b/ts/fixtures/lang/borrows/expected/borrows.ts @@ -5,8 +5,9 @@ import { copy$Option_tuple2_u64_u64, copy$tuple2_u64_u64, drop$Result_cell_RefMu import * as Noisy from "./borrows.Noisy.ts"; import * as Parts from "./borrows.Parts.ts"; import * as Polling from "./borrows.Polling.ts"; +import * as Shown from "./borrows.Shown.ts"; import * as Tagged from "./borrows.Tagged.ts"; -import { thenSome$0zrlsto, then$1jgls7y } from "./core/bool.ts"; +import { thenSome$0zrlsto, thenSome$0d5am30, then$1jgls7y } from "./core/bool.ts"; import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, mapOr$0qqbaqw as option_mapOr$0qqbaqw, mapOr$1dvn0au as option_mapOr$1dvn0au, mapOr$0ucbp7g as option_mapOr$0ucbp7g, mapOr$099335t as option_mapOr$099335t, okOr$1oufq9m as option_okOr$1oufq9m } from "./core/option.ts"; import { map$0n1xnuw as result_map$0n1xnuw, unwrapOr$0k9nfhn as result_unwrapOr$0k9nfhn } from "./core/result.ts"; @@ -1068,4 +1069,103 @@ export function flush(log: rt.Mutex, out: rt.ByteVec): void { rt.mutexUnlock(log2); } +/** + * Each byte an operation on cells printed by `Debug`, its value the operand: a `RefCell` + * free, shared, and borrowed exclusively, which writes `` with no options, plain, + * pretty, padded, and as a `&dyn Debug`; cells nested in cells, a vector, and a derived + * `Debug`; guards of cells, which write the cell they lend; and `Cell`s of `Copy` values + * and an `UnsafeCell`. + */ +export function printed(data: rt.ByteSlice, out: rt.ByteVec): void { + let text!: string; + const number: rt.RefCell = new rt.RefCell(0); + const nested: rt.RefCell[]> = new rt.RefCell([new rt.RefCell(0)]); + const pair: rt.Cell<[rt.u8, rt.char]> = new rt.Cell([0, 97] as [rt.u8, rt.char]); + const shown: Shown.Shown = { cell: new rt.Cell(0), refcell: new rt.RefCell(new rt.ByteVec()) }; + for (const op of rt.byteSliceView(data)) { + const v: rt.u8 = op >> 3; + const _25: rt.u8 = rt.u8Rem(op, 8); + if (_25 === 0) { + const _27: rt.u32 = v as rt.u32; + const _30: rt.RefCell = rt.refCellBorrowMut(number); + _30.value = rt.u32Add(_30.value, _27); + rt.refMutRelease(_30); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(number, f, rt.u32Debug)]; + const free: string = rt.fmtFormat([args2[0], " ", rt.fmtSpec({ alternate: true }, args2[0]), " ", rt.fmtSpec({ align: ">", width: 4 }, args2[0])]); + const shared: rt.RefCell = rt.refCellBorrow(number); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(number, f, rt.u32Debug)]; + const read: string = rt.fmtFormat([args4[0]]); + rt.refRelease(shared); + const _held: rt.RefCell = rt.refCellBorrowMut(number); + const dynamic: rt.Fmt = (f: rt.Formatter) => rt.refCellDebug(number, f, rt.u32Debug); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free), (f: rt.Formatter) => rt.fmtPad(f, read), (f: rt.Formatter) => rt.refCellDebug(number, f, rt.u32Debug), (f: rt.Formatter) => dynamic(f)]; + text = rt.fmtFormat([args6[0], " ", args6[1], " ", args6[2], " ", rt.fmtSpec({ alternate: true }, args6[2]), " ", rt.fmtSpec({ align: ">", width: 16 }, args6[2]), " ", args6[3]]); + rt.refMutRelease(_held); + } else if (_25 === 1) { + const _75: rt.RefCell[]> = rt.refCellBorrowMut(nested); + const _77: rt.RefCell = new rt.RefCell(thenSome$0d5am30(rt.u8Rem(v, 3) !== 0, v)); + _75.value.push(_77); + rt.refMutRelease(_75); + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(nested, f, (value: rt.RefCell[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.RefCell, f: rt.Formatter) => rt.refCellDebug(value, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))))]; + const free2: string = rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[0])]); + const cells: rt.RefCell[]> = rt.refCellBorrow(nested); + const _95: rt.RefCell[] = cells.value; + const _inner: rt.RefCell = rt.refCellBorrowMut(_95[rt.idx(_95, rt.usizeSub(cells.value.length, 1))]); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free2), (f: rt.Formatter) => rt.refCellDebug(nested, f, (value: rt.RefCell[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.RefCell, f: rt.Formatter) => rt.refCellDebug(value, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))))]; + text = rt.fmtFormat([args10[0], " ", args10[1], " ", rt.fmtSpec({ alternate: true }, args10[1])]); + rt.refMutRelease(_inner); + rt.refRelease(cells); + } else if (_25 === 2) { + const outer: rt.RefCell> = new rt.RefCell(new rt.RefCell(v)); + const shared2: rt.RefCell> = rt.refCellBorrow(outer); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(shared2.value, f, rt.u8Debug)]; + const free3: string = rt.fmtFormat([args12[0], " ", rt.fmtSpec({ alternate: true }, args12[0])]); + rt.refRelease(shared2); + const exclusive: rt.RefCell> = rt.refCellBorrowMut(outer); + const inner: rt.RefCell = rt.refCellBorrowMut(exclusive.value); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(exclusive.value, f, rt.u8Debug), (f: rt.Formatter) => rt.refCellDebug(outer, f, (value: rt.RefCell, f: rt.Formatter) => rt.refCellDebug(value, f, rt.u8Debug)), (f: rt.Formatter) => rt.u8Debug(inner.value, f)]; + const held: string = rt.fmtFormat([args14[0], " ", rt.fmtSpec({ alternate: true }, args14[0]), " ", args14[1], " ", args14[2]]); + rt.refMutRelease(inner); + const _146: rt.RefCell[]> = rt.refCellBorrow(nested); + const last: rt.RefCell> = rt.refMap(_146, ((n: rt.RefCell[]): rt.RefCell => { + return n[rt.idx(n, 0)]; + })(_146.value)); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free3), (f: rt.Formatter) => rt.fmtPad(f, held), (f: rt.Formatter) => rt.refCellDebug(exclusive.value, f, rt.u8Debug), (f: rt.Formatter) => rt.refCellDebug(last.value, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))]; + text = rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " ", args16[3]]); + rt.refRelease(last); + rt.refMutRelease(exclusive); + } else if (_25 === 3) { + const _164: [rt.u8, rt.char] = [rt.u8WrappingAdd(pair.v[0], v), rt.u8Add(97, rt.u8Rem(v, 26)) as rt.char]; + rt.cellSet(pair, _164); + const wide: rt.Cell = new rt.Cell(rt.u64Shl(v as rt.u64, 56)); + const maybe: rt.Cell = new rt.Cell(thenSome$0d5am30(rt.u8Rem(v, 2) === 0, v)); + const _184: rt.Cell = new rt.Cell(undefined); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.cellDebug(pair, f, (value: [rt.u8, rt.char], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.fmtCharDebug(value[1], f)], f)), (f: rt.Formatter) => rt.cellDebug(wide, f, rt.u64Debug), (f: rt.Formatter) => rt.cellDebug(maybe, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug)), (f: rt.Formatter) => rt.cellDebug(_184, f, rt.fmtUnit)]; + text = rt.fmtFormat([args18[0], " ", rt.fmtSpec({ alternate: true }, args18[0]), " ", args18[1], " ", args18[2], " ", rt.fmtSpec({ alternate: true }, args18[2]), " ", args18[3], " ", rt.fmtSpec({ align: ">", width: 3 }, args18[0])]); + } else if (_25 === 4) { + rt.cellSet(shown.cell, v); + const _204: rt.RefCell = rt.refCellBorrowMut(shown.refcell); + rt.byteVecPush(_204.value, v); + rt.refMutRelease(_204); + const args20: rt.Fmt[] = [(f: rt.Formatter) => Shown.fmt$fmt_Debug(shown, f)]; + const free4: string = rt.fmtFormat([args20[0], " ", rt.fmtSpec({ alternate: true }, args20[0])]); + const _held2: rt.RefCell = rt.refCellBorrowMut(shown.refcell); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free4), (f: rt.Formatter) => Shown.fmt$fmt_Debug(shown, f)]; + text = rt.fmtFormat([args22[0], " ", args22[1], " ", rt.fmtSpec({ alternate: true }, args22[1])]); + rt.refMutRelease(_held2); + } else if (_25 === 5) { + new rt.Cell(v); + const inRefcell: rt.RefCell> = new rt.RefCell(new rt.Cell(v)); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, "UnsafeCell { .. }"), (f: rt.Formatter) => rt.refCellDebug(inRefcell, f, (value: rt.Cell, f: rt.Formatter) => rt.cellDebug(value, f, rt.u8Debug))]; + text = rt.fmtFormat([args24[0], " ", rt.fmtSpec({ alternate: true }, args24[0]), " ", args24[1], " ", rt.fmtSpec({ alternate: true }, args24[1])]); + } else { + const _244: rt.RefCell = new rt.RefCell("s"); + const _247: rt.RefCell = new rt.RefCell(rt.bytes(2).fill(v)); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(_244, f, rt.fmtStr), (f: rt.Formatter) => rt.refCellDebug(_247, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; + text = rt.fmtFormat([args26[0], " ", args26[1]]); + } + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(text)); + } +} + //# sourceMappingURL=borrows.ts.map diff --git a/ts/fixtures/lang/borrows/expected/core/bool.ts b/ts/fixtures/lang/borrows/expected/core/bool.ts index 31890c18b..b5044cb9b 100644 --- a/ts/fixtures/lang/borrows/expected/core/bool.ts +++ b/ts/fixtures/lang/borrows/expected/core/bool.ts @@ -10,6 +10,13 @@ export function thenSome$0zrlsto(self: boolean, t: rt.ByteSlice): rt.ByteSlice | return t; } +export function thenSome$0d5am30(self: boolean, t: rt.u8): rt.u8 | undefined { + if (!self) { + return undefined; + } + return t; +} + export function then$1jgls7y(self: boolean, f: () => rt.RefCell): rt.RefCell | undefined { if (!self) { return undefined; diff --git a/ts/fixtures/lang/borrows/expected/lib.ts b/ts/fixtures/lang/borrows/expected/lib.ts index f46442981..d1b91b55d 100644 --- a/ts/fixtures/lang/borrows/expected/lib.ts +++ b/ts/fixtures/lang/borrows/expected/lib.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { borrows, guards, maps, tries, leaks } from "./borrows.ts"; +import { borrows, guards, maps, tries, leaks, printed } from "./borrows.ts"; import type * as Parts from "./borrows.Parts.ts"; import type * as Tagged from "./borrows.Tagged.ts"; @@ -181,6 +181,8 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) tries(data4, out4); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::leaks", (_26: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { leaks(data5, out5); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::printed", (_27: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + printed(data6, out6); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; } diff --git a/ts/fixtures/lang/borrows/src/borrows.rs b/ts/fixtures/lang/borrows/src/borrows.rs index 5aaba630e..ab154c221 100644 --- a/ts/fixtures/lang/borrows/src/borrows.rs +++ b/ts/fixtures/lang/borrows/src/borrows.rs @@ -5,7 +5,8 @@ //! cloned guards, each released as it drops; guards mapped, filtered, and split to parts //! JS copies and parts it doesn't, written through, released as the last drops; and //! guards tried on their parts, given back beside an error, and printed; and guards leaked, -//! which keep the cell borrowed until `undo_leak`, and mapped to the whole of its bytes. +//! which keep the cell borrowed until `undo_leak`, and mapped to the whole of its bytes; +//! and each cell printed by `Debug`, borrowed or not. use std::cell::{Cell, Ref, RefCell, RefMut}; use std::sync::{Arc, Mutex}; @@ -719,3 +720,81 @@ fn flush(log: &Mutex>, out: &mut Vec) { out.extend_from_slice(&log); log.clear(); } + +/// What a derived `Debug` writes each cell of as its field. +#[derive(Debug)] +struct Shown { + cell: Cell, + refcell: RefCell>, +} + +/// Each byte an operation on cells printed by `Debug`, its value the operand: a `RefCell` +/// free, shared, and borrowed exclusively, which writes `` with no options, plain, +/// pretty, padded, and as a `&dyn Debug`; cells nested in cells, a vector, and a derived +/// `Debug`; guards of cells, which write the cell they lend; and `Cell`s of `Copy` values +/// and an `UnsafeCell`. +pub fn printed(data: &[u8], out: &mut Vec) { + let number = RefCell::new(0u32); + let nested = RefCell::new(vec![RefCell::new(Some(0u8))]); + let pair = Cell::new((0u8, 'a')); + let shown = Shown { + cell: Cell::new(0), + refcell: RefCell::new(Vec::new()), + }; + for &op in data { + let v = op >> 3; + let text = match op % 8 { + 0 => { + *number.borrow_mut() += u32::from(v); + let free = format!("{number:?} {number:#?} {number:>4?}"); + let shared = number.borrow(); + let read = format!("{number:?}"); + drop(shared); + let _held = number.borrow_mut(); + let dynamic: &dyn std::fmt::Debug = &number; + format!("{free} {read} {number:?} {number:#?} {number:>16?} {dynamic:?}") + } + 1 => { + nested.borrow_mut().push(RefCell::new((v % 3 != 0).then_some(v))); + let free = format!("{nested:?} {nested:#?}"); + let cells = nested.borrow(); + let _inner = cells[cells.len() - 1].borrow_mut(); + format!("{free} {nested:?} {nested:#?}") + } + // A guard writes the cell it lends, borrowed or not. + 2 => { + let outer = RefCell::new(RefCell::new(v)); + let shared = outer.borrow(); + let free = format!("{shared:?} {shared:#?}"); + drop(shared); + let exclusive = outer.borrow_mut(); + let inner = exclusive.borrow_mut(); + let held = format!("{exclusive:?} {exclusive:#?} {outer:?} {inner:?}"); + drop(inner); + let last = Ref::map(nested.borrow(), |n| &n[0]); + format!("{free} {held} {exclusive:?} {last:?}") + } + 3 => { + pair.set((pair.get().0.wrapping_add(v), char::from(b'a' + v % 26))); + let wide = Cell::new(u64::from(v) << 56); + let maybe = Cell::new((v % 2 == 0).then_some(v)); + let unit = Cell::new(()); + format!("{pair:?} {pair:#?} {wide:?} {maybe:?} {maybe:#?} {unit:?} {pair:>3?}") + } + 4 => { + shown.cell.set(v); + shown.refcell.borrow_mut().push(v); + let free = format!("{shown:?} {shown:#?}"); + let _held = shown.refcell.borrow_mut(); + format!("{free} {shown:?} {shown:#?}") + } + 5 => { + let unsafe_cell = std::cell::UnsafeCell::new(v); + let in_refcell = RefCell::new(Cell::new(v)); + format!("{unsafe_cell:?} {unsafe_cell:#?} {in_refcell:?} {in_refcell:#?}") + } + _ => format!("{:?} {:?}", RefCell::new(String::from("s")), RefCell::new([v; 2])), + }; + out.extend_from_slice(text.as_bytes()); + } +} diff --git a/ts/fixtures/lang/borrows/src/lib.rs b/ts/fixtures/lang/borrows/src/lib.rs index fb6e38a40..6902102ac 100644 --- a/ts/fixtures/lang/borrows/src/lib.rs +++ b/ts/fixtures/lang/borrows/src/lib.rs @@ -23,5 +23,6 @@ fn cases() -> Vec<(&'static str, Case)> { ("borrows::maps", |_, data, out| borrows::maps(data, out)), ("borrows::tries", |_, data, out| borrows::tries(data, out)), ("borrows::leaks", |_, data, out| borrows::leaks(data, out)), + ("borrows::printed", |_, data, out| borrows::printed(data, out)), ] } diff --git a/ts/fixtures/lang/capacity/expected/capacity.ts b/ts/fixtures/lang/capacity/expected/capacity.ts index ab2960473..4cc1059dd 100644 --- a/ts/fixtures/lang/capacity/expected/capacity.ts +++ b/ts/fixtures/lang/capacity/expected/capacity.ts @@ -2004,9 +2004,9 @@ export function maps(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } let m: rt.HashMap = _8[0]; let s: rt.HashSet = _8[1]; + const floor: rt.usize = rt.usizeMul(made, (kind & 1) as rt.usize); const _22: rt.usize[] = [rt.hashLen(m), rt.hashLen(s)]; const _27: rt.usize[] = [rt.hashCapacity(m), rt.hashCapacity(s)]; - const floor: rt.usize = rt.usizeMul(made, (kind & 1) as rt.usize); _18(out, _22, _27, Array.from({ length: 2 }, (): rt.usize => { return floor; })); diff --git a/ts/fixtures/lang/collections/expected/collections.ts b/ts/fixtures/lang/collections/expected/collections.ts index 9b7e259b8..f92d23246 100644 --- a/ts/fixtures/lang/collections/expected/collections.ts +++ b/ts/fixtures/lang/collections/expected/collections.ts @@ -1727,9 +1727,9 @@ export function optionals(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi } else { read = rt.entryOrInsertMut(rt.entry(map, k), undefined as rt.u8 | undefined).v; } - const _56: rt.u8 | undefined | rt.None = read; const _50: rt.u8 | undefined = option_flatten$1nwzx42(read); const _53: boolean = rt.hashContains(map, k); + const _56: rt.u8 | undefined | rt.None = read; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_56, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug), rt.None), (f: rt.Formatter) => rt.fmtOption(_50, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtBool(_53, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " "]))); } diff --git a/ts/fixtures/lang/conversions/expected/conversions.ts b/ts/fixtures/lang/conversions/expected/conversions.ts index f5af8959a..20de2a978 100644 --- a/ts/fixtures/lang/conversions/expected/conversions.ts +++ b/ts/fixtures/lang/conversions/expected/conversions.ts @@ -517,8 +517,8 @@ export function writeFirst$array0_u8(s: Uint8Array[], value: Uint8Array): Uint8A export function writeFirst$array1_u8(s: Uint8Array[], value: Uint8Array): Uint8Array { value = copy$array_u8(value); rt.idx(s, 0); - const _8: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); const _3: rt.ByteSlice = rt.byteSliceFrom(s[0]); + const _8: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); const old2 = rt.byteSliceToArray(_3); _3.data.set(_8, _3.start); const old: Uint8Array = old2; @@ -546,8 +546,8 @@ export function writeFirst$array2_u32(s: rt.u32[][], value: rt.u32[]): rt.u32[] export function writeFirst$array3_u8(s: Uint8Array[], value: Uint8Array): Uint8Array { value = copy$array_u8(value); rt.idx(s, 0); - const _8: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); const _3: rt.ByteSlice = rt.byteSliceFrom(s[0]); + const _8: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); const old2 = rt.byteSliceToArray(_3); _3.data.set(_8, _3.start); const old: Uint8Array = old2; @@ -561,8 +561,8 @@ export function writeFirst$array3_u8(s: Uint8Array[], value: Uint8Array): Uint8A export function writeFirst$array40_u8(s: Uint8Array[], value: Uint8Array): Uint8Array { value = copy$array_u8(value); rt.idx(s, 0); - const _8: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); const _3: rt.ByteSlice = rt.byteSliceFrom(s[0]); + const _8: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); const old2 = rt.byteSliceToArray(_3); _3.data.set(_8, _3.start); const old: Uint8Array = old2; @@ -1018,8 +1018,8 @@ export function converted$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { const a: Uint8Array = copy$array_u8(make$conversions_Value_array0_u8(data, 0)); const b: Uint8Array = make$conversions_Value_array0_u8(data, 3); const owned: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(a)); - const _9: rt.ByteSlice = rt.byteSliceFrom(b); const _8: rt.ByteSlice = rt.byteSliceFrom(a); + const _9: rt.ByteSlice = rt.byteSliceFrom(b); _8.data.set(rt.byteSliceToArray(_9), _8.start); put$conversions_Value_array0_u8(rt.byteSliceFrom(owned), out); put$conversions_Value_array0_u8(rt.byteSliceFrom(a), out); @@ -1033,13 +1033,12 @@ export function converted$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { put$conversions_Value_array0_u8(rt.byteSliceFrom(c), out); put$conversions_Value_array0_u8(rt.byteSliceFrom(a), out); const held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array0_u8(data, 1))); - const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); + const _34: rt.ByteSlice = rt.byteSliceFrom(c); _33.data.set(rt.byteSliceToArray(_34), _33.start); const v: Uint8Array[] = copy$array_array0_u8([make$conversions_Value_array0_u8(data, 2), make$conversions_Value_array0_u8(data, 4)]).map(copy$array_u8); - const at = rt.idx(v, 1); + const _40: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 1)]); const _42: rt.ByteSlice = rt.byteSliceFrom(held.value); - const _40: rt.ByteSlice = rt.byteSliceFrom(v[at]); _40.data.set(rt.byteSliceToArray(_42), _40.start); const _44: rt.ByteSlice = rt.byteSliceFrom(b); const _45: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 0)]); @@ -1051,8 +1050,8 @@ export function converted$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, one.length & 0xff); const copied: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(one[0])); put$conversions_Value_array0_u8(rt.byteSliceFrom(one[0]), out); - const _71: rt.ByteSlice = rt.byteSliceFrom(copied); const _70: rt.ByteSlice = rt.byteSliceFrom(a); + const _71: rt.ByteSlice = rt.byteSliceFrom(copied); _70.data.set(rt.byteSliceToArray(_71), _70.start); put$conversions_Value_array0_u8(rt.byteSliceFrom(copied), out); put$conversions_Value_array0_u8(rt.byteSliceFrom(a), out); @@ -1075,8 +1074,8 @@ export function converted$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { _116[0] = _114; const _124: Uint8Array[] = array; rt.idx(_124, 2); - const _130: rt.ByteSlice = rt.byteSliceFrom(c); const _123: rt.ByteSlice = rt.byteSliceFrom(_124[2]); + const _130: rt.ByteSlice = rt.byteSliceFrom(c); _123.data.set(rt.byteSliceToArray(_130), _123.start); const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); while (true) { @@ -1097,8 +1096,8 @@ export function converted$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { const a: Uint8Array = copy$array_u8(make$conversions_Value_array1_u8(data, 0)); const b: Uint8Array = make$conversions_Value_array1_u8(data, 3); const owned: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(a)); - const _9: rt.ByteSlice = rt.byteSliceFrom(b); const _8: rt.ByteSlice = rt.byteSliceFrom(a); + const _9: rt.ByteSlice = rt.byteSliceFrom(b); _8.data.set(rt.byteSliceToArray(_9), _8.start); put$conversions_Value_array1_u8(rt.byteSliceFrom(owned), out); put$conversions_Value_array1_u8(rt.byteSliceFrom(a), out); @@ -1112,13 +1111,12 @@ export function converted$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); put$conversions_Value_array1_u8(rt.byteSliceFrom(a), out); const held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array1_u8(data, 1))); - const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); + const _34: rt.ByteSlice = rt.byteSliceFrom(c); _33.data.set(rt.byteSliceToArray(_34), _33.start); const v: Uint8Array[] = copy$array_array1_u8([make$conversions_Value_array1_u8(data, 2), make$conversions_Value_array1_u8(data, 4)]).map(copy$array_u8); - const at = rt.idx(v, 1); + const _40: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 1)]); const _42: rt.ByteSlice = rt.byteSliceFrom(held.value); - const _40: rt.ByteSlice = rt.byteSliceFrom(v[at]); _40.data.set(rt.byteSliceToArray(_42), _40.start); const _44: rt.ByteSlice = rt.byteSliceFrom(b); const _45: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 0)]); @@ -1130,8 +1128,8 @@ export function converted$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, one.length & 0xff); const copied: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(one[0])); put$conversions_Value_array1_u8(rt.byteSliceFrom(one[0]), out); - const _71: rt.ByteSlice = rt.byteSliceFrom(copied); const _70: rt.ByteSlice = rt.byteSliceFrom(a); + const _71: rt.ByteSlice = rt.byteSliceFrom(copied); _70.data.set(rt.byteSliceToArray(_71), _70.start); put$conversions_Value_array1_u8(rt.byteSliceFrom(copied), out); put$conversions_Value_array1_u8(rt.byteSliceFrom(a), out); @@ -1154,8 +1152,8 @@ export function converted$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { _116[0] = _114; const _124: Uint8Array[] = array; rt.idx(_124, 2); - const _130: rt.ByteSlice = rt.byteSliceFrom(c); const _123: rt.ByteSlice = rt.byteSliceFrom(_124[2]); + const _130: rt.ByteSlice = rt.byteSliceFrom(c); _123.data.set(rt.byteSliceToArray(_130), _123.start); const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); while (true) { @@ -1166,8 +1164,8 @@ export function converted$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { put$conversions_Value_array1_u8(_134, out); } put$conversions_Value_array1_u8(rt.byteSliceFrom(rt.byteSliceView(rt.byteSliceFrom(b))), out); - const _145: Uint8Array = copy$array_u8(make$conversions_Value_array1_u8(data, 16)); const q: rt.ByteSlice = rt.byteSliceFrom(c); + const _145: Uint8Array = copy$array_u8(make$conversions_Value_array1_u8(data, 16)); q.data.set(_145, q.start); put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); } @@ -1238,8 +1236,8 @@ export function converted$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { const a: Uint8Array = copy$array_u8(make$conversions_Value_array3_u8(data, 0)); const b: Uint8Array = make$conversions_Value_array3_u8(data, 3); const owned: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(a)); - const _9: rt.ByteSlice = rt.byteSliceFrom(b); const _8: rt.ByteSlice = rt.byteSliceFrom(a); + const _9: rt.ByteSlice = rt.byteSliceFrom(b); _8.data.set(rt.byteSliceToArray(_9), _8.start); put$conversions_Value_array3_u8(rt.byteSliceFrom(owned), out); put$conversions_Value_array3_u8(rt.byteSliceFrom(a), out); @@ -1253,13 +1251,12 @@ export function converted$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); put$conversions_Value_array3_u8(rt.byteSliceFrom(a), out); const held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array3_u8(data, 1))); - const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); + const _34: rt.ByteSlice = rt.byteSliceFrom(c); _33.data.set(rt.byteSliceToArray(_34), _33.start); const v: Uint8Array[] = copy$array_array3_u8([make$conversions_Value_array3_u8(data, 2), make$conversions_Value_array3_u8(data, 4)]).map(copy$array_u8); - const at = rt.idx(v, 1); + const _40: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 1)]); const _42: rt.ByteSlice = rt.byteSliceFrom(held.value); - const _40: rt.ByteSlice = rt.byteSliceFrom(v[at]); _40.data.set(rt.byteSliceToArray(_42), _40.start); const _44: rt.ByteSlice = rt.byteSliceFrom(b); const _45: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 0)]); @@ -1271,8 +1268,8 @@ export function converted$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteVecPush(out, one.length & 0xff); const copied: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(one[0])); put$conversions_Value_array3_u8(rt.byteSliceFrom(one[0]), out); - const _71: rt.ByteSlice = rt.byteSliceFrom(copied); const _70: rt.ByteSlice = rt.byteSliceFrom(a); + const _71: rt.ByteSlice = rt.byteSliceFrom(copied); _70.data.set(rt.byteSliceToArray(_71), _70.start); put$conversions_Value_array3_u8(rt.byteSliceFrom(copied), out); put$conversions_Value_array3_u8(rt.byteSliceFrom(a), out); @@ -1295,8 +1292,8 @@ export function converted$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { _116[0] = _114; const _124: Uint8Array[] = array; rt.idx(_124, 2); - const _130: rt.ByteSlice = rt.byteSliceFrom(c); const _123: rt.ByteSlice = rt.byteSliceFrom(_124[2]); + const _130: rt.ByteSlice = rt.byteSliceFrom(c); _123.data.set(rt.byteSliceToArray(_130), _123.start); const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); while (true) { @@ -1307,8 +1304,8 @@ export function converted$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { put$conversions_Value_array3_u8(_134, out); } put$conversions_Value_array3_u8(rt.byteSliceFrom(rt.byteSliceView(rt.byteSliceFrom(b))), out); - const _145: Uint8Array = copy$array_u8(make$conversions_Value_array3_u8(data, 16)); const q: rt.ByteSlice = rt.byteSliceFrom(c); + const _145: Uint8Array = copy$array_u8(make$conversions_Value_array3_u8(data, 16)); q.data.set(_145, q.start); put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); } @@ -1318,8 +1315,8 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void const a: Uint8Array = copy$array_u8(make$conversions_Value_array40_u8(data, 0)); const b: Uint8Array = make$conversions_Value_array40_u8(data, 3); const owned: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(a)); - const _9: rt.ByteSlice = rt.byteSliceFrom(b); const _8: rt.ByteSlice = rt.byteSliceFrom(a); + const _9: rt.ByteSlice = rt.byteSliceFrom(b); _8.data.set(rt.byteSliceToArray(_9), _8.start); put$conversions_Value_array40_u8(rt.byteSliceFrom(owned), out); put$conversions_Value_array40_u8(rt.byteSliceFrom(a), out); @@ -1333,13 +1330,12 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); put$conversions_Value_array40_u8(rt.byteSliceFrom(a), out); const held: Held.Held = new Held.Held(copy$array_u8(make$conversions_Value_array40_u8(data, 1))); - const _34: rt.ByteSlice = rt.byteSliceFrom(c); const _33: rt.ByteSlice = rt.byteSliceFrom(held.value); + const _34: rt.ByteSlice = rt.byteSliceFrom(c); _33.data.set(rt.byteSliceToArray(_34), _33.start); const v: Uint8Array[] = copy$array_array40_u8([make$conversions_Value_array40_u8(data, 2), make$conversions_Value_array40_u8(data, 4)]).map(copy$array_u8); - const at = rt.idx(v, 1); + const _40: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 1)]); const _42: rt.ByteSlice = rt.byteSliceFrom(held.value); - const _40: rt.ByteSlice = rt.byteSliceFrom(v[at]); _40.data.set(rt.byteSliceToArray(_42), _40.start); const _44: rt.ByteSlice = rt.byteSliceFrom(b); const _45: rt.ByteSlice = rt.byteSliceFrom(v[rt.idx(v, 0)]); @@ -1351,8 +1347,8 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void rt.byteVecPush(out, one.length & 0xff); const copied: Uint8Array = rt.byteSliceToArray(rt.byteSliceFrom(one[0])); put$conversions_Value_array40_u8(rt.byteSliceFrom(one[0]), out); - const _71: rt.ByteSlice = rt.byteSliceFrom(copied); const _70: rt.ByteSlice = rt.byteSliceFrom(a); + const _71: rt.ByteSlice = rt.byteSliceFrom(copied); _70.data.set(rt.byteSliceToArray(_71), _70.start); put$conversions_Value_array40_u8(rt.byteSliceFrom(copied), out); put$conversions_Value_array40_u8(rt.byteSliceFrom(a), out); @@ -1375,8 +1371,8 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void _116[0] = _114; const _124: Uint8Array[] = array; rt.idx(_124, 2); - const _130: rt.ByteSlice = rt.byteSliceFrom(c); const _123: rt.ByteSlice = rt.byteSliceFrom(_124[2]); + const _130: rt.ByteSlice = rt.byteSliceFrom(c); _123.data.set(rt.byteSliceToArray(_130), _123.start); const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); while (true) { @@ -1387,8 +1383,8 @@ export function converted$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void put$conversions_Value_array40_u8(_134, out); } put$conversions_Value_array40_u8(rt.byteSliceFrom(rt.byteSliceView(rt.byteSliceFrom(b))), out); - const _145: Uint8Array = copy$array_u8(make$conversions_Value_array40_u8(data, 16)); const q: rt.ByteSlice = rt.byteSliceFrom(c); + const _145: Uint8Array = copy$array_u8(make$conversions_Value_array40_u8(data, 16)); q.data.set(_145, q.start); put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); } @@ -1931,8 +1927,8 @@ export function lentOne$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { const s: Uint8Array[] = rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a)))); rt.byteVecPush(out, s.length & 0xff); rt.idx(s, 0); - const _28: Uint8Array = copy$array_u8(make$conversions_Value_array1_u8(data, 5)); const _23: rt.ByteSlice = rt.byteSliceFrom(s[0]); + const _28: Uint8Array = copy$array_u8(make$conversions_Value_array1_u8(data, 5)); const old4 = rt.byteSliceToArray(_23); _23.data.set(_28, _23.start); put$conversions_Value_array1_u8(rt.byteSliceFrom(old4), out); @@ -2003,8 +1999,8 @@ export function lentOne$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { const s: Uint8Array[] = rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a)))); rt.byteVecPush(out, s.length & 0xff); rt.idx(s, 0); - const _28: Uint8Array = copy$array_u8(make$conversions_Value_array3_u8(data, 5)); const _23: rt.ByteSlice = rt.byteSliceFrom(s[0]); + const _28: Uint8Array = copy$array_u8(make$conversions_Value_array3_u8(data, 5)); const old4 = rt.byteSliceToArray(_23); _23.data.set(_28, _23.start); put$conversions_Value_array3_u8(rt.byteSliceFrom(old4), out); @@ -2040,8 +2036,8 @@ export function lentOne$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { const s: Uint8Array[] = rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a)))); rt.byteVecPush(out, s.length & 0xff); rt.idx(s, 0); - const _28: Uint8Array = copy$array_u8(make$conversions_Value_array40_u8(data, 5)); const _23: rt.ByteSlice = rt.byteSliceFrom(s[0]); + const _28: Uint8Array = copy$array_u8(make$conversions_Value_array40_u8(data, 5)); const old4 = rt.byteSliceToArray(_23); _23.data.set(_28, _23.start); put$conversions_Value_array40_u8(rt.byteSliceFrom(old4), out); diff --git a/ts/fixtures/lang/cows/expected/cows.ts b/ts/fixtures/lang/cows/expected/cows.ts index 13cf20c47..3009679b8 100644 --- a/ts/fixtures/lang/cows/expected/cows.ts +++ b/ts/fixtures/lang/cows/expected/cows.ts @@ -480,8 +480,7 @@ export function bytes(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const half: rt.ByteSlice = rt.byteSliceRange(data, 0, rt.usizeDiv(data.length, 2)); let c: rt.ByteCow = made(data, owned); rt.byteVecPush(out, rt.byteCowSlice(c).length & 0xff); - const part2 = rt.min(rt.byteCowSlice(c).length, 3); - rt.byteVecExtendFromSlice(out, rt.byteSliceRange(rt.byteCowSlice(c), 0, part2)); + rt.byteVecExtendFromSlice(out, rt.byteSliceRange(rt.byteCowSlice(c), 0, rt.min(rt.byteCowSlice(c).length, 3))); const _35: rt.ByteCow = made(half, !owned); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(rt.byteCowSlice(c)), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(rt.byteCowSlice(_35)), f, rt.u8Debug)]; put(out, rt.fmtFormat([args2[0], " ", args2[1]])); diff --git a/ts/fixtures/lang/durations/expected/durations.ts b/ts/fixtures/lang/durations/expected/durations.ts index 568c57a05..d8d58c568 100644 --- a/ts/fixtures/lang/durations/expected/durations.ts +++ b/ts/fixtures/lang/durations/expected/durations.ts @@ -155,8 +155,8 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const d2: rt.Duration = rt.durationFromNanos(rt.u32Rem(n, 1000000) as rt.u64); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), (f: rt.Formatter) => rt.fmtOption(b, f, rt.durationDebug)]; put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", args2[2], "|", rt.fmtSpec({ align: ">", width: 16 }, args2[1]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 14 }, args2[2]), "|", rt.fmtSpec({ align: "<", width: 12 }, args2[1]), "|", rt.fmtSpec({ zero: true, width: 8 }, args2[0]), "|", args2[3]])); - const _234: rt.Duration | undefined = b; const p: rt.usize = rt.u32Rem(n, 13) as rt.usize; + const _234: rt.Duration | undefined = b; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), rt.fmtCount(p), (f: rt.Formatter) => rt.fmtOption(_234, f, rt.durationDebug)]; put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args4[0]), "|", rt.fmtSpec({ precision: 3 }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[1]), "|", rt.fmtSpec({ precision: 12 }, args4[2]), "|", rt.fmtSpec({ plus: true }, args4[0]), "|", rt.fmtSpec({ plus: true, width: 12, precision: 2 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 10, precision: 1 }, args4[2]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args4[3]) }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[4])])); const iter4: rt.Iter = rt.iterSlice([1500000000, 2500000000, 1250000, 1350000, 999500, 1999999999]); diff --git a/ts/fixtures/lang/dyns/expected/dyns.ts b/ts/fixtures/lang/dyns/expected/dyns.ts index 07675b3a2..a84ad2aa3 100644 --- a/ts/fixtures/lang/dyns/expected/dyns.ts +++ b/ts/fixtures/lang/dyns/expected/dyns.ts @@ -149,16 +149,16 @@ export function dyns(dataData: Uint8Array, dataStart: number, dataLen: number, o } const _167: Tri.Tri = tri; const at2 = rt.idx(shapes, 0); - const _175: rt.u32 = sum; const _165: Shown.Shown = { _0: (f: rt.Formatter) => Tri.fmt$fmt_Debug(_167, f) }; const _169: rt.u32 = shapes[at2].larger$Shape(b as rt.u32); + const _175: rt.u32 = sum; const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_175, f), (f: rt.Formatter) => Shown.fmt$fmt_Debug(_165, f), (f: rt.Formatter) => rt.u32Display(_169, f)]; put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " "])); for (const s2 of shapes) { sum = rt.u32WrappingAdd(sum, s2.intoArea$Shape()); } - const _204: rt.u32 = sum; const _203: rt.u32 = new Shape.of$u32(n).intoArea$Shape(); + const _204: rt.u32 = sum; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_204, f), (f: rt.Formatter) => rt.u32Display(_203, f)]; put(out, rt.fmtFormat([args12[0], " ", args12[1]])); } @@ -406,8 +406,8 @@ export function anys(dataData: Uint8Array, dataStart: number, dataLen: number, o const _54: boolean = bump(new Any.ofPlace$dyns_Tri(rt.place(() => tri, (value) => tri = value)), b); const _57: boolean = bump(new Any.ofPlace$u32(rt.place(() => n, (value2) => n = value2)), a); let _63: rt.u8 = 0; - const _72: Tri.Tri = tri; const hit: [boolean, boolean, boolean, boolean] = [_51, _54, _57, bump(new Any.ofPlace$u8(rt.place(() => _63, (value3) => _63 = value3)), a)]; + const _72: Tri.Tri = tri; const arg = sq.side; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(arg, f), (f: rt.Formatter) => Tri.fmt$fmt_Debug(_72, f), (f: rt.Formatter) => rt.u32Display(n, f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtBool(hit[0], f), (f: rt.Formatter) => rt.fmtBool(hit[1], f), (f: rt.Formatter) => rt.fmtBool(hit[2], f), (f: rt.Formatter) => rt.fmtBool(hit[3], f)], f)]; put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", args4[2], " ", args4[3], " "])); diff --git a/ts/fixtures/lang/fields/expected/fields.ts b/ts/fixtures/lang/fields/expected/fields.ts index 3e70b1343..91e807149 100644 --- a/ts/fixtures/lang/fields/expected/fields.ts +++ b/ts/fixtures/lang/fields/expected/fields.ts @@ -20,9 +20,8 @@ export const SCANNER: Scanner.Scanner = { bufData: Uint8Array.of(120, 121, 122), export function fields(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { let two!: Glued.Glued; const n: rt.usize = rt.u8Rem(kind, 5) as rt.usize; - const _12: rt.usize = kind as rt.usize; const _8: rt.ByteSlice = rt.byteSliceRange(data, rt.min(n, data.length)); - rt.byteVecPush(out, _12 & 0xff); + rt.byteVecPush(out, ((kind as rt.usize)) & 0xff); rt.byteVecExtendFromSlice(out, rt.byteSliceRange(new rt.ByteSlice(_8.data, _8.start, _8.length), 0, rt.min(_8.length, 2))); const r: Scanner.Scanner = { bufData: data.data, bufStart: data.start, bufLen: data.length, read: 0 }; while (true) { diff --git a/ts/fixtures/lang/heap/expected/heap.ts b/ts/fixtures/lang/heap/expected/heap.ts index 811eb770d..c3475dd45 100644 --- a/ts/fixtures/lang/heap/expected/heap.ts +++ b/ts/fixtures/lang/heap/expected/heap.ts @@ -157,8 +157,7 @@ export function layouts(data: rt.ByteSlice, out: rt.ByteVec): void { break; } const word: Uint8Array = rt.bytes(4); - const part = rt.min(_6.length, 4); - rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(word), 0, part), rt.byteSliceRange(_6, 0, rt.min(_6.length, 4))); + rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(word), 0, rt.min(_6.length, 4)), rt.byteSliceRange(_6, 0, rt.min(_6.length, 4))); const size: rt.usize = rt.u32FromBeBytes(word.slice().reverse()) as rt.usize; const b: rt.u8 = option_unwrapOr$0r2bmpr(rt.byteSliceGet(_6, 4), 0); if ((b & 128) === 0) { diff --git a/ts/fixtures/lang/iters/expected/iters.ts b/ts/fixtures/lang/iters/expected/iters.ts index 10e632ec5..ec4654d38 100644 --- a/ts/fixtures/lang/iters/expected/iters.ts +++ b/ts/fixtures/lang/iters/expected/iters.ts @@ -1275,7 +1275,9 @@ export function updates(a: rt.u8, b: rt.u8, data: rt.ByteSlice, out: rt.ByteVec) rt.byteVecPush(out, rt.byteSliceRange(data, 0).length & 0xff); rt.byteVecPush(out, rt.byteSliceRange(data, 0).length & 0xff); const copied: rt.ByteVec = rt.byteSliceToByteVec(data); - rt.byteSliceCopyWithin(rt.byteVecSlice(copied), 0, to, 0); + const _76: rt.ByteSlice = rt.byteVecSlice(copied); + const _78: rt.Range = new rt.Range(0, to); + rt.byteSliceCopyWithin(_76, _78.start, _78.end, 0); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(copied)); } @@ -4817,11 +4819,11 @@ export function bounded$char(table: rt.char[], at: rt.usize[], out: rt.ByteVec): const end: rt.char = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.charStep); const _102: rt.Range = new rt.Range(a, b, rt.charStep); + const _113: [rt.char, rt.char] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.charStep); const _107: { end: rt.char } = { end: b }; const _109: { end: rt.char; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.char, rt.char] = [start, end]; - const _113: [rt.char, rt.char] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.fmtCharDebug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.fmtCharDebug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.fmtCharDebug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.fmtCharDebug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.fmtCharDebug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtCharDebug(_111[0], f), (f: rt.Formatter) => rt.fmtCharDebug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtCharDebug(_113[0], f), (f: rt.Formatter) => rt.fmtCharDebug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -4887,11 +4889,11 @@ export function bounded$f32(table: rt.f32[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.f32 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.f32, rt.f32] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a); const _107: { end: rt.f32 } = { end: b }; const _109: { end: rt.f32; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.f32, rt.f32] = [start, end]; - const _113: [rt.f32, rt.f32] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.f32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.f32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.f32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.f32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.f32Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.f32Debug(_111[0], f), (f: rt.Formatter) => rt.f32Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.f32Debug(_113[0], f), (f: rt.Formatter) => rt.f32Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -4957,11 +4959,11 @@ export function bounded$f64(table: rt.f64[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.f64 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.f64, rt.f64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a); const _107: { end: rt.f64 } = { end: b }; const _109: { end: rt.f64; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.f64, rt.f64] = [start, end]; - const _113: [rt.f64, rt.f64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.f64Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.f64Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.f64Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.f64Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.f64Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.f64Debug(_111[0], f), (f: rt.Formatter) => rt.f64Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.f64Debug(_113[0], f), (f: rt.Formatter) => rt.f64Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5027,11 +5029,11 @@ export function bounded$i128(table: rt.i128[], at: rt.usize[], out: rt.ByteVec): const end: rt.i128 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i128Step); const _102: rt.Range = new rt.Range(a, b, rt.i128Step); + const _113: [rt.i128, rt.i128] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.i128Step); const _107: { end: rt.i128 } = { end: b }; const _109: { end: rt.i128; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.i128, rt.i128] = [start, end]; - const _113: [rt.i128, rt.i128] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.i128Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.i128Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.i128Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.i128Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.i128Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i128Debug(_111[0], f), (f: rt.Formatter) => rt.i128Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i128Debug(_113[0], f), (f: rt.Formatter) => rt.i128Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5097,11 +5099,11 @@ export function bounded$i16(table: rt.i16[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.i16 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i16Step); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.i16, rt.i16] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.i16Step); const _107: { end: rt.i16 } = { end: b }; const _109: { end: rt.i16; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.i16, rt.i16] = [start, end]; - const _113: [rt.i16, rt.i16] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i16Debug(_111[0], f), (f: rt.Formatter) => rt.i16Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i16Debug(_113[0], f), (f: rt.Formatter) => rt.i16Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5167,11 +5169,11 @@ export function bounded$i32(table: rt.i32[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.i32 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.i32, rt.i32] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.i32Step); const _107: { end: rt.i32 } = { end: b }; const _109: { end: rt.i32; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.i32, rt.i32] = [start, end]; - const _113: [rt.i32, rt.i32] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i32Debug(_111[0], f), (f: rt.Formatter) => rt.i32Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i32Debug(_113[0], f), (f: rt.Formatter) => rt.i32Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5237,11 +5239,11 @@ export function bounded$i64(table: rt.i64[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.i64 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i64Step); const _102: rt.Range = new rt.Range(a, b, rt.i64Step); + const _113: [rt.i64, rt.i64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.i64Step); const _107: { end: rt.i64 } = { end: b }; const _109: { end: rt.i64; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.i64, rt.i64] = [start, end]; - const _113: [rt.i64, rt.i64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.i64Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.i64Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.i64Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.i64Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.i64Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i64Debug(_111[0], f), (f: rt.Formatter) => rt.i64Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i64Debug(_113[0], f), (f: rt.Formatter) => rt.i64Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5307,11 +5309,11 @@ export function bounded$i8(table: rt.i8[], at: rt.usize[], out: rt.ByteVec): [rt const end: rt.i8 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i8Step); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.i8, rt.i8] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.i8Step); const _107: { end: rt.i8 } = { end: b }; const _109: { end: rt.i8; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.i8, rt.i8] = [start, end]; - const _113: [rt.i8, rt.i8] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.i8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.i8Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.i8Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.i8Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.i8Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i8Debug(_111[0], f), (f: rt.Formatter) => rt.i8Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.i8Debug(_113[0], f), (f: rt.Formatter) => rt.i8Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5377,11 +5379,11 @@ export function bounded$isize(table: rt.isize[], at: rt.usize[], out: rt.ByteVec const end: rt.isize = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.isizeStep); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.isize, rt.isize] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.isizeStep); const _107: { end: rt.isize } = { end: b }; const _109: { end: rt.isize; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.isize, rt.isize] = [start, end]; - const _113: [rt.isize, rt.isize] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.isizeDebug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.isizeDebug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.isizeDebug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.isizeDebug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.isizeDebug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.isizeDebug(_111[0], f), (f: rt.Formatter) => rt.isizeDebug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.isizeDebug(_113[0], f), (f: rt.Formatter) => rt.isizeDebug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5447,11 +5449,11 @@ export function bounded$num_NonZero_u128(table: rt.u128[], at: rt.usize[], out: const end: rt.u128 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.nonZeroStep(rt.u128Step, { hi: 0xffffffff, w2: 0xffffffff, w1: 0xffffffff, lo: 0xffffffff } as rt.u128)); const _102: rt.Range = new rt.Range(a, b, rt.nonZeroStep(rt.u128Step, { hi: 0xffffffff, w2: 0xffffffff, w1: 0xffffffff, lo: 0xffffffff } as rt.u128)); + const _113: [rt.u128, rt.u128] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.nonZeroStep(rt.u128Step, { hi: 0xffffffff, w2: 0xffffffff, w1: 0xffffffff, lo: 0xffffffff } as rt.u128)); const _107: { end: rt.u128 } = { end: b }; const _109: { end: rt.u128; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u128, rt.u128] = [start, end]; - const _113: [rt.u128, rt.u128] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u128Debug(_111[0], f), (f: rt.Formatter) => rt.u128Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u128Debug(_113[0], f), (f: rt.Formatter) => rt.u128Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5517,11 +5519,11 @@ export function bounded$num_NonZero_u64(table: rt.u64[], at: rt.usize[], out: rt const end: rt.u64 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.nonZeroStep(rt.u64Step, { hi: 0xffffffff, lo: 0xffffffff } as rt.u64)); const _102: rt.Range = new rt.Range(a, b, rt.nonZeroStep(rt.u64Step, { hi: 0xffffffff, lo: 0xffffffff } as rt.u64)); + const _113: [rt.u64, rt.u64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.nonZeroStep(rt.u64Step, { hi: 0xffffffff, lo: 0xffffffff } as rt.u64)); const _107: { end: rt.u64 } = { end: b }; const _109: { end: rt.u64; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u64, rt.u64] = [start, end]; - const _113: [rt.u64, rt.u64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u64Debug(_111[0], f), (f: rt.Formatter) => rt.u64Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u64Debug(_113[0], f), (f: rt.Formatter) => rt.u64Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5587,11 +5589,11 @@ export function bounded$num_NonZero_u8(table: rt.u8[], at: rt.usize[], out: rt.B const end: rt.u8 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.nonZeroStep(rt.u8Step, 255)); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.u8, rt.u8] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.nonZeroStep(rt.u8Step, 255)); const _107: { end: rt.u8 } = { end: b }; const _109: { end: rt.u8; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u8, rt.u8] = [start, end]; - const _113: [rt.u8, rt.u8] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(_111[0], f), (f: rt.Formatter) => rt.u8Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(_113[0], f), (f: rt.Formatter) => rt.u8Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5657,11 +5659,11 @@ export function bounded$num_NonZero_usize(table: rt.usize[], at: rt.usize[], out const end: rt.usize = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.nonZeroStep(rt.usizeStep, 4294967295)); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.usize, rt.usize] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.nonZeroStep(rt.usizeStep, 4294967295)); const _107: { end: rt.usize } = { end: b }; const _109: { end: rt.usize; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.usize, rt.usize] = [start, end]; - const _113: [rt.usize, rt.usize] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(_111[0], f), (f: rt.Formatter) => rt.usizeDebug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(_113[0], f), (f: rt.Formatter) => rt.usizeDebug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5727,11 +5729,11 @@ export function bounded$u128(table: rt.u128[], at: rt.usize[], out: rt.ByteVec): const end: rt.u128 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.u128Step); const _102: rt.Range = new rt.Range(a, b, rt.u128Step); + const _113: [rt.u128, rt.u128] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.u128Step); const _107: { end: rt.u128 } = { end: b }; const _109: { end: rt.u128; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u128, rt.u128] = [start, end]; - const _113: [rt.u128, rt.u128] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u128Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u128Debug(_111[0], f), (f: rt.Formatter) => rt.u128Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u128Debug(_113[0], f), (f: rt.Formatter) => rt.u128Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5797,11 +5799,11 @@ export function bounded$u16(table: rt.u16[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.u16 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.u16Step); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.u16, rt.u16] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.u16Step); const _107: { end: rt.u16 } = { end: b }; const _109: { end: rt.u16; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u16, rt.u16] = [start, end]; - const _113: [rt.u16, rt.u16] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u16Debug(_111[0], f), (f: rt.Formatter) => rt.u16Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u16Debug(_113[0], f), (f: rt.Formatter) => rt.u16Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5867,11 +5869,11 @@ export function bounded$u32(table: rt.u32[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.u32 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.u32Step); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.u32, rt.u32] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.u32Step); const _107: { end: rt.u32 } = { end: b }; const _109: { end: rt.u32; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u32, rt.u32] = [start, end]; - const _113: [rt.u32, rt.u32] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u32Debug(_111[0], f), (f: rt.Formatter) => rt.u32Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u32Debug(_113[0], f), (f: rt.Formatter) => rt.u32Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -5937,11 +5939,11 @@ export function bounded$u64(table: rt.u64[], at: rt.usize[], out: rt.ByteVec): [ const end: rt.u64 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.u64Step); const _102: rt.Range = new rt.Range(a, b, rt.u64Step); + const _113: [rt.u64, rt.u64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.u64Step); const _107: { end: rt.u64 } = { end: b }; const _109: { end: rt.u64; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u64, rt.u64] = [start, end]; - const _113: [rt.u64, rt.u64] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u64Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u64Debug(_111[0], f), (f: rt.Formatter) => rt.u64Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u64Debug(_113[0], f), (f: rt.Formatter) => rt.u64Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -6007,11 +6009,11 @@ export function bounded$u8(table: rt.ByteSlice, at: rt.usize[], out: rt.ByteVec) const end: rt.u8 = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.u8Step); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.u8, rt.u8] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.u8Step); const _107: { end: rt.u8 } = { end: b }; const _109: { end: rt.u8; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.u8, rt.u8] = [start, end]; - const _113: [rt.u8, rt.u8] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(_111[0], f), (f: rt.Formatter) => rt.u8Debug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(_113[0], f), (f: rt.Formatter) => rt.u8Debug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); @@ -6077,11 +6079,11 @@ export function bounded$usize(table: rt.usize[], at: rt.usize[], out: rt.ByteVec const end: rt.usize = _94[1]; const inclusive: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.usizeStep); const _102: rt.Range = new rt.Range(a, b); + const _113: [rt.usize, rt.usize] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _105: rt.RangeFrom = new rt.RangeFrom(a, rt.usizeStep); const _107: { end: rt.usize } = { end: b }; const _109: { end: rt.usize; inclusive: true } = { end: b, inclusive: true }; const _111: [rt.usize, rt.usize] = [start, end]; - const _113: [rt.usize, rt.usize] = [rt.rangeInclusiveStart(inclusive), rt.rangeInclusiveEnd(inclusive)]; const _118: [undefined, [undefined, rt.Range]] = [undefined, [undefined, new rt.Range(1, 2)]]; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_102, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeInclusive(inclusive, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeFrom(_105, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeTo(_107, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_109, f, rt.usizeDebug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(_111[0], f), (f: rt.Formatter) => rt.usizeDebug(_111[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(_113[0], f), (f: rt.Formatter) => rt.usizeDebug(_113[1], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[0], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtRangeFull(_118[1][0], f), (f: rt.Formatter) => rt.fmtRange(_118[1][1], f, rt.i32Debug)], f)], f)]; rt.iterExtendBytes(out, rt.strBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7]])), undefined, true); diff --git a/ts/fixtures/lang/locks/caller.ts b/ts/fixtures/lang/locks/caller.ts index 83bd9fb63..23e50e92e 100644 --- a/ts/fixtures/lang/locks/caller.ts +++ b/ts/fixtures/lang/locks/caller.ts @@ -39,4 +39,7 @@ const downgrades = [[0x00, 0x01, 0x11, 0x02, 0xf2, 0xe2, 0x03, 0x04, 0x13, 0x05] /** `locks::rwlocks` scripts: `get_mut` and `into_inner` among writes and reads. */ const rwlocks = [[6, 7, 0, 6, 2, 14, 15, 1]].map((bytes) => Uint8Array.of(...op("locks::rwlocks"), 0, ...bytes)); -export const cases: Uint8Array[] = [...locks, ...mappedLocks, ...relocks, ...mutexMaps, ...printed, ...downgrades, ...rwlocks]; +/** `locks::shown` scripts: each lock printed, free, read, held, and written, nested. */ +const shown = [[0x00, 0x05, 0x06, 0x07, 0xfc, 0x09, 0x0a]].map((bytes) => Uint8Array.of(...op("locks::shown"), 0, ...bytes)); + +export const cases: Uint8Array[] = [...locks, ...mappedLocks, ...relocks, ...mutexMaps, ...printed, ...downgrades, ...rwlocks, ...shown]; diff --git a/ts/fixtures/lang/locks/expected/lib.ts b/ts/fixtures/lang/locks/expected/lib.ts index 766f22c7a..ad3f9e2c7 100644 --- a/ts/fixtures/lang/locks/expected/lib.ts +++ b/ts/fixtures/lang/locks/expected/lib.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { locks, relock, rwlocks, mapped, mutexMapped, printed, downgraded } from "./locks.ts"; +import { locks, relock, rwlocks, mapped, mutexMapped, printed, downgraded, shown } from "./locks.ts"; import type * as Tally from "./locks.Tally.ts"; export function drop$Result_Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.Mutex>, rt.Mutex>): void { @@ -189,20 +189,22 @@ export function drop$sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.TryLockE * their count, so a case added at the end moves no other. */ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined][] { - return [["locks::locks", (_24: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { + return [["locks::locks", (_27: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): undefined => { locks(data, out); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::relock", (_25: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::relock", (_28: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): undefined => { relock(data2, out2); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::rwlocks", (_26: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::rwlocks", (_29: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): undefined => { rwlocks(data3, out3); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mapped", (_27: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mapped", (_210: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): undefined => { mapped(data4, out4); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mutex_mapped", (_28: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mutex_mapped", (_211: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): undefined => { mutexMapped(data5, out5); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::printed", (_29: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::printed", (_212: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): undefined => { printed(data6, out6); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::downgraded", (_210: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::downgraded", (_213: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): undefined => { downgraded(data7, out7); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::shown", (_214: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): undefined => { + shown(data8, out8); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; } diff --git a/ts/fixtures/lang/locks/expected/locks.ts b/ts/fixtures/lang/locks/expected/locks.ts index f2a2bf8c8..57f50e961 100644 --- a/ts/fixtures/lang/locks/expected/locks.ts +++ b/ts/fixtures/lang/locks/expected/locks.ts @@ -856,4 +856,57 @@ export function held$u32(lock: rt.RefCell): rt.u8 { return ((((read ? 1 : 0)) << 1) & 0xff) | ((write ? 1 : 0)); } +/** + * Each lock printed by `Debug` as std writes it, never poisoned, and `` with no + * options while a guard holds a mutex or writes a read-write lock, plain, pretty, and + * padded, its value the operand: free, held, read, and nested in an `Arc` and each other. + */ +export function shown(data: rt.ByteSlice, out: rt.ByteVec): void { + let text!: string; + const mutex: rt.Arc> = new rt.Arc(new rt.Mutex(0)); + const lock: rt.RefCell[]> = new rt.RefCell([new rt.Mutex(97)]); + for (const op of rt.byteSliceView(data)) { + const v: rt.u8 = op >> 2; + const _19: rt.u8 = rt.u8Rem(op, 4); + if (_19 === 0) { + const _23: rt.Mutex = rt.mutexLock(mutex.value); + _23.value = v; + rt.mutexUnlock(_23); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.mutexDebug(mutex.value, f, rt.u8Debug)]; + const free: string = rt.fmtFormat([args2[0], " ", rt.fmtSpec({ alternate: true }, args2[0]), " ", rt.fmtSpec({ align: ">", width: 4 }, args2[0])]); + const _held: rt.Mutex = rt.mutexLock(mutex.value); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free), (f: rt.Formatter) => rt.mutexDebug(mutex.value, f, rt.u8Debug)]; + text = rt.fmtFormat([args4[0], " ", args4[1], " ", rt.fmtSpec({ alternate: true }, args4[1]), " ", rt.fmtSpec({ align: ">", width: 12 }, args4[1])]); + rt.mutexUnlock(_held); + } else if (_19 === 1) { + const _53: rt.RefCell[]> = rt.rwLockWrite(lock); + const _56: rt.Mutex = new rt.Mutex(rt.u8Add(97, rt.u8Rem(v, 26)) as rt.char); + _53.value.push(_56); + rt.refMutRelease(_53); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; + const free2: string = rt.fmtFormat([args6[0], " ", rt.fmtSpec({ alternate: true }, args6[0])]); + const read: rt.RefCell[]> = rt.rwLockRead(lock); + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; + const shared: string = rt.fmtFormat([args8[0]]); + const _86: rt.Mutex[] = read.value; + const _held2: rt.Mutex = rt.mutexLock(_86[rt.idx(_86, 0)]); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free2), (f: rt.Formatter) => rt.fmtPad(f, shared), (f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; + text = rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " ", rt.fmtSpec({ alternate: true }, args10[2])]); + rt.mutexUnlock(_held2); + rt.refRelease(read); + } else if (_19 === 2) { + const _held3: rt.RefCell[]> = rt.rwLockWrite(lock); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; + text = rt.fmtFormat([args12[0], " ", rt.fmtSpec({ alternate: true }, args12[0]), " ", rt.fmtSpec({ align: ">", width: 12 }, args12[0])]); + rt.refMutRelease(_held3); + } else { + const part = new rt.RefCell(new rt.Mutex("s")); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(part, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtStr))]; + text = rt.fmtFormat([args14[0]]); + } + rt.byteVecExtendFromSlice(out, rt.stringAsBytes(text)); + } + mutex[Symbol.dispose](); +} + //# sourceMappingURL=locks.ts.map diff --git a/ts/fixtures/lang/locks/src/lib.rs b/ts/fixtures/lang/locks/src/lib.rs index 9a3b45cd7..d53bbaca6 100644 --- a/ts/fixtures/lang/locks/src/lib.rs +++ b/ts/fixtures/lang/locks/src/lib.rs @@ -25,5 +25,6 @@ fn cases() -> Vec<(&'static str, Case)> { ("locks::mutex_mapped", |_, data, out| locks::mutex_mapped(data, out)), ("locks::printed", |_, data, out| locks::printed(data, out)), ("locks::downgraded", |_, data, out| locks::downgraded(data, out)), + ("locks::shown", |_, data, out| locks::shown(data, out)), ] } diff --git a/ts/fixtures/lang/locks/src/locks.rs b/ts/fixtures/lang/locks/src/locks.rs index 1a41ff298..6923ef6ce 100644 --- a/ts/fixtures/lang/locks/src/locks.rs +++ b/ts/fixtures/lang/locks/src/locks.rs @@ -6,7 +6,7 @@ //! and written through guards mapped and filtered to parts of their values, a mutex's //! included, and locked again while a guard holds them, which aborts as wasm32's does; //! write guards downgraded, which keep the lock read; guards mapped to the whole of the -//! bytes a lock holds; and each lock's guards printed. +//! bytes a lock holds; and each lock and its guards printed. use std::fmt; use std::sync::{ @@ -524,3 +524,36 @@ fn held(lock: &RwLock) -> u8 { let write = matches!(lock.try_write(), Err(TryLockError::WouldBlock)); u8::from(read) << 1 | u8::from(write) } + +/// Each lock printed by `Debug` as std writes it, never poisoned, and `` with no +/// options while a guard holds a mutex or writes a read-write lock, plain, pretty, and +/// padded, its value the operand: free, held, read, and nested in an `Arc` and each other. +pub fn shown(data: &[u8], out: &mut Vec) { + let mutex = Arc::new(Mutex::new(0u8)); + let lock = RwLock::new(vec![Mutex::new('a')]); + for &op in data { + let v = op >> 2; + let text = match op % 4 { + 0 => { + *mutex.lock().unwrap() = v; + let free = format!("{mutex:?} {mutex:#?} {mutex:>4?}"); + let _held = mutex.lock().unwrap(); + format!("{free} {mutex:?} {mutex:#?} {mutex:>12?}") + } + 1 => { + lock.write().unwrap().push(Mutex::new(char::from(b'a' + v % 26))); + let free = format!("{lock:?} {lock:#?}"); + let read = lock.read().unwrap(); + let shared = format!("{lock:?}"); + let _held = read[0].lock().unwrap(); + format!("{free} {shared} {lock:?} {lock:#?}") + } + 2 => { + let _held = lock.write().unwrap(); + format!("{lock:?} {lock:#?} {lock:>12?}") + } + _ => format!("{:?}", RwLock::new(Mutex::new(String::from("s")))), + }; + out.extend_from_slice(text.as_bytes()); + } +} diff --git a/ts/fixtures/lang/nested/expected/nested.ts b/ts/fixtures/lang/nested/expected/nested.ts index dca41a062..fd85600e0 100644 --- a/ts/fixtures/lang/nested/expected/nested.ts +++ b/ts/fixtures/lang/nested/expected/nested.ts @@ -496,8 +496,7 @@ export function elements(data: rt.ByteSlice, out: rt.ByteVec): void { }); const v: Array = rt.vecExact(items.slice(), 2); rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(code(rt.sliceFirst(v, rt.None)), code(rt.sliceLast(v, rt.None)), code(rt.sliceGet(v, at, rt.None)))), undefined, true); - const part = at; - rt.byteVecPush(out, code(option_andThen$0ocv8av(rt.sliceGetRange(rt.sliceRange(v, 0), part), (s: Array): rt.u8 | undefined | rt.None => { + rt.byteVecPush(out, code(option_andThen$0ocv8av(rt.sliceGetRange(rt.sliceRange(v, 0), at), (s: Array): rt.u8 | undefined | rt.None => { return rt.sliceFirst(s, rt.None); }))); option_map$1diqi3e(rt.sliceFirstMut(v), (o9: rt.Place): undefined => { diff --git a/ts/fixtures/lang/refs/expected/refs.ts b/ts/fixtures/lang/refs/expected/refs.ts index cf5f97921..da8dcee57 100644 --- a/ts/fixtures/lang/refs/expected/refs.ts +++ b/ts/fixtures/lang/refs/expected/refs.ts @@ -1272,8 +1272,7 @@ export function toRefs(data: rt.ByteSlice, out: rt.ByteVec): void { text = text + String.fromCodePoint(rt.u8Add(97, rt.u8Rem(_59, 26)) as rt.char); } let s: string = text; - const part = rt.min(rt.usizeRem(n, 3), rt.stringLen(s)); - s = rt.strSlice(s, part); + s = rt.strSlice(s, rt.min(rt.usizeRem(n, 3), rt.stringLen(s))); rt.byteVecExtendFromSlice(out, rt.stringAsBytes(s)); const part2 = rt.usizeDiv(rt.byteSliceRange(data, 1).length, 2); const _85: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceRange(data, 1), part2); diff --git a/ts/fixtures/lang/shapes/expected/fmt.ts b/ts/fixtures/lang/shapes/expected/fmt.ts index f7915af1f..a7f3b5ba1 100644 --- a/ts/fixtures/lang/shapes/expected/fmt.ts +++ b/ts/fixtures/lang/shapes/expected/fmt.ts @@ -544,8 +544,8 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { const _129: rt.u8 = rt.optionExpect(missing, rt.fmtFormat(["missing ", args10[0]])); put(out, rt.fmtToString((f: rt.Formatter) => rt.u8Display(_129, f))); } else if (_7 === 11) { - const part5 = { _0: n }; - const args12: rt.Fmt[] = [(f: rt.Formatter) => Fails.fmt$fmt_Display(part5, f)]; + const part3 = { _0: n }; + const args12: rt.Fmt[] = [(f: rt.Formatter) => Fails.fmt$fmt_Display(part3, f)]; put(out, rt.fmtFormat([args12[0]])); } else if (_7 === 12) { const _157: Fails.Fails = { _0: n }; @@ -580,10 +580,10 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { put(out, rt.fmtToString((f: rt.Formatter) => rt.u8Display(_234, f))); } else if (_7 === 17) { const buf2: Uint8Array = Uint8Array.of(1, 2, 3, 4); - const part2 = rt.u8Rem(n, 6) as rt.usize; - const part3 = rt.u8Rem(rt.u8Div(n, 6), 6) as rt.usize; const dest: rt.usize = rt.usizeRem(option_unwrapOr$0r2bmpr(rt.byteSliceGet(rest, 1), 0) as rt.usize, 4); - rt.byteSliceCopyWithin(rt.byteSliceFrom(buf2), part2, part3, dest); + const _244: rt.ByteSlice = rt.byteSliceFrom(buf2); + const _246: rt.Range = new rt.Range(rt.u8Rem(n, 6) as rt.usize, rt.u8Rem(rt.u8Div(n, 6), 6) as rt.usize); + rt.byteSliceCopyWithin(_244, _246.start, _246.end, dest); const arg2 = rt.byteSliceFrom(buf2); const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(arg2), f, rt.u8Debug)]; put(out, rt.fmtFormat([args20[0]])); @@ -625,11 +625,11 @@ export function wrapped(data: rt.ByteSlice, out: rt.ByteVec): void { put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5]])); const _60: rt.Range = new rt.Range(a, b); const _62: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); + const _72: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); const _64: rt.RangeFrom = new rt.RangeFrom(a, rt.i32Step); const _66: { end: rt.i32 } = { end: b }; const _68: { end: rt.i32; inclusive: true } = { end: b, inclusive: true }; const _70: rt.Range = new rt.Range(a, b); - const _72: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); const _74: { end: rt.i32; inclusive: true } = { end: b, inclusive: true }; const _75: undefined = undefined; const _77: rt.Range = new rt.Range(a, b); @@ -2150,9 +2150,8 @@ export function writes(data: rt.ByteSlice, out: rt.ByteVec): void { const c: rt.char = option_unwrapOr$0k15iai(rt.charFromU32(rt.u32Mul(at(0) as rt.u32, 257)), 63); let s: string = ""; const _19: rt.u8 = at(1); - const _23: string = "q\"Ć©"; const _25: rt.u8 = at(2); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_19, f), (f: rt.Formatter) => rt.fmtCharDisplay(c, f), (f: rt.Formatter) => rt.fmtStr(_23, f), (f: rt.Formatter) => rt.u8LowerHex(_25, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_19, f), (f: rt.Formatter) => rt.fmtCharDisplay(c, f), (f: rt.Formatter) => rt.fmtStr("q\"Ć©", f), (f: rt.Formatter) => rt.u8LowerHex(_25, f)]; const written = rt.fmtWriteString(s, ["a", args2[0], "b", rt.fmtSpec({ align: ">", width: 5 }, args2[1]), "|", args2[2], "|", args2[3]]); s = written.s; result(out, written.result); diff --git a/ts/fixtures/lang/shapes/expected/shapes.ts b/ts/fixtures/lang/shapes/expected/shapes.ts index 26d80de1a..1f158fc37 100644 --- a/ts/fixtures/lang/shapes/expected/shapes.ts +++ b/ts/fixtures/lang/shapes/expected/shapes.ts @@ -591,9 +591,8 @@ export function order(data: rt.ByteSlice, out: rt.ByteVec): void { const len: rt.usize = data.length; const _83: rt.ByteSlice = logged(data, out); const _85: rt.usize = rt.min(mark(out, 14), len); - const _87: rt.usize = rt.usizeDiv(rt.min(mark(out, 15), len), 2); + const _82: rt.ByteSlice = rt.byteSliceRange(_83, rt.usizeDiv(rt.min(mark(out, 15), len), 2), _85); const _103: rt.usize = sum; - const _82: rt.ByteSlice = rt.byteSliceRange(_83, _87, _85); const args2: rt.Fmt[] = [(f: rt.Formatter) => Shape.fmt$fmt_Debug(rect, f), (f: rt.Formatter) => Shape.fmt$fmt_Debug(line, f), (f: rt.Formatter) => Pair.fmt$fmt_Debug(pair, f), (f: rt.Formatter) => Point.fmt$fmt_Debug(read, f), (f: rt.Formatter) => Moved.fmt$fmt_Debug(updated, f), (f: rt.Formatter) => Shape.fmt$fmt_Debug(taken, f), (f: rt.Formatter) => rt.usizeDisplay(_64, f), (f: rt.Formatter) => rt.usizeDisplay(_63, f), (f: rt.Formatter) => rt.usizeDisplay(_103, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_82), f, rt.u8Debug)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7], " ", args2[8], " ", args2[9]]))); const _125: rt.usize = mark(out, 16); diff --git a/ts/fixtures/lang/slices/expected/slices.ts b/ts/fixtures/lang/slices/expected/slices.ts index 0685e7bbc..8d7c28e3e 100644 --- a/ts/fixtures/lang/slices/expected/slices.ts +++ b/ts/fixtures/lang/slices/expected/slices.ts @@ -1772,8 +1772,8 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const _60: rt.u8 = rt.u8Rem(kind, 8); if (_60 === 0) { rt.byteSliceFill(rt.byteVecSlice(bytes), c & 0xff); - const part18 = a; - rt.byteSliceFill(rt.byteSliceRange(rt.byteVecSlice(bytes), part18), 90); + const part14 = a; + rt.byteSliceFill(rt.byteSliceRange(rt.byteVecSlice(bytes), part14), 90); rt.sliceRangeMut(words, 0, b).fill(rt.u16Mul(c & 0xffff, 257)); rt.sliceFill(pairs, { a: 1, b: 2 }, copy$slices_Pair); const _81: Pair.Pair | undefined = rt.sliceFirst(pairs); @@ -1887,11 +1887,11 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { rt.byteSliceRotateRight(_258[1], rt.usizeDiv(_258[1].length, 2)); rt.sliceRotateLeft(rt.sliceRangeMut(array, 1), c); } else if (_60 === 4) { - const part9 = a; - rt.byteSliceCopyWithin(rt.byteVecSlice(bytes), part9, b, c); - const part10 = a; + const _276: rt.ByteSlice = rt.byteVecSlice(bytes); + const _278: rt.Range = new rt.Range(a, b); + rt.byteSliceCopyWithin(_276, _278.start, _278.end, c); const _280: rt.u16[] = words; - rt.sliceCopyWithin(_280, part10, _280.length, c); + rt.sliceCopyWithin(_280, new rt.RangeFrom(a, rt.usizeStep).start, _280.length, c); rt.sliceCopyWithin(pairs, 0, b, c, copy$slices_Pair); const _287: Pair.Pair | undefined = rt.sliceGet(pairs, c); if (_287 !== undefined) { @@ -1901,16 +1901,13 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const bounds = rt.boundsRange(new rt.RangeInclusive(a, b, rt.usizeStep), _293.length); rt.sliceCopyWithin(_293, bounds[0], bounds[1], c); flush(out); - const part11 = rt.min(a, 5); - const _302: rt.usize = rt.min(c, 5); const _298: rt.u32[] = array; - rt.sliceCopyWithin(_298, part11, _298.length, _302); - const part12 = rt.usizeDiv(a, 2); - const part13 = rt.usizeDiv(b, 2); - const part: rt.u16[] = rt.sliceRangeMut(words, part12); - rt.sliceCopyWithin(part, part13, part.length, 0); + rt.sliceCopyWithin(_298, new rt.RangeFrom(rt.min(a, 5), rt.usizeStep).start, _298.length, rt.min(c, 5)); + const part: rt.u16[] = rt.sliceRangeMut(words, rt.usizeDiv(a, 2)); + rt.sliceCopyWithin(part, new rt.RangeFrom(rt.usizeDiv(b, 2), rt.usizeStep).start, part.length, 0); const _313: rt.ByteSlice = rt.byteVecSlice(bytes); - const bounds2 = rt.boundsRange([{ tag: "Excluded", _0: a } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound] as [rt.RangeBound, rt.RangeBound], _313.length); + const _315: [rt.RangeBound, rt.RangeBound] = [{ tag: "Excluded", _0: a } as rt.RangeBound, { tag: "Unbounded" } as rt.RangeBound]; + const bounds2 = rt.boundsRange(_315, _313.length); rt.byteSliceCopyWithin(_313, bounds2[0], bounds2[1], c); } else if (_60 === 5) { const _320: [rt.u16[], rt.u16[]] = rt.sliceSplitAtMut(words, a); @@ -1923,11 +1920,10 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_350 !== undefined) { _350.b = 48879; } - const _357: Counted.Counted[] = rt.sliceRangeMut(counted, a); - const part8 = rt.usizeSub(rt.byteSliceRange(data, 3).length, a); - rt.sliceCopyFromSlice(_357, rt.sliceRange(rt.iterToArray(rt.iterMap(new rt.Range(0, c), (n9: rt.usize): Counted.Counted => { + const other: Counted.Counted[] = rt.iterToArray(rt.iterMap(new rt.Range(0, c), (n9: rt.usize): Counted.Counted => { return { n: n9 & 0xff }; - }), undefined, 1, true), 0, part8)); + }), undefined, 1, true); + rt.sliceCopyFromSlice(rt.sliceRangeMut(counted, a), rt.sliceRange(other, 0, rt.usizeSub(rt.byteSliceRange(data, 3).length, a))); flush(out); const more: rt.u32[] = Array.from({ length: 3 }, (): rt.u32 => { return 0; @@ -1954,10 +1950,9 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { if (_434 !== undefined) { _434.b = 48879; } - const part4 = rt.min(b, 3); const _438: rt.u16[] = rt.sliceRangeMut(words, a); const _442: rt.u16[] = [7, 8, 9]; - rt.sliceCopyFromSlice(_438, rt.sliceRange(_442, 0, part4)); + rt.sliceCopyFromSlice(_438, rt.sliceRange(_442, 0, rt.min(b, 3))); rt.sliceCloneFromSlice(rt.sliceRangeMut(items, a), rt.sliceRange(source2, 0, rt.min(b, c)), Noisy.clone$Clone, rt.drop); flush(out); rt.sliceCopyFromSlice(rt.sliceRangeMut(pairs, 0, c), [{ a: 1, b: 1 }, { a: 1, b: 1 }], copy$slices_Pair); diff --git a/ts/fixtures/lang/strs/expected/strs.ts b/ts/fixtures/lang/strs/expected/strs.ts index 624b86bdd..ea965bd50 100644 --- a/ts/fixtures/lang/strs/expected/strs.ts +++ b/ts/fixtures/lang/strs/expected/strs.ts @@ -526,8 +526,7 @@ export function odd(c: rt.char): boolean { /** One edit of `s` by `op`, taking offsets and text from `a` and `b`, through a `&mut`. */ export function edit(s: rt.Place, op: rt.u8, a: rt.u8, b: rt.u8, out: rt.ByteVec): void { let capacity!: rt.usize; - const part = rt.u8Rem(a, 4) as rt.usize; - const piece: string = text(rt.byteSliceRange(rt.byteSliceFrom(Uint8Array.of(a, b, a ^ b)), 0, part)); + const piece: string = text(rt.byteSliceRange(rt.byteSliceFrom(Uint8Array.of(a, b, a ^ b)), 0, rt.u8Rem(a, 4) as rt.usize)); const _17: [rt.usize, rt.usize] = [offset(s.v, a), offset(s.v, b)]; const i: rt.usize = _17[0]; const j: rt.usize = _17[1]; diff --git a/ts/fixtures/stock/expected/buf.ts b/ts/fixtures/stock/expected/buf.ts index 5642610ef..6101e961f 100644 --- a/ts/fixtures/stock/expected/buf.ts +++ b/ts/fixtures/stock/expected/buf.ts @@ -226,8 +226,7 @@ export function read$boxed_Box_dyn_bytes_Buf(buf: rt.Place, n: rt.usize return rt.f32ToBits(getF32Le$bytes_Buf_boxed_Box_dyn_bytes_Buf(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - copyToSlice$bytes_Buf_boxed_Box_dyn_bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + copyToSlice$bytes_Buf_boxed_Box_dyn_bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -311,8 +310,7 @@ export function read$buf_Pieces(buf: Pieces.Pieces, n: rt.usize): rt.u128 { return rt.f32ToBits(Pieces.getF32Le$bytes_Buf(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - Pieces.copyToSlice$bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + Pieces.copyToSlice$bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -396,8 +394,7 @@ export function read$buf_Provided(buf: Provided.Provided, n: rt.usize): rt.u128 return rt.f32ToBits(Provided.getF32Le$bytes_Buf(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - Provided.copyToSlice$bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + Provided.copyToSlice$bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -505,8 +502,7 @@ export function read$bytes_Bytes(buf: rt.Place, n: rt.usize): rt.u return rt.f32ToBits(rt.f32FromBeBytes(rt.bytesRead(buf, 4, true))) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - rt.bytesCopyToSlice(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + rt.bytesCopyToSlice(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -614,8 +610,7 @@ export function read$bytes_BytesMut(buf: rt.BytesMut, n: rt.usize): rt.u128 { return rt.f32ToBits(rt.f32FromBeBytes(rt.bytesMutRead(buf, 4, true))) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - rt.bytesMutCopyToSlice(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + rt.bytesMutCopyToSlice(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -699,8 +694,7 @@ export function read$bytes_buf_Take_bytes_Bytes(buf: Take.Take, n: return rt.f32ToBits(Take.getF32Le$bytes_Buf_bytes_Bytes(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - Take.copyToSlice$bytes_Buf_bytes_Bytes(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + Take.copyToSlice$bytes_Buf_bytes_Bytes(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -782,8 +776,7 @@ export function read$dyn_buf_Leased(buf: Leased.Leased, n: rt.usize): rt.u128 { return rt.f32ToBits(buf.getF32Le$Buf()) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - buf.copyToSlice$Buf(rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + buf.copyToSlice$Buf(rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -865,8 +858,7 @@ export function read$dyn_bytes_Buf(buf: Buf.Buf, n: rt.usize): rt.u128 { return rt.f32ToBits(buf.getF32Le$Buf()) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - buf.copyToSlice$Buf(rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + buf.copyToSlice$Buf(rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -956,8 +948,7 @@ export function read$mut_buf_Pieces(buf: rt.Place, n: rt.usize): return rt.f32ToBits(Pieces.getF32Le$bytes_Buf_mut(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - Pieces.copyToSlice$bytes_Buf_mut(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + Pieces.copyToSlice$bytes_Buf_mut(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -1047,8 +1038,7 @@ export function read$mut_bytes_Bytes(buf: rt.Place>, n: r return rt.f32ToBits(getF32Le$bytes_Buf_mut_bytes_Bytes(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - copyToSlice$bytes_Buf_mut_bytes_Bytes(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + copyToSlice$bytes_Buf_mut_bytes_Bytes(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -1138,8 +1128,7 @@ export function read$mut_dyn_bytes_Buf(buf: rt.Place, n: rt.usize): rt. return rt.f32ToBits(getF32Le$bytes_Buf_mut_dyn_bytes_Buf(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - copyToSlice$bytes_Buf_mut_dyn_bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + copyToSlice$bytes_Buf_mut_dyn_bytes_Buf(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -1229,8 +1218,7 @@ export function read$mut_ref_slice_u8(buf: rt.Place>, n: return rt.f32ToBits(getF32Le$bytes_Buf_mut_ref_slice_u8(buf)) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - copyToSlice$bytes_Buf_mut_ref_slice_u8(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + copyToSlice$bytes_Buf_mut_ref_slice_u8(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -1338,8 +1326,7 @@ export function read$ref_slice_u8(buf: rt.Place, n: rt.usize): rt. return rt.f32ToBits(rt.f32FromBeBytes(rt.bytesRead(buf, 4, true))) as rt.u128; } const dst: Uint8Array = rt.bytes(3); - const part = rt.usizeRem(n, 4); - rt.bytesCopyToSlice(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, part)); + rt.bytesCopyToSlice(buf, rt.byteSliceRange(rt.byteSliceFrom(dst), 0, rt.usizeRem(n, 4))); return ((dst[0] << 16) | (dst[1] << 8) | dst[2]) as rt.u128; } @@ -1800,8 +1787,7 @@ export function writeAll$Vec_u8(buf: rt.ByteVec, dataData: Uint8Array, dataStart const _45: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(112, 117, 116)); rt.byteVecExtendFromSlice(buf, _45); } else if (_19 === 14) { - const part = rt.usizeRem(n2 as rt.usize, 71); - const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, part); + const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, rt.usizeRem(n2 as rt.usize, 71)); rt.byteVecExtendFromSlice(buf, _48); } else if (_19 === 15) { const _55: rt.BytesMut = rt.bytesMutFrom(rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(3).fill(n2)), 0)); @@ -1883,8 +1869,7 @@ export function writeAll$boxed_Box_Vec_u8(buf: rt.Place, dataData: U const _45: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(112, 117, 116)); rt.byteVecPutChunked(buf.v, _45); } else if (_19 === 14) { - const part = rt.usizeRem(n2 as rt.usize, 71); - const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, part); + const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, rt.usizeRem(n2 as rt.usize, 71)); rt.byteVecPutChunked(buf.v, _48); } else if (_19 === 15) { const _55: rt.BytesMut = rt.bytesMutFrom(rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(3).fill(n2)), 0)); @@ -1966,8 +1951,7 @@ export function writeAll$boxed_Box_bytes_BytesMut(buf: rt.Place, da const _45: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(112, 117, 116)); rt.bytesMutPutChunked(buf.v, _45); } else if (_19 === 14) { - const part = rt.usizeRem(n2 as rt.usize, 71); - const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, part); + const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, rt.usizeRem(n2 as rt.usize, 71)); rt.bytesMutPutChunked(buf.v, _48); } else if (_19 === 15) { const _55: rt.BytesMut = rt.bytesMutFrom(rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(3).fill(n2)), 0)); @@ -2049,8 +2033,7 @@ export function writeAll$bytes_BytesMut(buf: rt.BytesMut, dataData: Uint8Array, const _45: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(112, 117, 116)); rt.bytesMutPutStorage(buf, _45); } else if (_19 === 14) { - const part = rt.usizeRem(n2 as rt.usize, 71); - const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, part); + const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, rt.usizeRem(n2 as rt.usize, 71)); rt.bytesMutExtend(buf, _48); } else if (_19 === 15) { const _55: rt.BytesMut = rt.bytesMutFrom(rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(3).fill(n2)), 0)); @@ -2132,8 +2115,7 @@ export function writeAll$mut_Vec_u8(buf: rt.Place, dataData: Uint8Ar const _45: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(112, 117, 116)); rt.byteVecPutChunked(buf.v, _45); } else if (_19 === 14) { - const part = rt.usizeRem(n2 as rt.usize, 71); - const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, part); + const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, rt.usizeRem(n2 as rt.usize, 71)); rt.byteVecPutChunked(buf.v, _48); } else if (_19 === 15) { const _55: rt.BytesMut = rt.bytesMutFrom(rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(3).fill(n2)), 0)); @@ -2215,8 +2197,7 @@ export function writeAll$mut_bytes_BytesMut(buf: rt.Place, dataData const _45: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(112, 117, 116)); rt.bytesMutPutChunked(buf.v, _45); } else if (_19 === 14) { - const part = rt.usizeRem(n2 as rt.usize, 71); - const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, part); + const _48: rt.ByteSlice = rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(70).fill(op2)), 0, rt.usizeRem(n2 as rt.usize, 71)); rt.bytesMutPutChunked(buf.v, _48); } else if (_19 === 15) { const _55: rt.BytesMut = rt.bytesMutFrom(rt.byteSliceRange(rt.byteSliceFrom(rt.bytes(3).fill(n2)), 0)); diff --git a/ts/runtime/rt/task.ts b/ts/runtime/rt/task.ts index b7f160aee..37d0a5dbc 100644 --- a/ts/runtime/rt/task.ts +++ b/ts/runtime/rt/task.ts @@ -4,7 +4,7 @@ // A value whose drop JS can observe has `[Symbol.dispose]`, which runs its `Drop` impl // and drops its fields. `None` is `undefined`, which drops as nothing. -import { Abort, type Debug, debugTupleField, debugTupleFinish, Err, type FmtResult, type Formatter, fmtDebugTuple, fmtPad, type None, OK, Ok, Panic, panic, type Place, place, ptrWrite, type Result, vecAssign } from "../rt.ts"; +import { Abort, type Debug, debugStructField, debugStructFinish, debugStructFinishNonExhaustive, debugTupleField, debugTupleFinish, Err, type Fmt, type FmtResult, type Formatter, fmtBool, fmtDebugStruct, fmtDebugTuple, fmtPad, fmtStr, type None, OK, Ok, Panic, panic, type Place, place, ptrWrite, type Result, vecAssign } from "../rt.ts"; // Drops @@ -349,6 +349,17 @@ export class Mutex implements Disposable { } } +/** `Debug` of a `Mutex`: its value, or `""`, a string, while a guard holds it. */ +export function mutexDebug(mutex: Mutex, f: Formatter, debug: Debug): FmtResult { + return lockDebug(f, "Mutex", mutex.locked ? (f) => fmtStr("", f) : (f) => debug(mutex.value, f)); +} + +/** `Debug` of a lock named `name`: `data`, then that it is never poisoned, as a panic aborts. */ +function lockDebug(f: Formatter, name: string, data: Fmt): FmtResult { + const b = debugStructField(fmtDebugStruct(f, name), "data", data); + return debugStructFinishNonExhaustive(debugStructField(b, "poisoned", (f) => fmtBool(false, f))); +} + /** `TryLockError`, tagged as the crate's own enums are; a panic aborts, so it is never `Poisoned`. */ export type TryLockError = { readonly tag: "Poisoned"; readonly _0: T } | { readonly tag: "WouldBlock" }; @@ -466,6 +477,17 @@ export function refCellReplace(cell: RefCell, value: T): T { return old; } +/** `Debug` of a `RefCell`: its value, or `` unpadded while borrowed exclusively. */ +export function refCellDebug(cell: RefCell, f: Formatter, debug: Debug): FmtResult { + const value: Fmt = cell.borrows < 0 ? (f) => f.out.writeStr("") : (f) => debug(cell.value, f); + return debugStructFinish(debugStructField(fmtDebugStruct(f, "RefCell"), "value", value)); +} + +/** `Debug` of an `RwLock`: its value, or `` unpadded while written. */ +export function rwLockDebug(lock: RefCell, f: Formatter, debug: Debug): FmtResult { + return lockDebug(f, "RwLock", lock.borrows < 0 ? (f) => f.out.writeStr("") : (f) => debug(lock.value, f)); +} + /** `RwLock::read`: a shared guard, which aborts while a write is held, as wasm32's does. */ export function rwLockRead(lock: RefCell): RefCell { if (lock.borrows < 0) throw new Abort("rwlock locked for writing"); @@ -679,6 +701,11 @@ export class Cell implements Place, Disposable { } } +/** `Debug` of a `Cell` of a `Copy` value. */ +export function cellDebug(cell: Cell, f: Formatter, debug: Debug): FmtResult { + return debugStructFinish(debugStructField(fmtDebugStruct(f, "Cell"), "value", (f) => debug(cell.v, f))); +} + /** `Cell::from_mut` of the place `p`: a cell of it, which nothing drops, as nothing owns it. */ export function cellOfPlace(p: Place): Cell { return p as Cell; diff --git a/ts/src/lower/fmt.rs b/ts/src/lower/fmt.rs index 140e54a09..7ccace5ac 100644 --- a/ts/src/lower/fmt.rs +++ b/ts/src/lower/fmt.rs @@ -437,6 +437,21 @@ pub fn std_impl<'tcx>( (Std::BorrowError, Trait::Display) => Expr::rt("borrowErrorDisplay", vec![value, f]), (Std::BorrowMutError, Trait::Debug) => Expr::rt("borrowMutErrorDebug", vec![value, f]), (Std::BorrowMutError, Trait::Display) => Expr::rt("borrowMutErrorDisplay", vec![value, f]), + // What each holds, or what keeps it from being read; a `Cell`'s value is `Copy`. An + // `RwLock` shares a `RefCell`'s representation, and an `UnsafeCell` a `Cell`'s. + (Std::Cell, Trait::Debug) if tcx.is_lang_item(adt.did(), rustc_attr_ir::LangItem::UnsafeCell) => { + rt("writeStr", vec![f, Expr::Str("UnsafeCell { .. }".into())]) + } + (std @ (Std::RefCell | Std::Mutex | Std::Cell), Trait::Debug) => { + let debug = match std { + Std::RefCell if tcx.is_diagnostic_item(rustc_span::sym::RwLock, adt.did()) => "rwLockDebug", + Std::RefCell => "refCellDebug", + Std::Mutex => "mutexDebug", + _ => "cellDebug", + }; + let held = b.fmt_fn(tr, args.type_at(0), span); + Expr::rt(debug, vec![value, f, held]) + } // What it holds, or ``. (std @ (Std::OnceCell | Std::OnceLock), Trait::Debug) => { let held = b.fmt_fn(tr, args.type_at(0), span); diff --git a/ts/src/lower/mir/mod.rs b/ts/src/lower/mir/mod.rs index 3ace9fd18..39b4f0fb4 100644 --- a/ts/src/lower/mir/mod.rs +++ b/ts/src/lower/mir/mod.rs @@ -2109,8 +2109,9 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { }); } - /// Emit the pending temporaries `e` reads, and those held back before them, so that - /// `e` can be read more than once, or later. + /// Emit the pending temporaries `e` reads, those held back before them, and those + /// after them that do or read anything, so that `e` can be read more than once, or + /// later. What `out` gathers is often emitted after, which would run those first. pub(super) fn materialize(&mut self, e: &Expr, out: &mut Vec) { let mut names = Vec::new(); reads_of(e, &mut names); @@ -2124,7 +2125,8 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { return; }; let pending = std::mem::take(&mut self.pending); - let (flush, keep): (Vec, Vec) = pending.into_iter().partition(|p| p.order <= last); + let (flush, keep): (Vec, Vec) = + (pending.into_iter()).partition(|p| p.order <= last || p.effect || p.memory); self.pending = keep; for p in flush { self.flush_one(p, out); From 31cf8f551ba51a88e1c80db1e2022330c297ff9f Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 2 Nov 2026 21:21:29 -0800 Subject: [PATCH 3/4] fix(ts): hold a cell's or a lock's guard while its Debug writes its value Co-Authored-By: Claude Opus 5.5 --- ts/fixtures/lang/borrows/caller.ts | 5 +- .../lang/borrows/expected/borrows.Probe.ts | 37 +++++++++++++ .../lang/borrows/expected/borrows.Shown.ts | 2 +- ts/fixtures/lang/borrows/expected/borrows.ts | 26 ++++++---- ts/fixtures/lang/borrows/expected/lib.ts | 13 +++++ ts/fixtures/lang/borrows/src/borrows.rs | 24 +++++++-- ts/fixtures/lang/locks/caller.ts | 4 +- .../lang/locks/expected/core/option.ts | 15 ++++++ ts/fixtures/lang/locks/expected/lib.ts | 43 +++++++++++++++ .../lang/locks/expected/locks.Probe.ts | 50 ++++++++++++++++++ ts/fixtures/lang/locks/expected/locks.ts | 52 +++++++++++++------ ts/fixtures/lang/locks/src/locks.rs | 41 +++++++++++++-- ts/runtime/rt/task.ts | 47 ++++++++++++----- ts/src/lower/fmt.rs | 16 ++++-- 14 files changed, 319 insertions(+), 56 deletions(-) create mode 100644 ts/fixtures/lang/borrows/expected/borrows.Probe.ts create mode 100644 ts/fixtures/lang/locks/expected/locks.Probe.ts diff --git a/ts/fixtures/lang/borrows/caller.ts b/ts/fixtures/lang/borrows/caller.ts index 972de77cd..25aee8a46 100644 --- a/ts/fixtures/lang/borrows/caller.ts +++ b/ts/fixtures/lang/borrows/caller.ts @@ -51,9 +51,10 @@ const leaks = [[0x00, 0x01, 0x02, 0xf1, 0xf2, 0x04, 0x05, 0x03, 0x06], [0xe3], [ /** * `borrows::printed` scripts: each cell printed, free, shared, and borrowed exclusively, - * nested and through guards, more than once so that what each holds grows. + * nested, through guards, and borrowed while it writes what it holds, more than once so + * that what each holds grows. */ -const printed = [[0x00, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x18, 0xf1, 0x12, 0xfb, 0x24, 0x2d], []].map((bytes) => +const printed = [[0x00, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0xf1, 0x12, 0xfb, 0x24, 0x2d], []].map((bytes) => Uint8Array.of(...op("borrows::printed"), 0, ...bytes), ); diff --git a/ts/fixtures/lang/borrows/expected/borrows.Probe.ts b/ts/fixtures/lang/borrows/expected/borrows.Probe.ts new file mode 100644 index 000000000..6e8d9615a --- /dev/null +++ b/ts/fixtures/lang/borrows/expected/borrows.Probe.ts @@ -0,0 +1,37 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { drop$Result_cell_RefMut_borrows_Probe_cell_BorrowMutError, drop$Result_cell_Ref_borrows_Probe_cell_BorrowError } from "./lib.ts"; + +/** + * Writes whether the cell it is in can be borrowed, shared and exclusively, and how it + * writes, while the cell writes it. + */ +export class Probe { + _0: rt.Weak>; + + constructor(_0: rt.Weak>) { + this._0 = _0; + } + + [Symbol.dispose](): void { + this._0[Symbol.dispose](); + } +} + +export function fmt$fmt_Debug(self: Probe, f: rt.Formatter): rt.Result { + const cell: rt.Arc> = rt.optionUnwrap(rt.weakUpgrade(self._0)); + const _8: rt.Result, rt.BorrowError> = rt.refCellTryBorrow(cell.value); + const shared: boolean = _8.ok; + drop$Result_cell_Ref_borrows_Probe_cell_BorrowError(_8); + const _13: rt.Result, rt.BorrowMutError> = rt.refCellTryBorrowMut(cell.value); + const exclusive: boolean = _13.ok; + drop$Result_cell_RefMut_borrows_Probe_cell_BorrowMutError(_13); + const _19: boolean = rt.fmtAlternate(f); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(shared, f), (f: rt.Formatter) => rt.fmtBool(exclusive, f), (f: rt.Formatter) => rt.fmtBool(_19, f)]; + const _0: rt.Result = rt.fmtWriteFmt(f, [args2[0], " ", args2[1], " ", args2[2]]); + cell[Symbol.dispose](); + return _0; +} + +//# sourceMappingURL=borrows.Probe.ts.map diff --git a/ts/fixtures/lang/borrows/expected/borrows.Shown.ts b/ts/fixtures/lang/borrows/expected/borrows.Shown.ts index 48a06186b..dbf752b93 100644 --- a/ts/fixtures/lang/borrows/expected/borrows.Shown.ts +++ b/ts/fixtures/lang/borrows/expected/borrows.Shown.ts @@ -5,7 +5,7 @@ import * as rt from "./rt.ts"; export function fmt$fmt_Debug(self: Shown, f: rt.Formatter): rt.Result { const _3: string = "Shown"; const _4: string = "cell"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.cellDebug(self.cell, f, rt.u8Debug); + const _5: rt.Fmt = (f: rt.Formatter) => rt.cellDebug(self.cell.v, f, rt.u8Debug); const _7: string = "refcell"; const _8: rt.Fmt = (f: rt.Formatter) => rt.refCellDebug(self.refcell, f, (value: rt.ByteVec, f: rt.Formatter) => rt.fmtList(rt.byteVecView(value), f, rt.u8Debug)); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); diff --git a/ts/fixtures/lang/borrows/expected/borrows.ts b/ts/fixtures/lang/borrows/expected/borrows.ts index 7a13c1354..a639861c3 100644 --- a/ts/fixtures/lang/borrows/expected/borrows.ts +++ b/ts/fixtures/lang/borrows/expected/borrows.ts @@ -5,6 +5,7 @@ import { copy$Option_tuple2_u64_u64, copy$tuple2_u64_u64, drop$Result_cell_RefMu import * as Noisy from "./borrows.Noisy.ts"; import * as Parts from "./borrows.Parts.ts"; import * as Polling from "./borrows.Polling.ts"; +import * as Probe from "./borrows.Probe.ts"; import * as Shown from "./borrows.Shown.ts"; import * as Tagged from "./borrows.Tagged.ts"; import { thenSome$0zrlsto, thenSome$0d5am30, then$1jgls7y } from "./core/bool.ts"; @@ -1072,9 +1073,9 @@ export function flush(log: rt.Mutex, out: rt.ByteVec): void { /** * Each byte an operation on cells printed by `Debug`, its value the operand: a `RefCell` * free, shared, and borrowed exclusively, which writes `` with no options, plain, - * pretty, padded, and as a `&dyn Debug`; cells nested in cells, a vector, and a derived - * `Debug`; guards of cells, which write the cell they lend; and `Cell`s of `Copy` values - * and an `UnsafeCell`. + * pretty, padded, and as a `&dyn Debug`, and borrowed shared while it writes what it + * holds; cells nested in cells, a vector, and a derived `Debug`; guards of cells, which + * write the cell they lend; and `Cell`s of `Copy` values and an `UnsafeCell`. */ export function printed(data: rt.ByteSlice, out: rt.ByteVec): void { let text!: string; @@ -1140,7 +1141,7 @@ export function printed(data: rt.ByteSlice, out: rt.ByteVec): void { const wide: rt.Cell = new rt.Cell(rt.u64Shl(v as rt.u64, 56)); const maybe: rt.Cell = new rt.Cell(thenSome$0d5am30(rt.u8Rem(v, 2) === 0, v)); const _184: rt.Cell = new rt.Cell(undefined); - const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.cellDebug(pair, f, (value: [rt.u8, rt.char], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.fmtCharDebug(value[1], f)], f)), (f: rt.Formatter) => rt.cellDebug(wide, f, rt.u64Debug), (f: rt.Formatter) => rt.cellDebug(maybe, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug)), (f: rt.Formatter) => rt.cellDebug(_184, f, rt.fmtUnit)]; + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.cellDebug(pair.v, f, (value: [rt.u8, rt.char], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(value[0], f), (f: rt.Formatter) => rt.fmtCharDebug(value[1], f)], f)), (f: rt.Formatter) => rt.cellDebug(wide.v, f, rt.u64Debug), (f: rt.Formatter) => rt.cellDebug(maybe.v, f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug)), (f: rt.Formatter) => rt.cellDebug(_184.v, f, rt.fmtUnit)]; text = rt.fmtFormat([args18[0], " ", rt.fmtSpec({ alternate: true }, args18[0]), " ", args18[1], " ", args18[2], " ", rt.fmtSpec({ alternate: true }, args18[2]), " ", args18[3], " ", rt.fmtSpec({ align: ">", width: 3 }, args18[0])]); } else if (_25 === 4) { rt.cellSet(shown.cell, v); @@ -1156,13 +1157,20 @@ export function printed(data: rt.ByteSlice, out: rt.ByteVec): void { } else if (_25 === 5) { new rt.Cell(v); const inRefcell: rt.RefCell> = new rt.RefCell(new rt.Cell(v)); - const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, "UnsafeCell { .. }"), (f: rt.Formatter) => rt.refCellDebug(inRefcell, f, (value: rt.Cell, f: rt.Formatter) => rt.cellDebug(value, f, rt.u8Debug))]; + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, "UnsafeCell { .. }"), (f: rt.Formatter) => rt.refCellDebug(inRefcell, f, (value: rt.Cell, f: rt.Formatter) => rt.cellDebug(value.v, f, rt.u8Debug))]; text = rt.fmtFormat([args24[0], " ", rt.fmtSpec({ alternate: true }, args24[0]), " ", args24[1], " ", rt.fmtSpec({ alternate: true }, args24[1])]); + } else if (_25 === 6) { + const probe: rt.Arc> = rt.arcNewCyclic((me: rt.Weak>): rt.RefCell => { + return new rt.RefCell(new Probe.Probe(rt.weakClone(me))); + }); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(probe.value, f, (value: Probe.Probe, f: rt.Formatter) => Probe.fmt$fmt_Debug(value, f))]; + text = rt.fmtFormat([args26[0], " ", rt.fmtSpec({ alternate: true }, args26[0])]); + probe[Symbol.dispose](); } else { - const _244: rt.RefCell = new rt.RefCell("s"); - const _247: rt.RefCell = new rt.RefCell(rt.bytes(2).fill(v)); - const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(_244, f, rt.fmtStr), (f: rt.Formatter) => rt.refCellDebug(_247, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; - text = rt.fmtFormat([args26[0], " ", args26[1]]); + const _253: rt.RefCell = new rt.RefCell("s"); + const _256: rt.RefCell = new rt.RefCell(rt.bytes(2).fill(v)); + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.refCellDebug(_253, f, rt.fmtStr), (f: rt.Formatter) => rt.refCellDebug(_256, f, (value: Uint8Array, f: rt.Formatter) => rt.fmtList(value, f, rt.u8Debug))]; + text = rt.fmtFormat([args28[0], " ", args28[1]]); } rt.byteVecExtendFromSlice(out, rt.stringAsBytes(text)); } diff --git a/ts/fixtures/lang/borrows/expected/lib.ts b/ts/fixtures/lang/borrows/expected/lib.ts index d1b91b55d..59cbc5a78 100644 --- a/ts/fixtures/lang/borrows/expected/lib.ts +++ b/ts/fixtures/lang/borrows/expected/lib.ts @@ -3,6 +3,7 @@ import * as rt from "./rt.ts"; import { borrows, guards, maps, tries, leaks, printed } from "./borrows.ts"; import type * as Parts from "./borrows.Parts.ts"; +import type * as Probe from "./borrows.Probe.ts"; import type * as Tagged from "./borrows.Tagged.ts"; export function copy$Option_tuple2_u64_u64(v: [rt.u64, rt.u64] | undefined): [rt.u64, rt.u64] | undefined { @@ -43,6 +44,12 @@ export function drop$Result_cell_RefMut_borrows_Parts_cell_BorrowMutError(_1: rt } } +export function drop$Result_cell_RefMut_borrows_Probe_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } +} + export function drop$Result_cell_RefMut_borrows_Tagged_cell_BorrowMutError(_1: rt.Result, rt.BorrowMutError>): void { if (_1.ok) { rt.refMutRelease(_1.value); @@ -87,6 +94,12 @@ export function drop$Result_cell_Ref_borrows_Parts_cell_BorrowError(_1: rt.Resul } } +export function drop$Result_cell_Ref_borrows_Probe_cell_BorrowError(_1: rt.Result, rt.BorrowError>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } +} + export function drop$Result_cell_Ref_ref_str_tuple2_cell_Ref_tuple2_u8_ref_str_u8(_1: rt.Result, [rt.RefCell<[rt.u8, string]>, rt.u8]>): void { if (_1.ok) { rt.refRelease(_1.value); diff --git a/ts/fixtures/lang/borrows/src/borrows.rs b/ts/fixtures/lang/borrows/src/borrows.rs index ab154c221..69003dc52 100644 --- a/ts/fixtures/lang/borrows/src/borrows.rs +++ b/ts/fixtures/lang/borrows/src/borrows.rs @@ -728,11 +728,24 @@ struct Shown { refcell: RefCell>, } +/// Writes whether the cell it is in can be borrowed, shared and exclusively, and how it +/// writes, while the cell writes it. +struct Probe(std::rc::Weak>); + +impl std::fmt::Debug for Probe { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let cell = self.0.upgrade().unwrap(); + let shared = cell.try_borrow().is_ok(); + let exclusive = cell.try_borrow_mut().is_ok(); + write!(f, "{shared} {exclusive} {}", f.alternate()) + } +} + /// Each byte an operation on cells printed by `Debug`, its value the operand: a `RefCell` /// free, shared, and borrowed exclusively, which writes `` with no options, plain, -/// pretty, padded, and as a `&dyn Debug`; cells nested in cells, a vector, and a derived -/// `Debug`; guards of cells, which write the cell they lend; and `Cell`s of `Copy` values -/// and an `UnsafeCell`. +/// pretty, padded, and as a `&dyn Debug`, and borrowed shared while it writes what it +/// holds; cells nested in cells, a vector, and a derived `Debug`; guards of cells, which +/// write the cell they lend; and `Cell`s of `Copy` values and an `UnsafeCell`. pub fn printed(data: &[u8], out: &mut Vec) { let number = RefCell::new(0u32); let nested = RefCell::new(vec![RefCell::new(Some(0u8))]); @@ -793,6 +806,11 @@ pub fn printed(data: &[u8], out: &mut Vec) { let in_refcell = RefCell::new(Cell::new(v)); format!("{unsafe_cell:?} {unsafe_cell:#?} {in_refcell:?} {in_refcell:#?}") } + // Borrowed while it writes what it holds. + 6 => { + let probe = std::rc::Rc::new_cyclic(|me| RefCell::new(Probe(me.clone()))); + format!("{probe:?} {probe:#?}") + } _ => format!("{:?} {:?}", RefCell::new(String::from("s")), RefCell::new([v; 2])), }; out.extend_from_slice(text.as_bytes()); diff --git a/ts/fixtures/lang/locks/caller.ts b/ts/fixtures/lang/locks/caller.ts index 23e50e92e..bfa4e6873 100644 --- a/ts/fixtures/lang/locks/caller.ts +++ b/ts/fixtures/lang/locks/caller.ts @@ -39,7 +39,7 @@ const downgrades = [[0x00, 0x01, 0x11, 0x02, 0xf2, 0xe2, 0x03, 0x04, 0x13, 0x05] /** `locks::rwlocks` scripts: `get_mut` and `into_inner` among writes and reads. */ const rwlocks = [[6, 7, 0, 6, 2, 14, 15, 1]].map((bytes) => Uint8Array.of(...op("locks::rwlocks"), 0, ...bytes)); -/** `locks::shown` scripts: each lock printed, free, read, held, and written, nested. */ -const shown = [[0x00, 0x05, 0x06, 0x07, 0xfc, 0x09, 0x0a]].map((bytes) => Uint8Array.of(...op("locks::shown"), 0, ...bytes)); +/** `locks::shown` scripts: each lock printed, free, read, held, and written, nested, and locked while it writes what it holds. */ +const shown = [[0, 6, 11, 2, 3, 8, 4, 125, 7]].map((bytes) => Uint8Array.of(...op("locks::shown"), 0, ...bytes)); export const cases: Uint8Array[] = [...locks, ...mappedLocks, ...relocks, ...mutexMaps, ...printed, ...downgrades, ...rwlocks, ...shown]; diff --git a/ts/fixtures/lang/locks/expected/core/option.ts b/ts/fixtures/lang/locks/expected/core/option.ts index d13e15db8..4c49bd1c8 100644 --- a/ts/fixtures/lang/locks/expected/core/option.ts +++ b/ts/fixtures/lang/locks/expected/core/option.ts @@ -1,6 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "../rt.ts"; +import type * as Probe from "../locks.Probe.ts"; export function unwrapOr$1iemzn8(self: string | undefined, default_: string): string { if (self === undefined) { @@ -16,4 +17,18 @@ export function unwrapOr$0r2bmpr(self: rt.u8 | undefined, default_: rt.u8): rt.u return self; } +export function map$16br6l4(self: rt.Arc> | undefined, f: (a0: rt.Arc>) => boolean): boolean | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + +export function map$1uijrx3(self: rt.Arc>> | undefined, f: (a0: rt.Arc>>) => boolean): boolean | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + //# sourceMappingURL=option.ts.map diff --git a/ts/fixtures/lang/locks/expected/lib.ts b/ts/fixtures/lang/locks/expected/lib.ts index ad3f9e2c7..ea5bc8b73 100644 --- a/ts/fixtures/lang/locks/expected/lib.ts +++ b/ts/fixtures/lang/locks/expected/lib.ts @@ -2,6 +2,7 @@ import * as rt from "./rt.ts"; import { locks, relock, rwlocks, mapped, mutexMapped, printed, downgraded, shown } from "./locks.ts"; +import type * as Probe from "./locks.Probe.ts"; import type * as Tally from "./locks.Tally.ts"; export function drop$Result_Result_sync_MappedMutexGuard_u64_sync_MappedMutexGuard_u64_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.Mutex>, rt.Mutex>): void { @@ -52,6 +53,14 @@ export function drop$Result_sync_MutexGuard_array4_u8_sync_TryLockError_sync_Mut } } +export function drop$Result_sync_MutexGuard_locks_Probe_sync_TryLockError_sync_MutexGuard_locks_Probe(_1: rt.Result, rt.TryLockError>>): void { + if (_1.ok) { + rt.mutexUnlock(_1.value); + } else { + drop$sync_TryLockError_sync_MutexGuard_locks_Probe(_1.error); + } +} + export function drop$Result_sync_MutexGuard_locks_Tally_sync_TryLockError_sync_MutexGuard_locks_Tally(_1: rt.Result, rt.TryLockError>>): void { if (_1.ok) { rt.mutexUnlock(_1.value); @@ -92,6 +101,14 @@ export function drop$Result_sync_RwLockReadGuard_locks_Tally_sync_TryLockError_s } } +export function drop$Result_sync_RwLockReadGuard_sync_Mutex_locks_Probe_sync_TryLockError_sync_RwLockReadGuard_sync_Mutex_locks_Probe(_1: rt.Result>, rt.TryLockError>>>): void { + if (_1.ok) { + rt.refRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockReadGuard_sync_Mutex_locks_Probe(_1.error); + } +} + export function drop$Result_sync_RwLockReadGuard_u32_sync_TryLockError_sync_RwLockReadGuard_u32(_1: rt.Result, rt.TryLockError>>): void { if (_1.ok) { rt.refRelease(_1.value); @@ -116,6 +133,14 @@ export function drop$Result_sync_RwLockWriteGuard_locks_Tally_sync_TryLockError_ } } +export function drop$Result_sync_RwLockWriteGuard_sync_Mutex_locks_Probe_sync_TryLockError_sync_RwLockWriteGuard_sync_Mutex_locks_Probe(_1: rt.Result>, rt.TryLockError>>>): void { + if (_1.ok) { + rt.refMutRelease(_1.value); + } else { + drop$sync_TryLockError_sync_RwLockWriteGuard_sync_Mutex_locks_Probe(_1.error); + } +} + export function drop$Result_sync_RwLockWriteGuard_u32_sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.Result, rt.TryLockError>>): void { if (_1.ok) { rt.refMutRelease(_1.value); @@ -130,6 +155,12 @@ export function drop$sync_TryLockError_sync_MutexGuard_array4_u8(_1: rt.TryLockE } } +export function drop$sync_TryLockError_sync_MutexGuard_locks_Probe(_1: rt.TryLockError>): void { + if (_1.tag === "Poisoned") { + rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); + } +} + export function drop$sync_TryLockError_sync_MutexGuard_locks_Tally(_1: rt.TryLockError>): void { if (_1.tag === "Poisoned") { rt.mutexUnlock((_1 as { tag: "Poisoned"; _0: rt.Mutex })._0); @@ -160,6 +191,12 @@ export function drop$sync_TryLockError_sync_RwLockReadGuard_locks_Tally(_1: rt.T } } +export function drop$sync_TryLockError_sync_RwLockReadGuard_sync_Mutex_locks_Probe(_1: rt.TryLockError>>): void { + if (_1.tag === "Poisoned") { + rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell> })._0); + } +} + export function drop$sync_TryLockError_sync_RwLockReadGuard_u32(_1: rt.TryLockError>): void { if (_1.tag === "Poisoned") { rt.refRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); @@ -178,6 +215,12 @@ export function drop$sync_TryLockError_sync_RwLockWriteGuard_locks_Tally(_1: rt. } } +export function drop$sync_TryLockError_sync_RwLockWriteGuard_sync_Mutex_locks_Probe(_1: rt.TryLockError>>): void { + if (_1.tag === "Poisoned") { + rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell> })._0); + } +} + export function drop$sync_TryLockError_sync_RwLockWriteGuard_u32(_1: rt.TryLockError>): void { if (_1.tag === "Poisoned") { rt.refMutRelease((_1 as { tag: "Poisoned"; _0: rt.RefCell })._0); diff --git a/ts/fixtures/lang/locks/expected/locks.Probe.ts b/ts/fixtures/lang/locks/expected/locks.Probe.ts new file mode 100644 index 000000000..c61403ce9 --- /dev/null +++ b/ts/fixtures/lang/locks/expected/locks.Probe.ts @@ -0,0 +1,50 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { drop$Result_sync_MutexGuard_locks_Probe_sync_TryLockError_sync_MutexGuard_locks_Probe, drop$Result_sync_RwLockReadGuard_sync_Mutex_locks_Probe_sync_TryLockError_sync_RwLockReadGuard_sync_Mutex_locks_Probe, drop$Result_sync_RwLockWriteGuard_sync_Mutex_locks_Probe_sync_TryLockError_sync_RwLockWriteGuard_sync_Mutex_locks_Probe } from "./lib.ts"; +import { map$16br6l4 as option_map$16br6l4, map$1uijrx3 as option_map$1uijrx3 } from "./core/option.ts"; + +/** Writes whether the locks it is in can be locked, and how it writes, while they write it. */ +export class Probe { + mutex: rt.Weak>; + lock: rt.Weak>>; + + constructor(mutex: rt.Weak>, lock: rt.Weak>>) { + this.mutex = mutex; + this.lock = lock; + } + + [Symbol.dispose](): void { + this.mutex[Symbol.dispose](); + this.lock[Symbol.dispose](); + } +} + +export function fmt$fmt_Debug(self: Probe, f: rt.Formatter): rt.Result { + const mutex: boolean | undefined = option_map$16br6l4(rt.weakUpgrade(self.mutex), (m: rt.Arc>): boolean => { + const _42: rt.Result, rt.TryLockError>> = rt.mutexTryLock(m.value); + const _02: boolean = _42.ok; + drop$Result_sync_MutexGuard_locks_Probe_sync_TryLockError_sync_MutexGuard_locks_Probe(_42); + m[Symbol.dispose](); + return _02; + }); + const read: boolean | undefined = option_map$1uijrx3(rt.weakUpgrade(self.lock), (l: rt.Arc>>): boolean => { + const _43: rt.Result>, rt.TryLockError>>> = rt.rwLockTryRead(l.value); + const _03: boolean = _43.ok; + drop$Result_sync_RwLockReadGuard_sync_Mutex_locks_Probe_sync_TryLockError_sync_RwLockReadGuard_sync_Mutex_locks_Probe(_43); + l[Symbol.dispose](); + return _03; + }); + const written: boolean | undefined = option_map$1uijrx3(rt.weakUpgrade(self.lock), (l2: rt.Arc>>): boolean => { + const _44: rt.Result>, rt.TryLockError>>> = rt.rwLockTryWrite(l2.value); + const _04: boolean = _44.ok; + drop$Result_sync_RwLockWriteGuard_sync_Mutex_locks_Probe_sync_TryLockError_sync_RwLockWriteGuard_sync_Mutex_locks_Probe(_44); + l2[Symbol.dispose](); + return _04; + }); + const _15: boolean = rt.fmtAlternate(f); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(mutex, f, rt.fmtBool), (f: rt.Formatter) => rt.fmtOption(read, f, rt.fmtBool), (f: rt.Formatter) => rt.fmtOption(written, f, rt.fmtBool), (f: rt.Formatter) => rt.fmtBool(_15, f)]; + return rt.fmtWriteFmt(f, [args2[0], " ", args2[1], " ", args2[2], " ", args2[3]]); +} + +//# sourceMappingURL=locks.Probe.ts.map diff --git a/ts/fixtures/lang/locks/expected/locks.ts b/ts/fixtures/lang/locks/expected/locks.ts index 57f50e961..14d257b83 100644 --- a/ts/fixtures/lang/locks/expected/locks.ts +++ b/ts/fixtures/lang/locks/expected/locks.ts @@ -6,6 +6,7 @@ import { thenSome$0sf2w1i, thenSome$0d5am30 } from "./core/bool.ts"; import { unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; import { map$02txiwz as result_map$02txiwz, map$1g6jln5 as result_map$1g6jln5, mapOr$0666x4n as result_mapOr$0666x4n, mapOr$1qkf3ab as result_mapOr$1qkf3ab } from "./core/result.ts"; import * as Lock from "./locks.Lock.ts"; +import * as Probe from "./locks.Probe.ts"; import * as Tally from "./locks.Tally.ts"; /** Each byte an operation on the mutexes, its value the operand; each puts what it read. */ @@ -859,50 +860,67 @@ export function held$u32(lock: rt.RefCell): rt.u8 { /** * Each lock printed by `Debug` as std writes it, never poisoned, and `` with no * options while a guard holds a mutex or writes a read-write lock, plain, pretty, and - * padded, its value the operand: free, held, read, and nested in an `Arc` and each other. + * padded, its value the operand: free, held, read, and nested in an `Arc` and each other, + * and locked while each writes what it holds. */ export function shown(data: rt.ByteSlice, out: rt.ByteVec): void { let text!: string; const mutex: rt.Arc> = new rt.Arc(new rt.Mutex(0)); const lock: rt.RefCell[]> = new rt.RefCell([new rt.Mutex(97)]); for (const op of rt.byteSliceView(data)) { - const v: rt.u8 = op >> 2; - const _19: rt.u8 = rt.u8Rem(op, 4); - if (_19 === 0) { - const _23: rt.Mutex = rt.mutexLock(mutex.value); - _23.value = v; - rt.mutexUnlock(_23); + const v: rt.u8 = rt.u8Div(op, 5); + const _18: rt.u8 = rt.u8Rem(op, 5); + if (_18 === 0) { + const _22: rt.Mutex = rt.mutexLock(mutex.value); + _22.value = v; + rt.mutexUnlock(_22); const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.mutexDebug(mutex.value, f, rt.u8Debug)]; const free: string = rt.fmtFormat([args2[0], " ", rt.fmtSpec({ alternate: true }, args2[0]), " ", rt.fmtSpec({ align: ">", width: 4 }, args2[0])]); const _held: rt.Mutex = rt.mutexLock(mutex.value); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free), (f: rt.Formatter) => rt.mutexDebug(mutex.value, f, rt.u8Debug)]; text = rt.fmtFormat([args4[0], " ", args4[1], " ", rt.fmtSpec({ alternate: true }, args4[1]), " ", rt.fmtSpec({ align: ">", width: 12 }, args4[1])]); rt.mutexUnlock(_held); - } else if (_19 === 1) { - const _53: rt.RefCell[]> = rt.rwLockWrite(lock); - const _56: rt.Mutex = new rt.Mutex(rt.u8Add(97, rt.u8Rem(v, 26)) as rt.char); - _53.value.push(_56); - rt.refMutRelease(_53); + } else if (_18 === 1) { + const _52: rt.RefCell[]> = rt.rwLockWrite(lock); + const _55: rt.Mutex = new rt.Mutex(rt.u8Add(97, rt.u8Rem(v, 26)) as rt.char); + _52.value.push(_55); + rt.refMutRelease(_52); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; const free2: string = rt.fmtFormat([args6[0], " ", rt.fmtSpec({ alternate: true }, args6[0])]); const read: rt.RefCell[]> = rt.rwLockRead(lock); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; const shared: string = rt.fmtFormat([args8[0]]); - const _86: rt.Mutex[] = read.value; - const _held2: rt.Mutex = rt.mutexLock(_86[rt.idx(_86, 0)]); + const _85: rt.Mutex[] = read.value; + const _held2: rt.Mutex = rt.mutexLock(_85[rt.idx(_85, 0)]); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, free2), (f: rt.Formatter) => rt.fmtPad(f, shared), (f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; text = rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " ", rt.fmtSpec({ alternate: true }, args10[2])]); rt.mutexUnlock(_held2); rt.refRelease(read); - } else if (_19 === 2) { + } else if (_18 === 2) { const _held3: rt.RefCell[]> = rt.rwLockWrite(lock); const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock, f, (value: rt.Mutex[], f: rt.Formatter) => rt.fmtList(value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtCharDebug)))]; text = rt.fmtFormat([args12[0], " ", rt.fmtSpec({ alternate: true }, args12[0]), " ", rt.fmtSpec({ align: ">", width: 12 }, args12[0])]); rt.refMutRelease(_held3); + } else if (_18 === 3) { + if (!(rt.u8Rem(v, 2) === 0)) { + const lock2: rt.Arc>> = rt.arcNewCyclic((me2: rt.Weak>>): rt.RefCell> => { + return new rt.RefCell(new rt.Mutex(new Probe.Probe(new rt.Weak(), rt.weakClone(me2)))); + }); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(lock2.value, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, (value: Probe.Probe, f: rt.Formatter) => Probe.fmt$fmt_Debug(value, f)))]; + text = rt.fmtFormat([args16[0], " ", rt.fmtSpec({ alternate: true }, args16[0])]); + lock2[Symbol.dispose](); + } else { + const mutex2: rt.Arc> = rt.arcNewCyclic((me: rt.Weak>): rt.Mutex => { + return new rt.Mutex(new Probe.Probe(rt.weakClone(me), new rt.Weak())); + }); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.mutexDebug(mutex2.value, f, (value: Probe.Probe, f: rt.Formatter) => Probe.fmt$fmt_Debug(value, f))]; + text = rt.fmtFormat([args14[0], " ", rt.fmtSpec({ alternate: true }, args14[0])]); + mutex2[Symbol.dispose](); + } } else { const part = new rt.RefCell(new rt.Mutex("s")); - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(part, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtStr))]; - text = rt.fmtFormat([args14[0]]); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.rwLockDebug(part, f, (value: rt.Mutex, f: rt.Formatter) => rt.mutexDebug(value, f, rt.fmtStr))]; + text = rt.fmtFormat([args18[0]]); } rt.byteVecExtendFromSlice(out, rt.stringAsBytes(text)); } diff --git a/ts/fixtures/lang/locks/src/locks.rs b/ts/fixtures/lang/locks/src/locks.rs index 6923ef6ce..e39870421 100644 --- a/ts/fixtures/lang/locks/src/locks.rs +++ b/ts/fixtures/lang/locks/src/locks.rs @@ -525,15 +525,31 @@ fn held(lock: &RwLock) -> u8 { u8::from(read) << 1 | u8::from(write) } +/// Writes whether the locks it is in can be locked, and how it writes, while they write it. +struct Probe { + mutex: std::sync::Weak>, + lock: std::sync::Weak>>, +} + +impl fmt::Debug for Probe { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mutex = self.mutex.upgrade().map(|m| m.try_lock().is_ok()); + let read = self.lock.upgrade().map(|l| l.try_read().is_ok()); + let written = self.lock.upgrade().map(|l| l.try_write().is_ok()); + write!(f, "{mutex:?} {read:?} {written:?} {}", f.alternate()) + } +} + /// Each lock printed by `Debug` as std writes it, never poisoned, and `` with no /// options while a guard holds a mutex or writes a read-write lock, plain, pretty, and -/// padded, its value the operand: free, held, read, and nested in an `Arc` and each other. +/// padded, its value the operand: free, held, read, and nested in an `Arc` and each other, +/// and locked while each writes what it holds. pub fn shown(data: &[u8], out: &mut Vec) { let mutex = Arc::new(Mutex::new(0u8)); let lock = RwLock::new(vec![Mutex::new('a')]); for &op in data { - let v = op >> 2; - let text = match op % 4 { + let v = op / 5; + let text = match op % 5 { 0 => { *mutex.lock().unwrap() = v; let free = format!("{mutex:?} {mutex:#?} {mutex:>4?}"); @@ -552,6 +568,25 @@ pub fn shown(data: &[u8], out: &mut Vec) { let _held = lock.write().unwrap(); format!("{lock:?} {lock:#?} {lock:>12?}") } + // Locked while each writes what it holds. + 3 if v % 2 == 0 => { + let mutex = Arc::new_cyclic(|me| { + Mutex::new(Probe { + mutex: me.clone(), + lock: std::sync::Weak::new(), + }) + }); + format!("{mutex:?} {mutex:#?}") + } + 3 => { + let lock = Arc::new_cyclic(|me| { + RwLock::new(Mutex::new(Probe { + mutex: std::sync::Weak::new(), + lock: me.clone(), + })) + }); + format!("{lock:?} {lock:#?}") + } _ => format!("{:?}", RwLock::new(Mutex::new(String::from("s")))), }; out.extend_from_slice(text.as_bytes()); diff --git a/ts/runtime/rt/task.ts b/ts/runtime/rt/task.ts index 37d0a5dbc..0346830b3 100644 --- a/ts/runtime/rt/task.ts +++ b/ts/runtime/rt/task.ts @@ -4,7 +4,7 @@ // A value whose drop JS can observe has `[Symbol.dispose]`, which runs its `Drop` impl // and drops its fields. `None` is `undefined`, which drops as nothing. -import { Abort, type Debug, debugStructField, debugStructFinish, debugStructFinishNonExhaustive, debugTupleField, debugTupleFinish, Err, type Fmt, type FmtResult, type Formatter, fmtBool, fmtDebugStruct, fmtDebugTuple, fmtPad, fmtStr, type None, OK, Ok, Panic, panic, type Place, place, ptrWrite, type Result, vecAssign } from "../rt.ts"; +import { Abort, type Debug, type DebugStruct, debugStructField, debugStructFinish, debugStructFinishNonExhaustive, debugTupleField, debugTupleFinish, Err, type FmtResult, type Formatter, fmtBool, fmtDebugStruct, fmtDebugTuple, fmtPad, fmtStr, type None, OK, Ok, Panic, panic, type Place, place, ptrWrite, type Result, vecAssign } from "../rt.ts"; // Drops @@ -349,14 +349,20 @@ export class Mutex implements Disposable { } } -/** `Debug` of a `Mutex`: its value, or `""`, a string, while a guard holds it. */ +/** `Debug` of a `Mutex`: its value, locked while it is written, or `""`, a string, while a guard holds it. */ export function mutexDebug(mutex: Mutex, f: Formatter, debug: Debug): FmtResult { - return lockDebug(f, "Mutex", mutex.locked ? (f) => fmtStr("", f) : (f) => debug(mutex.value, f)); + const b = fmtDebugStruct(f, "Mutex"); + if (mutex.locked) debugStructField(b, "data", (f) => fmtStr("", f)); + else { + mutexLock(mutex); + debugStructField(b, "data", (f) => debug(mutex.value, f)); + mutexUnlock(mutex); + } + return lockFinish(b); } -/** `Debug` of a lock named `name`: `data`, then that it is never poisoned, as a panic aborts. */ -function lockDebug(f: Formatter, name: string, data: Fmt): FmtResult { - const b = debugStructField(fmtDebugStruct(f, name), "data", data); +/** A lock's `Debug` after its `data`: that it is never poisoned, as a panic aborts. */ +function lockFinish(b: DebugStruct): FmtResult { return debugStructFinishNonExhaustive(debugStructField(b, "poisoned", (f) => fmtBool(false, f))); } @@ -477,15 +483,28 @@ export function refCellReplace(cell: RefCell, value: T): T { return old; } -/** `Debug` of a `RefCell`: its value, or `` unpadded while borrowed exclusively. */ +/** `Debug` of a `RefCell`: its value, borrowed while it is written, or `` unpadded while borrowed exclusively. */ export function refCellDebug(cell: RefCell, f: Formatter, debug: Debug): FmtResult { - const value: Fmt = cell.borrows < 0 ? (f) => f.out.writeStr("") : (f) => debug(cell.value, f); - return debugStructFinish(debugStructField(fmtDebugStruct(f, "RefCell"), "value", value)); + const b = fmtDebugStruct(f, "RefCell"); + if (cell.borrows < 0) debugStructField(b, "value", (f) => f.out.writeStr("")); + else { + refCellBorrow(cell); + debugStructField(b, "value", (f) => debug(cell.value, f)); + refRelease(cell); + } + return debugStructFinish(b); } -/** `Debug` of an `RwLock`: its value, or `` unpadded while written. */ +/** `Debug` of an `RwLock`: its value, read while it is written, or `` unpadded while written. */ export function rwLockDebug(lock: RefCell, f: Formatter, debug: Debug): FmtResult { - return lockDebug(f, "RwLock", lock.borrows < 0 ? (f) => f.out.writeStr("") : (f) => debug(lock.value, f)); + const b = fmtDebugStruct(f, "RwLock"); + if (lock.borrows < 0) debugStructField(b, "data", (f) => f.out.writeStr("")); + else { + rwLockRead(lock); + debugStructField(b, "data", (f) => debug(lock.value, f)); + refRelease(lock); + } + return lockFinish(b); } /** `RwLock::read`: a shared guard, which aborts while a write is held, as wasm32's does. */ @@ -701,9 +720,9 @@ export class Cell implements Place, Disposable { } } -/** `Debug` of a `Cell` of a `Copy` value. */ -export function cellDebug(cell: Cell, f: Formatter, debug: Debug): FmtResult { - return debugStructFinish(debugStructField(fmtDebugStruct(f, "Cell"), "value", (f) => debug(cell.v, f))); +/** `Debug` of a `Cell` of a `Copy` value, given what `Cell::get` gave before anything is written. */ +export function cellDebug(value: T, f: Formatter, debug: Debug): FmtResult { + return debugStructFinish(debugStructField(fmtDebugStruct(f, "Cell"), "value", (f) => debug(value, f))); } /** `Cell::from_mut` of the place `p`: a cell of it, which nothing drops, as nothing owns it. */ diff --git a/ts/src/lower/fmt.rs b/ts/src/lower/fmt.rs index 7ccace5ac..c4467a7d1 100644 --- a/ts/src/lower/fmt.rs +++ b/ts/src/lower/fmt.rs @@ -437,17 +437,23 @@ pub fn std_impl<'tcx>( (Std::BorrowError, Trait::Display) => Expr::rt("borrowErrorDisplay", vec![value, f]), (Std::BorrowMutError, Trait::Debug) => Expr::rt("borrowMutErrorDebug", vec![value, f]), (Std::BorrowMutError, Trait::Display) => Expr::rt("borrowMutErrorDisplay", vec![value, f]), - // What each holds, or what keeps it from being read; a `Cell`'s value is `Copy`. An - // `RwLock` shares a `RefCell`'s representation, and an `UnsafeCell` a `Cell`'s. + // What each holds, held as a guard would while it is written, or what keeps it from + // being read. An `RwLock` shares a `RefCell`'s representation, and an `UnsafeCell` a + // `Cell`'s. (Std::Cell, Trait::Debug) if tcx.is_lang_item(adt.did(), rustc_attr_ir::LangItem::UnsafeCell) => { rt("writeStr", vec![f, Expr::Str("UnsafeCell { .. }".into())]) } - (std @ (Std::RefCell | Std::Mutex | Std::Cell), Trait::Debug) => { + // What `get` gives, before anything is written. + (Std::Cell, Trait::Debug) => { + let held = b.fmt_fn(tr, args.type_at(0), span); + let value = b.t.copied(value.member("v"), args.type_at(0), span); + Expr::rt("cellDebug", vec![value, f, held]) + } + (std @ (Std::RefCell | Std::Mutex), Trait::Debug) => { let debug = match std { Std::RefCell if tcx.is_diagnostic_item(rustc_span::sym::RwLock, adt.did()) => "rwLockDebug", Std::RefCell => "refCellDebug", - Std::Mutex => "mutexDebug", - _ => "cellDebug", + _ => "mutexDebug", }; let held = b.fmt_fn(tr, args.type_at(0), span); Expr::rt(debug, vec![value, f, held]) From e4ed6c203eaa9091b1d69ccfe09a4d399f926bc8 Mon Sep 17 00:00:00 2001 From: quest fixer Date: Mon, 2 Nov 2026 21:42:41 -0800 Subject: [PATCH 4/4] test(ts): regenerate edit snapshots after base merge --- .../lang/pointers/expected/pointers.ts | 3 +- ts/fixtures/lang/strs/expected/strs.ts | 32 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/ts/fixtures/lang/pointers/expected/pointers.ts b/ts/fixtures/lang/pointers/expected/pointers.ts index bb7f5329a..f2b1c29fd 100644 --- a/ts/fixtures/lang/pointers/expected/pointers.ts +++ b/ts/fixtures/lang/pointers/expected/pointers.ts @@ -436,9 +436,8 @@ export function cells(data: rt.ByteSlice, out: rt.ByteVec): void { _67._1 = _67._1 ^ 128; rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(before2._0, before2._1, between._0, between._1, pair.v._0, pair.v._1)), undefined, true); } else if (_23 === 3) { - const _85: rt.char = rt.u8Add(97, rt.u8Rem(n, 26)) as rt.char; const _83: rt.Place = text; - _83.v = _83.v + String.fromCodePoint(_85); + _83.v = _83.v + String.fromCodePoint(rt.u8Add(97, rt.u8Rem(n, 26)) as rt.char); const _91: rt.Place = text; _91.v = _91.v + "!"; rt.iterExtendBytes(out, rt.iterSlice(rt.byteSliceView(rt.stringAsBytes(text.v))), undefined, true); diff --git a/ts/fixtures/lang/strs/expected/strs.ts b/ts/fixtures/lang/strs/expected/strs.ts index 6c66b9239..cd49ab713 100644 --- a/ts/fixtures/lang/strs/expected/strs.ts +++ b/ts/fixtures/lang/strs/expected/strs.ts @@ -684,8 +684,8 @@ export function edits(kind: rt.u8, dataData: Uint8Array, dataStart: number, data const _44: rt.Place = rt.place(() => s, (value9) => s = value9); _44.v = _44.v + "Ć©/"; } else if (_42 === 1) { - const _47: rt.usize = offset(s, a); const _46: rt.Place = rt.place(() => s, (value8) => s = value8); + const _47: rt.usize = offset(s, a); _46.v = rt.stringTruncate(_46.v, _47); } else if (_42 === 2) { const _51: rt.Place = rt.place(() => s, (value7) => s = value7); @@ -693,10 +693,9 @@ export function edits(kind: rt.u8, dataData: Uint8Array, dataStart: number, data _51.v = edit4[0]; putChar(out, edit4[1]); } else if (_42 === 3) { - const _53: rt.usize = offset(s, a); - const _56: string = "šŸ˜€"; const _52: rt.Place = rt.place(() => s, (value6) => s = value6); - _52.v = rt.stringInsertStr(_52.v, _53, _56); + const _53: rt.usize = offset(s, a); + _52.v = rt.stringInsertStr(_52.v, _53, "šŸ˜€"); } else if (_42 === 4) { const _60: rt.Place = rt.place(() => s, (value5) => s = value5); const _61: rt.usize = offset(s, a); @@ -1463,8 +1462,8 @@ export function hinted(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const m: rt.u32 = _7[1]; const sub: rt.usize = rt.usizeDiv(option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, 1), 0) as rt.usize, [0, 5, 8, 9, 2147483645, 2147483648, 4294967295].length); let t: string = "aĆ©"; - const _26: string = text(option_unwrapOr$1rbuegs(rt.byteSliceGetRange(data, 2), rt.byteSliceFrom(Uint8Array.of()))); const _25: rt.Place = rt.place(() => t, (value) => t = value); + const _26: string = text(option_unwrapOr$1rbuegs(rt.byteSliceGetRange(data, 2), rt.byteSliceFrom(Uint8Array.of()))); _25.v = _25.v + _26; const calls: rt.Cell = new rt.Cell(0); const f: (a0: rt.u32) => rt.char = (_2: rt.u32): rt.char => { @@ -1481,20 +1480,20 @@ export function hinted(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { }; const _38: rt.u8 = rt.u8Rem(kind, 10); if (_38 === 0) { - const _41: rt.Iter = rt.iterMap(new rt.Range(0, n), f); const _40: rt.Place = rt.place(() => t, (value13) => t = value13); + const _41: rt.Iter = rt.iterMap(new rt.Range(0, n), f); _40.v = rt.stringExtendChars(_40.v, _41); } else if (_38 === 1) { t = rt.stringExtendChars("", rt.iterMap(rt.iterChain(new rt.RangeInclusive(0, n, rt.u32Step), new rt.Range(0, n)), f)); } else if (_38 === 2) { + const _48: rt.Place = rt.place(() => t, (value12) => t = value12); const _49: rt.Iter = rt.iterSkip(rt.iterMap(new rt.Range(0, rt.u64Or(rt.u64Shl(n as rt.u64, 8), m as rt.u64), rt.u64Step), (i4: rt.u64): rt.char => { return f(rt.u64Low(i4)); }), m as rt.usize); - const _48: rt.Place = rt.place(() => t, (value12) => t = value12); _48.v = rt.stringExtendChars(_48.v, _49); } else if (_38 === 3) { - const _62: rt.Iter = rt.iterTake(rt.iterMap(new rt.Range(0, n), f), m as rt.usize, undefined, true); const _61: rt.Place = rt.place(() => t, (value11) => t = value11); + const _62: rt.Iter = rt.iterTake(rt.iterMap(new rt.Range(0, n), f), m as rt.usize, undefined, true); _61.v = rt.stringExtendChars(_61.v, _62); } else if (_38 === 4) { const _66: rt.Place = rt.place(() => t, (value10) => t = value10); @@ -1508,45 +1507,45 @@ export function hinted(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { _66.v = rt.stringExtendChars(_66.v, _67); } else if (_38 === 5) { if (rt.u32Rem(m, 2) === 0) { - const _79: rt.Iter = rt.iterChain(rt.iterMap(new rt.Range(0, n), f), rt.iterMap(new rt.Range(0, m), f)); const _78: rt.Place = rt.place(() => t, (value9) => t = value9); + const _79: rt.Iter = rt.iterChain(rt.iterMap(new rt.Range(0, n), f), rt.iterMap(new rt.Range(0, m), f)); _78.v = rt.stringExtendChars(_78.v, _79); } else { + const _84: rt.Place = rt.place(() => t, (value8) => t = value8); const _85: rt.Iter = rt.iterMap(rt.iterZip(new rt.Range(0, n), new rt.Range(0, m), [false, false]), (_211: [rt.u32, rt.u32]): rt.char => { return f(_211[0]); }); - const _84: rt.Place = rt.place(() => t, (value8) => t = value8); _84.v = rt.stringExtendChars(_84.v, _85); } } else if (_38 === 6) { + const _91: rt.Place = rt.place(() => t, (value7) => t = value7); const _92: rt.Iter = rt.iterFlatMap(new rt.Range(0, n), (i2: rt.u32): rt.char[] => { return [f(i2), f(i2)]; }, (value: rt.char[]) => rt.iterSlice(value), false, 2); - const _91: rt.Place = rt.place(() => t, (value7) => t = value7); _91.v = rt.stringExtendChars(_91.v, _92); } else if (_38 === 7) { - const _97: rt.Iter = rt.iterChain(rt.iterChain(rt.iterChain(rt.iterChain(rt.iterMap(new rt.Range(0, rt.u32SaturatingSub(n, 5)), f), rt.iterOnce(120)), rt.iterOption(121)), rt.strChars("Ć©šŸ˜€")), rt.iterSlice([122])); const _96: rt.Place = rt.place(() => t, (value6) => t = value6); + const _97: rt.Iter = rt.iterChain(rt.iterChain(rt.iterChain(rt.iterChain(rt.iterMap(new rt.Range(0, rt.u32SaturatingSub(n, 5)), f), rt.iterOnce(120)), rt.iterOption(121)), rt.strChars("Ć©šŸ˜€")), rt.iterSlice([122])); _96.v = rt.stringExtendChars(_96.v, _97); } else if (_38 === 8) { const _112: rt.usize = rt.usizeRem(sub, 3); if (_112 === 0) { + const _114: rt.Place = rt.place(() => t, (value5) => t = value5); const _115: rt.Iter = rt.iterMap(new rt.Range({ hi: 0x10000000, lo: 0 } as rt.u64, rt.u64Add({ hi: 0x10000000, lo: 0 } as rt.u64, n as rt.u64), rt.u64Step), (_210: rt.u64): rt.char => { return f(0); }); - const _114: rt.Place = rt.place(() => t, (value5) => t = value5); _114.v = rt.stringExtendChars(_114.v, _115); } else if (_112 === 1) { + const _128: rt.Place = rt.place(() => t, (value4) => t = value4); const _129: rt.Iter = rt.iterMap(new rt.Range(rt.i128Neg(rt.i128Shl(1, 100)), rt.i128Add(rt.i128Neg(rt.i128Shl(1, 100)), n as rt.i128), rt.i128Step), (_27: rt.i128): rt.char => { return f(0); }); - const _128: rt.Place = rt.place(() => t, (value4) => t = value4); _128.v = rt.stringExtendChars(_128.v, _129); } else { + const _146: rt.Place = rt.place(() => t, (value3) => t = value3); const _147: rt.Iter = rt.iterMap(new rt.RangeInclusive({ hi: 0x10000000, lo: 0 } as rt.u64, rt.u64Add({ hi: 0x10000000, lo: 0 } as rt.u64, n as rt.u64), rt.u64Step), (_24: rt.u64): rt.char => { return f(0); }); - const _146: rt.Place = rt.place(() => t, (value3) => t = value3); _146.v = rt.stringExtendChars(_146.v, _147); } } else { @@ -1554,9 +1553,8 @@ export function hinted(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { return _23[1]; })))); putChar(out, rt.peekablePeek(chars)); - const _173: rt.Peekable = chars; const _172: rt.Place = rt.place(() => t, (value2) => t = value2); - _172.v = rt.stringExtendChars(_172.v, _173); + _172.v = rt.stringExtendChars(_172.v, chars); } put(out, t); }