diff --git a/quest/m3/README.md b/quest/m3/README.md index e6d4b1e97..f1e74b224 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -22,7 +22,8 @@ generic std gap is planned here even when moq never calls it. - [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 - [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's consumers, flattens, and collects drop as std's do - [Fresh writes in a body generic over a type](/quest/m3/ts-fresh-type-params.md) - a whole write into fresh memory holding a type parameter's values fills it, as one generic over a length alone does -- [std's conversions of a reference](/quest/m3/ts-ref-conversions.md) - `to_owned`, `clone_from`, `binary_search`, `size_of_val`, `from_ref`/`from_mut`, and `AsRef`/`Borrow` as a slice translate +- [A slice of one value behind any &mut](/quest/m3/ts-slice-of-one.md) - `slice::from_mut` and `array::from_mut` of a `&mut u8`, or of an object no place names, translate +- [A slice's searches by a closure](/quest/m3/ts-binary-search-by.md) - `binary_search_by`, `binary_search_by_key`, and `partition_point` translate, probing as std's do - [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form - [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does - [A deque's two slices](/quest/m3/ts-deque-slices.md) - `VecDeque::as_slices` and `{:?}` of a deque's `Iter`, `IterMut`, and `Drain` translate, split where std's are diff --git a/quest/m3/ts-binary-search-by.md b/quest/m3/ts-binary-search-by.md new file mode 100644 index 000000000..a708cfb53 --- /dev/null +++ b/quest/m3/ts-binary-search-by.md @@ -0,0 +1,16 @@ +# [XS] A slice's searches by a closure + +## Goal + +[rust2-ts](/ts/README.md) translates `slice::binary_search_by`, `binary_search_by_key`, +and `partition_point`, calling the closure on the elements std's search probes, in its +order, proven by a differential test against native Rust over runs of equal elements. + +## Plan + +Found writing [std's conversions of a reference](https://github.com/moq-dev/rust2/pull/386), +which maps `binary_search` to the runtime's `sliceBinarySearch`, std's probe sequence. The +others are std's same search by another comparison, so they can share it. They are refused +as "unsupported call" today. + +Public API: the translator's output. diff --git a/quest/m3/ts-ref-conversions.md b/quest/m3/ts-ref-conversions.md deleted file mode 100644 index 6e2521256..000000000 --- a/quest/m3/ts-ref-conversions.md +++ /dev/null @@ -1,23 +0,0 @@ -# [M] std's conversions of a reference - -## Goal - -[rust2-ts](/ts/README.md) translates std's functions that take a reference and convert, -copy, or measure what it points at, for any `T` and for `[u8; N]`, proven by differential -tests against native Rust: `ToOwned::to_owned` and `clone_into`, `Clone::clone_from`, -`slice::binary_search`, `mem::size_of_val` and `align_of_val`, `slice::from_mut`, -`array::from_ref` and `from_mut`, `AsRef`, `AsMut`, and `Borrow` of an array as a slice, -`Cell::from_mut`, and `ptr::from_ref` and `from_mut`. - -## Plan - -Found by [moq-dev/rust2#354](https://github.com/moq-dev/rust2/pull/354): each is refused as -"unsupported call" for `[u32; 2]` and `u32` as for `[u8; 2]`, having no mapping. A mapping -given a `&[u8; N]` as a `&T` gets an `rt.byteSliceView` of it from `lend::give`, which -shares the bytes, so reads, copies, and writes through it need nothing more. A pointer to -a `[u8; N]` is an `rt.ByteSlice` compared by the buffer and offset of its bytes, so -`ptr::from_ref` of the view is `rt.byteSliceFrom` of it. - -No consumer calls them yet; they are planned here as part of std. - -Public API: the translator's output. diff --git a/quest/m3/ts-slice-of-one.md b/quest/m3/ts-slice-of-one.md new file mode 100644 index 000000000..2b47773b6 --- /dev/null +++ b/quest/m3/ts-slice-of-one.md @@ -0,0 +1,21 @@ +# [S] A slice of one value behind any &mut + +## Goal + +[rust2-ts](/ts/README.md) translates `slice::from_mut` and `array::from_mut` of every +`&mut`, proven by a differential test against native Rust that writes the element whole, +reads it out with `mem::replace`, and writes it in place: a `&mut u8`, and a `&mut` to an +object, such as a struct or a `[u32; N]`, that names no place in the function, as a +parameter does. + +## Plan + +Found writing [std's conversions of a reference](https://github.com/moq-dev/rust2/pull/386): +both are refused. A `&mut [u8]` is an `rt.ByteSlice`, which can only view a `Uint8Array`, +not the `rt.Place` of one `u8`. A slice's element write replaces the slot, so a slice of +an object whose place is unknown can't make the caller's variable hold the new value, and +copying the write into the object instead makes `mem::replace` return the object it just +overwrote. Either needs translated code to write such a slice's element in place, or a +`&mut u8` to know the bytes it may point into. + +Public API: the translator's output. diff --git a/ts/README.md b/ts/README.md index fd69092d1..cda1a2f3f 100644 --- a/ts/README.md +++ b/ts/README.md @@ -782,7 +782,8 @@ they need. whose length is a power of two. A `Vec`, `VecDeque`, and `BinaryHeap` hold what std guarantees of their capacity: at least their length and what `with_capacity`, `reserve`, and `reserve_exact` ask for, and std's exactly where its doubling fixes it, - as through pushes. One holds a capacity, as `cap`, only where `with_capacity`, `reserve`, + as through pushes. `clone_from` and `clone_into`, of which std guarantees only the + length, leave a clone's capacity, not the allocation std reuses. One holds a capacity, as `cap`, only where `with_capacity`, `reserve`, `shrink_to`, a `clone`, or a `collect` or `extend` set it, so a push never reads or writes one. Reading it doubles it while short of the length, from the least std's `RawVec` allocates for the element size, which a run of pushes grows std's to. A diff --git a/ts/fixtures/lang/expected/conversions.Held.ts b/ts/fixtures/lang/expected/conversions.Held.ts new file mode 100644 index 000000000..71be3c013 --- /dev/null +++ b/ts/fixtures/lang/expected/conversions.Held.ts @@ -0,0 +1,18 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; + +/** Holds a value in a field. */ +export class Held { + value: T; + + constructor(value: T) { + this.value = value; + } + + [Symbol.dispose](): void { + rt.drop(this.value); + } +} + +//# sourceMappingURL=conversions.Held.ts.map diff --git a/ts/fixtures/lang/expected/conversions.Logged.ts b/ts/fixtures/lang/expected/conversions.Logged.ts new file mode 100644 index 000000000..f2244d014 --- /dev/null +++ b/ts/fixtures/lang/expected/conversions.Logged.ts @@ -0,0 +1,54 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { byte as conversions_byte, LOG as conversions_LOG } from "./conversions.ts"; + +/** + * Logs its id as it drops, and as it is cloned, the id with the high bit set: its clone's + * id is one more. + */ +export class Logged { + id: rt.u8; + log: rt.Arc>; + + constructor(id: rt.u8, log: rt.Arc>) { + this.id = id; + this.log = log; + } + + [Symbol.dispose](): void { + drop$ops_Drop(this); + this.log[Symbol.dispose](); + } +} + +export function clone$Clone(self: Logged): Logged { + const _5: rt.RefCell = rt.refCellBorrowMut(self.log.value); + rt.byteVecPush(_5.value, 128 | self.id); + rt.refMutRelease(_5); + return new Logged(rt.u8WrappingAdd(self.id, 1), rt.arcClone(self.log)); +} + +export function drop$ops_Drop(self: Logged): void { + const _5: rt.RefCell = rt.refCellBorrowMut(self.log.value); + rt.byteVecPush(_5.value, self.id); + rt.refMutRelease(_5); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value(data: rt.ByteSlice, at: rt.usize): Logged { + return new Logged(conversions_byte(data, at) & 127, ((a0: rt.Arc>): rt.Arc> => { + return rt.arcClone(a0); + })(conversions_LOG.get())); +} + +/** Its bytes. */ +export function put$conversions_Value(self: Logged, out: rt.ByteVec): void { + rt.byteVecPush(out, self.id); + rt.byteVecPush(out, 253); + const _10: rt.RefCell = rt.refCellBorrowMut(self.log.value); + rt.iterExtendBytes(out, rt.byteVecDrain(_10.value, undefined), "fold", true); + rt.refMutRelease(_10); +} + +//# sourceMappingURL=conversions.Logged.ts.map diff --git a/ts/fixtures/lang/expected/conversions.Named.ts b/ts/fixtures/lang/expected/conversions.Named.ts new file mode 100644 index 000000000..a588e2bbb --- /dev/null +++ b/ts/fixtures/lang/expected/conversions.Named.ts @@ -0,0 +1,39 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { byte as conversions_byte, make$conversions_Value_String as conversions_make$conversions_Value_String, put$conversions_Value_String as conversions_put$conversions_Value_String } from "./conversions.ts"; + +export function clone$Clone(self: Named): Named { + return { id: self.id, name: self.name }; +} + +export function partialCmp$cmp_PartialOrd(self: Named, other: Named): rt.Ordering | undefined { + return cmp$cmp_Ord(self, other); +} + +export function cmp$cmp_Ord(self: Named, other: Named): rt.Ordering { + const cmp: rt.Ordering = rt.cmp(self.id, other.id); + if (cmp === 0) { + return rt.cmpStr(self.name, other.name); + } + return cmp; +} + +/** A struct, which JS holds as an object. */ +export interface Named { + id: rt.u16; + name: string; +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value(data: rt.ByteSlice, at: rt.usize): Named { + return { id: rt.u8Rem(conversions_byte(data, at), 4) as rt.u16, name: conversions_make$conversions_Value_String(data, rt.usizeAdd(at, 1)) }; +} + +/** Its bytes. */ +export function put$conversions_Value(self: Named, out: rt.ByteVec): void { + rt.iterExtendBytes(out, rt.iterSlice(rt.u16ToBeBytes(self.id)), undefined, true); + conversions_put$conversions_Value_String(self.name, out); +} + +//# sourceMappingURL=conversions.Named.ts.map diff --git a/ts/fixtures/lang/expected/conversions.ts b/ts/fixtures/lang/expected/conversions.ts new file mode 100644 index 000000000..673b8c189 --- /dev/null +++ b/ts/fixtures/lang/expected/conversions.ts @@ -0,0 +1,2758 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import { copy$array_array0_u8, copy$array_array1_u8, copy$array_array2_u32, copy$array_array3_u8, copy$array_array40_u8, copy$array_tuple2_usize_usize, copy$array_u32, copy$array_u8 } from "./lib.ts"; +import * as conversions_Held from "./conversions.Held.ts"; +import * as conversions_Logged from "./conversions.Logged.ts"; +import * as conversions_Named from "./conversions.Named.ts"; +import { thenSome$0b23a33 } from "./core/bool.ts"; +import { unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr } from "./core/option.ts"; + +/** The byte at `at`, past `data`'s end its index. */ +export function byte(data: rt.ByteSlice, at: rt.usize): rt.u8 { + return option_unwrapOr$0r2bmpr(rt.byteSliceGet(data, at), at & 0xff); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_u8(data: rt.ByteSlice, at: rt.usize): rt.u8 { + return byte(data, at); +} + +/** Its bytes. */ +export function put$conversions_Value_u8(self: rt.u8, out: rt.ByteVec): void { + rt.byteVecPush(out, self); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_u32(data: rt.ByteSlice, at: rt.usize): rt.u32 { + return rt.u32Mul(byte(data, at) as rt.u32, 16843009); +} + +/** Its bytes. */ +export function put$conversions_Value_u32(self: rt.u32, out: rt.ByteVec): void { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(self)), undefined, true); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_u64(data: rt.ByteSlice, at: rt.usize): rt.u64 { + return rt.u64Or(rt.u64Shl(byte(data, at) as rt.u64, 56), byte(data, rt.usizeAdd(at, 1)) as rt.u64); +} + +/** Its bytes. */ +export function put$conversions_Value_u64(self: rt.u64, out: rt.ByteVec): void { + rt.iterExtendBytes(out, rt.iterSlice(rt.u64ToBeBytes(self)), undefined, true); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_String(data: rt.ByteSlice, at: rt.usize): string { + const part = rt.u8Rem(byte(data, at), 16); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(part, f)]; + return rt.fmtFormat(["s", args2[0]]); +} + +/** Its bytes. */ +export function put$conversions_Value_String(self: string, out: rt.ByteVec): void { + rt.iterExtendBytes(out, rt.iterSlice(rt.byteSliceView(rt.stringAsBytes(self))), undefined, true); + rt.byteVecPush(out, 255); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_Option_u16(data: rt.ByteSlice, at: rt.usize): rt.u16 | undefined { + const b: rt.u8 = byte(data, at); + return thenSome$0b23a33(rt.u8Rem(b, 4) !== 0, (((b as rt.u16)) << 4) & 0xffff); +} + +/** Its bytes. */ +export function put$conversions_Value_Option_u16(self: rt.u16 | undefined, out: rt.ByteVec): void { + if (self === undefined) { + rt.byteVecPush(out, 255); + } else { + rt.iterExtendBytes(out, rt.iterSlice(rt.u16ToBeBytes(self)), undefined, true); + } +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_array0_u8(data: rt.ByteSlice, at: rt.usize): Uint8Array { + return rt.bytesFromFn(0, (i: rt.usize): rt.u8 => { + return rt.u8Rem(byte(data, rt.usizeAdd(at, i)), 4); + }); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_array1_u8(data: rt.ByteSlice, at: rt.usize): Uint8Array { + return rt.bytesFromFn(1, (i: rt.usize): rt.u8 => { + return rt.u8Rem(byte(data, rt.usizeAdd(at, i)), 4); + }); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_array2_u8(data: rt.ByteSlice, at: rt.usize): Uint8Array { + return rt.bytesFromFn(2, (i: rt.usize): rt.u8 => { + return rt.u8Rem(byte(data, rt.usizeAdd(at, i)), 4); + }); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_array3_u8(data: rt.ByteSlice, at: rt.usize): Uint8Array { + return rt.bytesFromFn(3, (i: rt.usize): rt.u8 => { + return rt.u8Rem(byte(data, rt.usizeAdd(at, i)), 4); + }); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_array40_u8(data: rt.ByteSlice, at: rt.usize): Uint8Array { + return rt.bytesFromFn(40, (i: rt.usize): rt.u8 => { + return rt.u8Rem(byte(data, rt.usizeAdd(at, i)), 4); + }); +} + +/** Its bytes. */ +export function put$conversions_Value_array0_u8(self: rt.ByteSlice, out: rt.ByteVec): void { + rt.byteVecExtendFromSlice(out, self); +} + +/** Its bytes. */ +export function put$conversions_Value_array1_u8(self: rt.ByteSlice, out: rt.ByteVec): void { + rt.byteVecExtendFromSlice(out, self); +} + +/** Its bytes. */ +export function put$conversions_Value_array3_u8(self: rt.ByteSlice, out: rt.ByteVec): void { + rt.byteVecExtendFromSlice(out, self); +} + +/** Its bytes. */ +export function put$conversions_Value_array40_u8(self: rt.ByteSlice, out: rt.ByteVec): void { + rt.byteVecExtendFromSlice(out, self); +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_array2_u32(data: rt.ByteSlice, at: rt.usize): rt.u32[] { + return [rt.u8Rem(byte(data, at), 4) as rt.u32, (((byte(data, rt.usizeAdd(at, 1)) as rt.u32)) << 20) >>> 0]; +} + +/** Its bytes. */ +export function put$conversions_Value_array2_u32(self: rt.u32[], out: rt.ByteVec): void { + for (const _5 of self) { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(_5)), undefined, true); + } +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_Vec_u32(data: rt.ByteSlice, at: rt.usize): rt.u32[] { + return rt.iterToArray(rt.iterMap(new rt.Range(0, rt.u8Rem(byte(data, at), 4) as rt.usize), (i: rt.usize): rt.u32 => { + return byte(data, rt.usizeAdd(rt.usizeAdd(at, i), 1)) as rt.u32; + }), undefined, 4, true); +} + +/** Its bytes. */ +export function put$conversions_Value_Vec_u32(self: rt.u32[], out: rt.ByteVec): void { + rt.byteVecPush(out, self.length & 0xff); + for (const _8 of self) { + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(_8)), undefined, true); + } +} + +/** The value `data` makes from `at`. */ +export function make$conversions_Value_Vec_u8(data: rt.ByteSlice, at: rt.usize): rt.ByteVec { + return rt.iterToByteVec(rt.iterMap(new rt.Range(0, rt.u8Rem(byte(data, at), 4) as rt.usize), (i: rt.usize): rt.u8 => { + return byte(data, rt.usizeAdd(rt.usizeAdd(at, i), 1)); + }), undefined, true); +} + +/** Its bytes. */ +export function put$conversions_Value_Vec_u8(self: rt.ByteVec, out: rt.ByteVec): void { + rt.byteVecPush(out, self.length & 0xff); + rt.byteVecExtendFromSlice(out, rt.byteVecSlice(self)); +} + +export const LOG: rt.LocalKey>> = /* @__PURE__ */ new rt.LocalKey((): rt.Arc> => { + return LOG$init(undefined); +}, true, rt.drop); + +export function LOG$init(_1: undefined): rt.Arc> { + return new rt.Arc(new rt.RefCell(new rt.ByteVec())); +} + +/** + * Runs each conversion of the type `kind` picks, but for `u8`, whose `&mut` no slice can + * view, and [`searched`] of those that order. + */ +export function conversions(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { + const _5: rt.u8 = rt.u8Rem(kind, 14); + if (_5 === 0) { + ordered$u32(data, out); + lentThrough$u32(data, out); + } else if (_5 === 1) { + ordered$u64(data, out); + } else if (_5 === 2) { + ordered$String(data, out); + lentThrough$String(data, out); + } else if (_5 === 3) { + ordered$Option_u16(data, out); + lentThrough$Option_u16(data, out); + } else if (_5 === 4) { + ordered$array0_u8(data, out); + } else if (_5 === 5) { + ordered$array1_u8(data, out); + } else if (_5 === 6) { + ordered$array3_u8(data, out); + lentThrough$array3_u8(data, out); + } else if (_5 === 7) { + ordered$array40_u8(data, out); + } else if (_5 === 8) { + ordered$array2_u32(data, out); + } else if (_5 === 9) { + ordered$conversions_Named(data, out); + } else if (_5 === 10) { + ordered$Vec_u32(data, out); + } else if (_5 === 11) { + ordered$Vec_u8(data, out); + } else if (_5 === 12) { + converted$u8(data, out); + searched$u8(data, out); + } else { + ((log: rt.Arc>): undefined => { + const _52: rt.RefCell = rt.refCellBorrowMut(log.value); + rt.byteVecClear(_52.value); + rt.refMutRelease(_52); + })(LOG.get()); + converted$conversions_Logged(data, out); + lentOne$conversions_Logged(data, out); + } + measured(data, out); + pointed(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$Option_u16(data, out); + lentOne$Option_u16(data, out); + searched$Option_u16(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$String(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$String(data, out); + lentOne$String(data, out); + searched$String(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$Vec_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$Vec_u32(data, out); + lentOne$Vec_u32(data, out); + searched$Vec_u32(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$Vec_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$Vec_u8(data, out); + lentOne$Vec_u8(data, out); + searched$Vec_u8(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$array0_u8(data, out); + lentOne$array0_u8(data, out); + searched$array0_u8(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$array1_u8(data, out); + lentOne$array1_u8(data, out); + searched$array1_u8(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$array2_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$array2_u32(data, out); + lentOne$array2_u32(data, out); + searched$array2_u32(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$array3_u8(data, out); + lentOne$array3_u8(data, out); + searched$array3_u8(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$array40_u8(data, out); + lentOne$array40_u8(data, out); + searched$array40_u8(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$conversions_Named(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$conversions_Named(data, out); + lentOne$conversions_Named(data, out); + searched$conversions_Named(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$u32(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$u32(data, out); + lentOne$u32(data, out); + searched$u32(data, out); +} + +/** Each conversion of a `T` that orders. */ +export function ordered$u64(data: rt.ByteSlice, out: rt.ByteVec): void { + converted$u64(data, out); + lentOne$u64(data, out); + searched$u64(data, out); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$Option_u16(to: rt.Place, from: rt.u16 | undefined): void { + to.v = from; +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$String(to: rt.Place, from: string): void { + to.v = from; +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$Vec_u32(to: rt.u32[], from: rt.u32[]): void { + rt.replaceIn(to, rt.vecExact(from.slice(), 4)); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$Vec_u8(to: rt.ByteVec, from: rt.ByteVec): void { + rt.replaceIn(to, rt.byteVecFrom(rt.byteVecView(from))); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$array0_u8(to: rt.ByteSlice, from: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$array1_u8(to: rt.ByteSlice, from: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$array2_u32(to: rt.u32[], from: rt.u32[]): void { + rt.replaceIn(to, copy$array_u32(from)); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$array3_u8(to: rt.ByteSlice, from: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$array40_u8(to: rt.ByteSlice, from: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$conversions_Logged(to: conversions_Logged.Logged, from: conversions_Logged.Logged): void { + rt.replaceIn(to, conversions_Logged.clone$Clone(from))[Symbol.dispose](); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$conversions_Named(to: conversions_Named.Named, from: conversions_Named.Named): void { + rt.replaceIn(to, conversions_Named.clone$Clone(from)); +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$u32(to: rt.Place, from: rt.u32): void { + to.v = from; +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$u64(to: rt.Place, from: rt.u64): void { + to.v = from; +} + +/** `clone_from` through a `&mut` whose place only the caller knows. */ +export function cloneFromParam$u8(to: rt.Place, from: rt.u8): void { + to.v = from; +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$Option_u16(from: rt.u16 | undefined, to: rt.Place): void { + to.v = from; +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$String(from: string, to: rt.Place): void { + to.v = from; +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$Vec_u32(from: rt.u32[], to: rt.u32[]): void { + rt.replaceIn(to, rt.vecExact(from.slice(), 4)); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$Vec_u8(from: rt.ByteVec, to: rt.ByteVec): void { + rt.replaceIn(to, rt.byteVecFrom(rt.byteVecView(from))); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$array0_u8(from: rt.ByteSlice, to: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$array1_u8(from: rt.ByteSlice, to: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$array2_u32(from: rt.u32[], to: rt.u32[]): void { + rt.replaceIn(to, copy$array_u32(from)); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$array3_u8(from: rt.ByteSlice, to: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$array40_u8(from: rt.ByteSlice, to: rt.ByteSlice): void { + to.data.set(rt.byteSliceToArray(from), to.start); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$conversions_Logged(from: conversions_Logged.Logged, to: conversions_Logged.Logged): void { + rt.replaceIn(to, conversions_Logged.clone$Clone(from))[Symbol.dispose](); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$conversions_Named(from: conversions_Named.Named, to: conversions_Named.Named): void { + rt.replaceIn(to, conversions_Named.clone$Clone(from)); +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$u32(from: rt.u32, to: rt.Place): void { + to.v = from; +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$u64(from: rt.u64, to: rt.Place): void { + to.v = from; +} + +/** `clone_into` through a `&mut` whose place only the caller knows. */ +export function cloneIntoParam$u8(from: rt.u8, to: rt.Place): void { + to.v = from; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$Option_u16(s: Array, value: rt.u16 | undefined): rt.u16 | undefined { + rt.idx(s, 0); + const _8: rt.u16 | undefined = value; + const old2 = s[0]; + s[0] = _8; + const old: rt.u16 | undefined = old2; + const _10: rt.u16 | undefined = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$String(s: string[], value: string): string { + rt.idx(s, 0); + const _8: string = value; + const old2 = s[0]; + s[0] = _8; + const old: string = old2; + const _10: string = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$Vec_u32(s: rt.u32[][], value: rt.u32[]): rt.u32[] { + rt.idx(s, 0); + const _8: rt.u32[] = rt.vecExact(value.slice(), 4); + const old2 = s[0]; + s[0] = _8; + const old: rt.u32[] = old2; + const _10: rt.u32[] = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$Vec_u8(s: rt.ByteVec[], value: rt.ByteVec): rt.ByteVec { + rt.idx(s, 0); + const _8: rt.ByteVec = rt.byteVecFrom(rt.byteVecView(value)); + const old2 = s[0]; + s[0] = _8; + const old: rt.ByteVec = old2; + const _10: rt.ByteVec = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$array0_u8(s: Uint8Array[], value: Uint8Array): Uint8Array { + value = copy$array_u8(value); + rt.idx(s, 0); + rt.byteSliceFrom(s[0]); + const old: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(value))); + const _10: Uint8Array = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +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 old2 = rt.byteSliceToArray(_3); + _3.data.set(_8, _3.start); + const old: Uint8Array = old2; + const _10: Uint8Array = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$array2_u32(s: rt.u32[][], value: rt.u32[]): rt.u32[] { + value = copy$array_u32(value); + rt.idx(s, 0); + const _8: rt.u32[] = copy$array_u32(copy$array_u32(value)); + const old2 = s[0]; + s[0] = _8; + const old: rt.u32[] = old2; + const _10: rt.u32[] = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +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 old2 = rt.byteSliceToArray(_3); + _3.data.set(_8, _3.start); + const old: Uint8Array = old2; + const _10: Uint8Array = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +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 old2 = rt.byteSliceToArray(_3); + _3.data.set(_8, _3.start); + const old: Uint8Array = old2; + const _10: Uint8Array = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$conversions_Logged(s: conversions_Logged.Logged[], value: conversions_Logged.Logged): conversions_Logged.Logged { + rt.idx(s, 0); + const _8: conversions_Logged.Logged = conversions_Logged.clone$Clone(value); + const old2 = s[0]; + s[0] = _8; + const old: conversions_Logged.Logged = old2; + const _10: conversions_Logged.Logged = value; + rt.idx(s, 0); + s[0][Symbol.dispose](); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$conversions_Named(s: conversions_Named.Named[], value: conversions_Named.Named): conversions_Named.Named { + rt.idx(s, 0); + const _8: conversions_Named.Named = conversions_Named.clone$Clone(value); + const old2 = s[0]; + s[0] = _8; + const old: conversions_Named.Named = old2; + const _10: conversions_Named.Named = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$u32(s: rt.u32[], value: rt.u32): rt.u32 { + rt.idx(s, 0); + const _8: rt.u32 = value; + const old2 = s[0]; + s[0] = _8; + const old: rt.u32 = old2; + const _10: rt.u32 = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** A whole write into what a slice holds, as a function given any slice makes it. */ +export function writeFirst$u64(s: rt.u64[], value: rt.u64): rt.u64 { + rt.idx(s, 0); + const _8: rt.u64 = value; + const old2 = s[0]; + s[0] = _8; + const old: rt.u64 = old2; + const _10: rt.u64 = value; + rt.idx(s, 0); + s[0] = _10; + return old; +} + +/** + * A slice of what a `&mut` whose place only the caller knows points at, written through: + * one to a value JS copies or to an array of bytes, which a whole write reaches, unlike + * an object's slot. + */ +export function lentParam$Option_u16(to: rt.Place, value: rt.u16 | undefined): rt.u16 | undefined { + return writeFirst$Option_u16(rt.sliceOfPlace(to), value); +} + +/** + * A slice of what a `&mut` whose place only the caller knows points at, written through: + * one to a value JS copies or to an array of bytes, which a whole write reaches, unlike + * an object's slot. + */ +export function lentParam$String(to: rt.Place, value: string): string { + return writeFirst$String(rt.sliceOfPlace(to), value); +} + +/** + * A slice of what a `&mut` whose place only the caller knows points at, written through: + * one to a value JS copies or to an array of bytes, which a whole write reaches, unlike + * an object's slot. + */ +export function lentParam$array3_u8(to: rt.ByteSlice, value: Uint8Array): Uint8Array { + return writeFirst$array3_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(to))), value); +} + +/** + * A slice of what a `&mut` whose place only the caller knows points at, written through: + * one to a value JS copies or to an array of bytes, which a whole write reaches, unlike + * an object's slot. + */ +export function lentParam$u32(to: rt.Place, value: rt.u32): rt.u32 { + return writeFirst$u32(rt.sliceOfPlace(to), value); +} + +/** [`lent_param`] of an element. */ +export function lentThrough$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void { + const v: Array = [make$conversions_Value_Option_u16(data, 2), make$conversions_Value_Option_u16(data, 4)]; + const at = rt.idx(v, 1); + const _12: rt.u16 | undefined = make$conversions_Value_Option_u16(data, 18); + put$conversions_Value_Option_u16(lentParam$Option_u16(rt.place(() => v[at], (value) => v[at] = value), _12), out); + put$conversions_Value_Option_u16(v[rt.idx(v, 1)], out); +} + +/** [`lent_param`] of an element. */ +export function lentThrough$String(data: rt.ByteSlice, out: rt.ByteVec): void { + const v: string[] = [make$conversions_Value_String(data, 2), make$conversions_Value_String(data, 4)]; + const at = rt.idx(v, 1); + const _12: string = make$conversions_Value_String(data, 18); + put$conversions_Value_String(lentParam$String(rt.place(() => v[at], (value) => v[at] = value), _12), out); + put$conversions_Value_String(v[rt.idx(v, 1)], out); +} + +/** [`lent_param`] of an element. */ +export function lentThrough$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + 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); + put$conversions_Value_array3_u8(rt.byteSliceFrom(lentParam$array3_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), make$conversions_Value_array3_u8(data, 18))), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); +} + +/** [`lent_param`] of an element. */ +export function lentThrough$u32(data: rt.ByteSlice, out: rt.ByteVec): void { + const v: rt.u32[] = [make$conversions_Value_u32(data, 2), make$conversions_Value_u32(data, 4)]; + const at = rt.idx(v, 1); + const _12: rt.u32 = make$conversions_Value_u32(data, 18); + put$conversions_Value_u32(lentParam$u32(rt.place(() => v[at], (value) => v[at] = value), _12), out); + put$conversions_Value_u32(v[rt.idx(v, 1)], out); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$Option_u16(to: rt.Place, value: rt.u16 | undefined): rt.u16 | undefined { + return rt.cellReplace(rt.cellOfPlace(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$String(to: rt.Place, value: string): string { + return rt.cellReplace(rt.cellOfPlace(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$Vec_u32(to: rt.u32[], value: rt.u32[]): rt.u32[] { + return rt.cellReplace(rt.cellIn(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$Vec_u8(to: rt.ByteVec, value: rt.ByteVec): rt.ByteVec { + return rt.cellReplace(rt.cellIn(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$array0_u8(to: rt.ByteSlice, value: Uint8Array): Uint8Array { + return rt.cellReplace(rt.cellIn(rt.byteSliceView(to)), copy$array_u8(value)); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$array1_u8(to: rt.ByteSlice, value: Uint8Array): Uint8Array { + return rt.cellReplace(rt.cellIn(rt.byteSliceView(to)), copy$array_u8(value)); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$array2_u32(to: rt.u32[], value: rt.u32[]): rt.u32[] { + return rt.cellReplace(rt.cellIn(to), copy$array_u32(value)); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$array3_u8(to: rt.ByteSlice, value: Uint8Array): Uint8Array { + return rt.cellReplace(rt.cellIn(rt.byteSliceView(to)), copy$array_u8(value)); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$array40_u8(to: rt.ByteSlice, value: Uint8Array): Uint8Array { + return rt.cellReplace(rt.cellIn(rt.byteSliceView(to)), copy$array_u8(value)); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$conversions_Logged(to: conversions_Logged.Logged, value: conversions_Logged.Logged): conversions_Logged.Logged { + return rt.cellReplace(rt.cellIn(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$conversions_Named(to: conversions_Named.Named, value: conversions_Named.Named): conversions_Named.Named { + return rt.cellReplace(rt.cellIn(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$u32(to: rt.Place, value: rt.u32): rt.u32 { + return rt.cellReplace(rt.cellOfPlace(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$u64(to: rt.Place, value: rt.u64): rt.u64 { + return rt.cellReplace(rt.cellOfPlace(to), value); +} + +/** A cell of what a `&mut` whose place only the caller knows points at, written through. */ +export function setThrough$u8(to: rt.Place, value: rt.u8): rt.u8 { + return rt.cellReplace(rt.cellOfPlace(to), value); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.u16 | undefined = make$conversions_Value_Option_u16(data, 0); + const b: rt.u16 | undefined = make$conversions_Value_Option_u16(data, 3); + const owned: rt.u16 | undefined = a; + a = b; + put$conversions_Value_Option_u16(owned, out); + put$conversions_Value_Option_u16(a, out); + let c: rt.u16 | undefined = make$conversions_Value_Option_u16(data, 6); + c = owned; + put$conversions_Value_Option_u16(c, out); + cloneFromParam$Option_u16(rt.place(() => c, (value) => c = value), b); + cloneIntoParam$Option_u16(owned, rt.place(() => a, (value2) => a = value2)); + put$conversions_Value_Option_u16(c, out); + put$conversions_Value_Option_u16(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_Option_u16(data, 1)); + held.value = c; + const v: Array = [make$conversions_Value_Option_u16(data, 2), make$conversions_Value_Option_u16(data, 4)]; + v[rt.idx(v, 1)] = held.value; + v[rt.idx(v, 0)] = b; + put$conversions_Value_Option_u16(held.value, out); + put$conversions_Value_Option_u16(v[rt.idx(v, 0)], out); + put$conversions_Value_Option_u16(v[rt.idx(v, 1)], out); + const one: Array = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.u16 | undefined = one[0]; + put$conversions_Value_Option_u16(one[0], out); + a = copied; + put$conversions_Value_Option_u16(copied, out); + put$conversions_Value_Option_u16(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value3) => c = value3)); + const old: rt.u16 | undefined = rt.cellReplace(cell, make$conversions_Value_Option_u16(data, 10)); + rt.cellSet(cell, make$conversions_Value_Option_u16(data, 11)); + put$conversions_Value_Option_u16(old, out); + put$conversions_Value_Option_u16(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.u16 | undefined = make$conversions_Value_Option_u16(data, 12); + put$conversions_Value_Option_u16(setThrough$Option_u16(rt.place(() => v[at5], (value4) => v[at5] = value4), _91), out); + put$conversions_Value_Option_u16(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value5) => borrowed.value = value5)), make$conversions_Value_Option_u16(data, 17)); + put$conversions_Value_Option_u16(held.value, out); + const array: Array = [make$conversions_Value_Option_u16(data, 13), make$conversions_Value_Option_u16(data, 14), make$conversions_Value_Option_u16(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.u16 | undefined = b; + const _116: Array = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: Array = array; + rt.idx(_124, 2); + _124[2] = c; + for (const _134 of array) { + put$conversions_Value_Option_u16(_134, out); + } + put$conversions_Value_Option_u16({ v: b }.v, out); + c = make$conversions_Value_Option_u16(data, 16); + put$conversions_Value_Option_u16(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$String(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: string = make$conversions_Value_String(data, 0); + const b: string = make$conversions_Value_String(data, 3); + const owned: string = a; + a = b; + put$conversions_Value_String(owned, out); + put$conversions_Value_String(a, out); + let c: string = make$conversions_Value_String(data, 6); + c = owned; + put$conversions_Value_String(c, out); + cloneFromParam$String(rt.place(() => c, (value) => c = value), b); + cloneIntoParam$String(owned, rt.place(() => a, (value2) => a = value2)); + put$conversions_Value_String(c, out); + put$conversions_Value_String(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_String(data, 1)); + held.value = c; + const v: string[] = [make$conversions_Value_String(data, 2), make$conversions_Value_String(data, 4)]; + v[rt.idx(v, 1)] = held.value; + v[rt.idx(v, 0)] = b; + put$conversions_Value_String(held.value, out); + put$conversions_Value_String(v[rt.idx(v, 0)], out); + put$conversions_Value_String(v[rt.idx(v, 1)], out); + const one: string[] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: string = one[0]; + put$conversions_Value_String(one[0], out); + a = copied; + put$conversions_Value_String(copied, out); + put$conversions_Value_String(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value3) => c = value3)); + const old: string = rt.cellReplace(cell, make$conversions_Value_String(data, 10)); + rt.cellSet(cell, make$conversions_Value_String(data, 11)); + put$conversions_Value_String(old, out); + put$conversions_Value_String(c, out); + const at5 = rt.idx(v, 0); + const _91: string = make$conversions_Value_String(data, 12); + put$conversions_Value_String(setThrough$String(rt.place(() => v[at5], (value4) => v[at5] = value4), _91), out); + put$conversions_Value_String(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value5) => borrowed.value = value5)), make$conversions_Value_String(data, 17)); + put$conversions_Value_String(held.value, out); + const array: string[] = [make$conversions_Value_String(data, 13), make$conversions_Value_String(data, 14), make$conversions_Value_String(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: string = b; + const _116: string[] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: string[] = array; + rt.idx(_124, 2); + _124[2] = c; + for (const _134 of array) { + put$conversions_Value_String(_134, out); + } + put$conversions_Value_String({ v: b }.v, out); + c = make$conversions_Value_String(data, 16); + put$conversions_Value_String(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$Vec_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.u32[] = make$conversions_Value_Vec_u32(data, 0); + const b: rt.u32[] = make$conversions_Value_Vec_u32(data, 3); + const owned: rt.u32[] = rt.vecExact(a.slice(), 4); + a = rt.vecExact(b.slice(), 4); + put$conversions_Value_Vec_u32(owned, out); + put$conversions_Value_Vec_u32(a, out); + let c: rt.u32[] = make$conversions_Value_Vec_u32(data, 6); + c = rt.vecExact(owned.slice(), 4); + put$conversions_Value_Vec_u32(c, out); + cloneFromParam$Vec_u32(c, b); + cloneIntoParam$Vec_u32(owned, a); + put$conversions_Value_Vec_u32(c, out); + put$conversions_Value_Vec_u32(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_Vec_u32(data, 1)); + held.value = rt.vecExact(c.slice(), 4); + const v: rt.u32[][] = [make$conversions_Value_Vec_u32(data, 2), make$conversions_Value_Vec_u32(data, 4)]; + v[rt.idx(v, 1)] = rt.vecExact(held.value.slice(), 4); + v[rt.idx(v, 0)] = rt.vecExact(b.slice(), 4); + put$conversions_Value_Vec_u32(held.value, out); + put$conversions_Value_Vec_u32(v[rt.idx(v, 0)], out); + put$conversions_Value_Vec_u32(v[rt.idx(v, 1)], out); + const one: rt.u32[][] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.u32[] = rt.vecExact(one[0].slice(), 4); + put$conversions_Value_Vec_u32(one[0], out); + a = rt.vecExact(copied.slice(), 4); + put$conversions_Value_Vec_u32(copied, out); + put$conversions_Value_Vec_u32(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: rt.u32[] = rt.cellReplace(cell, make$conversions_Value_Vec_u32(data, 10)); + rt.cellSet(cell, make$conversions_Value_Vec_u32(data, 11)); + put$conversions_Value_Vec_u32(old, out); + put$conversions_Value_Vec_u32(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.u32[] = make$conversions_Value_Vec_u32(data, 12); + put$conversions_Value_Vec_u32(setThrough$Vec_u32(v[at5], _91), out); + put$conversions_Value_Vec_u32(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_Vec_u32(data, 17)); + put$conversions_Value_Vec_u32(held.value, out); + const array: rt.u32[][] = [make$conversions_Value_Vec_u32(data, 13), make$conversions_Value_Vec_u32(data, 14), make$conversions_Value_Vec_u32(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.u32[] = rt.vecExact(b.slice(), 4); + const _116: rt.u32[][] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: rt.u32[][] = array; + rt.idx(_124, 2); + _124[2] = rt.vecExact(c.slice(), 4); + for (const _134 of array) { + put$conversions_Value_Vec_u32(_134, out); + } + put$conversions_Value_Vec_u32({ v: b }.v, out); + c = make$conversions_Value_Vec_u32(data, 16); + put$conversions_Value_Vec_u32(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$Vec_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.ByteVec = make$conversions_Value_Vec_u8(data, 0); + const b: rt.ByteVec = make$conversions_Value_Vec_u8(data, 3); + const owned: rt.ByteVec = rt.byteVecFrom(rt.byteVecView(a)); + a = rt.byteVecFrom(rt.byteVecView(b)); + put$conversions_Value_Vec_u8(owned, out); + put$conversions_Value_Vec_u8(a, out); + let c: rt.ByteVec = make$conversions_Value_Vec_u8(data, 6); + c = rt.byteVecFrom(rt.byteVecView(owned)); + put$conversions_Value_Vec_u8(c, out); + cloneFromParam$Vec_u8(c, b); + cloneIntoParam$Vec_u8(owned, a); + put$conversions_Value_Vec_u8(c, out); + put$conversions_Value_Vec_u8(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_Vec_u8(data, 1)); + held.value = rt.byteVecFrom(rt.byteVecView(c)); + const v: rt.ByteVec[] = [make$conversions_Value_Vec_u8(data, 2), make$conversions_Value_Vec_u8(data, 4)]; + v[rt.idx(v, 1)] = rt.byteVecFrom(rt.byteVecView(held.value)); + v[rt.idx(v, 0)] = rt.byteVecFrom(rt.byteVecView(b)); + put$conversions_Value_Vec_u8(held.value, out); + put$conversions_Value_Vec_u8(v[rt.idx(v, 0)], out); + put$conversions_Value_Vec_u8(v[rt.idx(v, 1)], out); + const one: rt.ByteVec[] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.ByteVec = rt.byteVecFrom(rt.byteVecView(one[0])); + put$conversions_Value_Vec_u8(one[0], out); + a = rt.byteVecFrom(rt.byteVecView(copied)); + put$conversions_Value_Vec_u8(copied, out); + put$conversions_Value_Vec_u8(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: rt.ByteVec = rt.cellReplace(cell, make$conversions_Value_Vec_u8(data, 10)); + rt.cellSet(cell, make$conversions_Value_Vec_u8(data, 11)); + put$conversions_Value_Vec_u8(old, out); + put$conversions_Value_Vec_u8(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.ByteVec = make$conversions_Value_Vec_u8(data, 12); + put$conversions_Value_Vec_u8(setThrough$Vec_u8(v[at5], _91), out); + put$conversions_Value_Vec_u8(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_Vec_u8(data, 17)); + put$conversions_Value_Vec_u8(held.value, out); + const array: rt.ByteVec[] = [make$conversions_Value_Vec_u8(data, 13), make$conversions_Value_Vec_u8(data, 14), make$conversions_Value_Vec_u8(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.ByteVec = rt.byteVecFrom(rt.byteVecView(b)); + const _116: rt.ByteVec[] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: rt.ByteVec[] = array; + rt.idx(_124, 2); + _124[2] = rt.byteVecFrom(rt.byteVecView(c)); + for (const _134 of array) { + put$conversions_Value_Vec_u8(_134, out); + } + put$conversions_Value_Vec_u8({ v: b }.v, out); + c = make$conversions_Value_Vec_u8(data, 16); + put$conversions_Value_Vec_u8(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +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); + _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); + const c: Uint8Array = copy$array_u8(make$conversions_Value_array0_u8(data, 6)); + const _16: rt.ByteSlice = rt.byteSliceFrom(owned); + const _17: rt.ByteSlice = rt.byteSliceFrom(c); + _17.data.set(rt.byteSliceToArray(_16), _17.start); + put$conversions_Value_array0_u8(rt.byteSliceFrom(c), out); + cloneFromParam$array0_u8(rt.byteSliceFrom(c), rt.byteSliceFrom(b)); + cloneIntoParam$array0_u8(rt.byteSliceFrom(owned), rt.byteSliceFrom(a)); + put$conversions_Value_array0_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(a), out); + const held: conversions_Held.Held = new conversions_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); + _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 _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)]); + _45.data.set(rt.byteSliceToArray(_44), _45.start); + put$conversions_Value_array0_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + const one: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + 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); + _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); + const cell: rt.Cell = rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(c))); + const old: Uint8Array = rt.cellReplace(cell, copy$array_u8(make$conversions_Value_array0_u8(data, 10))); + rt.cellSet(cell, copy$array_u8(make$conversions_Value_array0_u8(data, 11))); + put$conversions_Value_array0_u8(rt.byteSliceFrom(old), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(setThrough$array0_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), make$conversions_Value_array0_u8(data, 12))), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + rt.cellSet(rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(held.value))), copy$array_u8(make$conversions_Value_array0_u8(data, 17))); + put$conversions_Value_array0_u8(rt.byteSliceFrom(held.value), out); + const array: Uint8Array[] = [copy$array_u8(make$conversions_Value_array0_u8(data, 13)), copy$array_u8(make$conversions_Value_array0_u8(data, 14)), copy$array_u8(make$conversions_Value_array0_u8(data, 15))]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))); + const _116: Uint8Array[] = array; + rt.idx(_116, 0); + _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]); + _123.data.set(rt.byteSliceToArray(_130), _123.start); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); + while (true) { + const _134: rt.ByteSlice | rt.Done = iter.next(); + if (_134 === rt.DONE) { + break; + } + put$conversions_Value_array0_u8(_134, out); + } + put$conversions_Value_array0_u8(rt.byteSliceFrom(rt.byteSliceView(rt.byteSliceFrom(b))), out); + rt.byteSliceFrom(c); + copy$array_u8(make$conversions_Value_array0_u8(data, 16)); + put$conversions_Value_array0_u8(rt.byteSliceFrom(c), out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +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); + _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); + const c: Uint8Array = copy$array_u8(make$conversions_Value_array1_u8(data, 6)); + const _16: rt.ByteSlice = rt.byteSliceFrom(owned); + const _17: rt.ByteSlice = rt.byteSliceFrom(c); + _17.data.set(rt.byteSliceToArray(_16), _17.start); + put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); + cloneFromParam$array1_u8(rt.byteSliceFrom(c), rt.byteSliceFrom(b)); + cloneIntoParam$array1_u8(rt.byteSliceFrom(owned), rt.byteSliceFrom(a)); + put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(a), out); + const held: conversions_Held.Held = new conversions_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); + _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 _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)]); + _45.data.set(rt.byteSliceToArray(_44), _45.start); + put$conversions_Value_array1_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + const one: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + 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); + _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); + const cell: rt.Cell = rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(c))); + const old: Uint8Array = rt.cellReplace(cell, copy$array_u8(make$conversions_Value_array1_u8(data, 10))); + rt.cellSet(cell, copy$array_u8(make$conversions_Value_array1_u8(data, 11))); + put$conversions_Value_array1_u8(rt.byteSliceFrom(old), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(setThrough$array1_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), make$conversions_Value_array1_u8(data, 12))), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + rt.cellSet(rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(held.value))), copy$array_u8(make$conversions_Value_array1_u8(data, 17))); + put$conversions_Value_array1_u8(rt.byteSliceFrom(held.value), out); + const array: Uint8Array[] = [copy$array_u8(make$conversions_Value_array1_u8(data, 13)), copy$array_u8(make$conversions_Value_array1_u8(data, 14)), copy$array_u8(make$conversions_Value_array1_u8(data, 15))]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))); + const _116: Uint8Array[] = array; + rt.idx(_116, 0); + _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]); + _123.data.set(rt.byteSliceToArray(_130), _123.start); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); + while (true) { + const _134: rt.ByteSlice | rt.Done = iter.next(); + if (_134 === rt.DONE) { + break; + } + 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); + q.data.set(_145, q.start); + put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$array2_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.u32[] = copy$array_u32(make$conversions_Value_array2_u32(data, 0)); + const b: rt.u32[] = make$conversions_Value_array2_u32(data, 3); + const owned: rt.u32[] = copy$array_u32(a); + a = copy$array_u32(b); + put$conversions_Value_array2_u32(owned, out); + put$conversions_Value_array2_u32(a, out); + let c: rt.u32[] = copy$array_u32(make$conversions_Value_array2_u32(data, 6)); + c = copy$array_u32(owned); + put$conversions_Value_array2_u32(c, out); + cloneFromParam$array2_u32(c, b); + cloneIntoParam$array2_u32(owned, a); + put$conversions_Value_array2_u32(c, out); + put$conversions_Value_array2_u32(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(copy$array_u32(make$conversions_Value_array2_u32(data, 1))); + held.value = copy$array_u32(c); + const v: rt.u32[][] = copy$array_array2_u32([make$conversions_Value_array2_u32(data, 2), make$conversions_Value_array2_u32(data, 4)]).map(copy$array_u32); + v[rt.idx(v, 1)] = copy$array_u32(held.value); + v[rt.idx(v, 0)] = copy$array_u32(b); + put$conversions_Value_array2_u32(held.value, out); + put$conversions_Value_array2_u32(v[rt.idx(v, 0)], out); + put$conversions_Value_array2_u32(v[rt.idx(v, 1)], out); + const one: rt.u32[][] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.u32[] = copy$array_u32(one[0]); + put$conversions_Value_array2_u32(one[0], out); + a = copy$array_u32(copied); + put$conversions_Value_array2_u32(copied, out); + put$conversions_Value_array2_u32(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: rt.u32[] = rt.cellReplace(cell, copy$array_u32(make$conversions_Value_array2_u32(data, 10))); + rt.cellSet(cell, copy$array_u32(make$conversions_Value_array2_u32(data, 11))); + put$conversions_Value_array2_u32(old, out); + put$conversions_Value_array2_u32(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.u32[] = make$conversions_Value_array2_u32(data, 12); + put$conversions_Value_array2_u32(setThrough$array2_u32(v[at5], _91), out); + put$conversions_Value_array2_u32(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), copy$array_u32(make$conversions_Value_array2_u32(data, 17))); + put$conversions_Value_array2_u32(held.value, out); + const array: rt.u32[][] = [copy$array_u32(make$conversions_Value_array2_u32(data, 13)), copy$array_u32(make$conversions_Value_array2_u32(data, 14)), copy$array_u32(make$conversions_Value_array2_u32(data, 15))]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.u32[] = copy$array_u32(copy$array_u32(b)); + const _116: rt.u32[][] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: rt.u32[][] = array; + rt.idx(_124, 2); + _124[2] = copy$array_u32(c); + for (const _134 of array) { + put$conversions_Value_array2_u32(_134, out); + } + put$conversions_Value_array2_u32(b, out); + rt.ptrWrite(c, copy$array_u32(make$conversions_Value_array2_u32(data, 16))); + put$conversions_Value_array2_u32(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +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); + _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); + const c: Uint8Array = copy$array_u8(make$conversions_Value_array3_u8(data, 6)); + const _16: rt.ByteSlice = rt.byteSliceFrom(owned); + const _17: rt.ByteSlice = rt.byteSliceFrom(c); + _17.data.set(rt.byteSliceToArray(_16), _17.start); + put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); + cloneFromParam$array3_u8(rt.byteSliceFrom(c), rt.byteSliceFrom(b)); + cloneIntoParam$array3_u8(rt.byteSliceFrom(owned), rt.byteSliceFrom(a)); + put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(a), out); + const held: conversions_Held.Held = new conversions_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); + _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 _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)]); + _45.data.set(rt.byteSliceToArray(_44), _45.start); + put$conversions_Value_array3_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + const one: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + 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); + _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); + const cell: rt.Cell = rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(c))); + const old: Uint8Array = rt.cellReplace(cell, copy$array_u8(make$conversions_Value_array3_u8(data, 10))); + rt.cellSet(cell, copy$array_u8(make$conversions_Value_array3_u8(data, 11))); + put$conversions_Value_array3_u8(rt.byteSliceFrom(old), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(setThrough$array3_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), make$conversions_Value_array3_u8(data, 12))), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + rt.cellSet(rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(held.value))), copy$array_u8(make$conversions_Value_array3_u8(data, 17))); + put$conversions_Value_array3_u8(rt.byteSliceFrom(held.value), out); + const array: Uint8Array[] = [copy$array_u8(make$conversions_Value_array3_u8(data, 13)), copy$array_u8(make$conversions_Value_array3_u8(data, 14)), copy$array_u8(make$conversions_Value_array3_u8(data, 15))]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))); + const _116: Uint8Array[] = array; + rt.idx(_116, 0); + _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]); + _123.data.set(rt.byteSliceToArray(_130), _123.start); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); + while (true) { + const _134: rt.ByteSlice | rt.Done = iter.next(); + if (_134 === rt.DONE) { + break; + } + 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); + q.data.set(_145, q.start); + put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +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); + _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); + const c: Uint8Array = copy$array_u8(make$conversions_Value_array40_u8(data, 6)); + const _16: rt.ByteSlice = rt.byteSliceFrom(owned); + const _17: rt.ByteSlice = rt.byteSliceFrom(c); + _17.data.set(rt.byteSliceToArray(_16), _17.start); + put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); + cloneFromParam$array40_u8(rt.byteSliceFrom(c), rt.byteSliceFrom(b)); + cloneIntoParam$array40_u8(rt.byteSliceFrom(owned), rt.byteSliceFrom(a)); + put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(a), out); + const held: conversions_Held.Held = new conversions_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); + _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 _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)]); + _45.data.set(rt.byteSliceToArray(_44), _45.start); + put$conversions_Value_array40_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + const one: Uint8Array[] = [rt.byteSliceView(rt.byteSliceFrom(b))]; + 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); + _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); + const cell: rt.Cell = rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(c))); + const old: Uint8Array = rt.cellReplace(cell, copy$array_u8(make$conversions_Value_array40_u8(data, 10))); + rt.cellSet(cell, copy$array_u8(make$conversions_Value_array40_u8(data, 11))); + put$conversions_Value_array40_u8(rt.byteSliceFrom(old), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(setThrough$array40_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), make$conversions_Value_array40_u8(data, 12))), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(v[rt.idx(v, 0)]), out); + rt.cellSet(rt.cellIn(rt.byteSliceView(rt.byteSliceFrom(held.value))), copy$array_u8(make$conversions_Value_array40_u8(data, 17))); + put$conversions_Value_array40_u8(rt.byteSliceFrom(held.value), out); + const array: Uint8Array[] = [copy$array_u8(make$conversions_Value_array40_u8(data, 13)), copy$array_u8(make$conversions_Value_array40_u8(data, 14)), copy$array_u8(make$conversions_Value_array40_u8(data, 15))]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: Uint8Array = copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))); + const _116: Uint8Array[] = array; + rt.idx(_116, 0); + _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]); + _123.data.set(rt.byteSliceToArray(_130), _123.start); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(array), rt.byteSliceFrom); + while (true) { + const _134: rt.ByteSlice | rt.Done = iter.next(); + if (_134 === rt.DONE) { + break; + } + 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); + q.data.set(_145, q.start); + put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 0); + const b: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 3); + const owned: conversions_Logged.Logged = conversions_Logged.clone$Clone(a); + const old2 = a; + a = conversions_Logged.clone$Clone(b); + old2[Symbol.dispose](); + conversions_Logged.put$conversions_Value(owned, out); + conversions_Logged.put$conversions_Value(a, out); + let c: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 6); + const old3 = c; + c = conversions_Logged.clone$Clone(owned); + old3[Symbol.dispose](); + conversions_Logged.put$conversions_Value(c, out); + cloneFromParam$conversions_Logged(c, b); + cloneIntoParam$conversions_Logged(owned, a); + conversions_Logged.put$conversions_Value(c, out); + conversions_Logged.put$conversions_Value(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(conversions_Logged.make$conversions_Value(data, 1)); + const old4 = held.value; + held.value = conversions_Logged.clone$Clone(c); + old4[Symbol.dispose](); + const v: conversions_Logged.Logged[] = [conversions_Logged.make$conversions_Value(data, 2), conversions_Logged.make$conversions_Value(data, 4)]; + const at = rt.idx(v, 1); + const old5 = v[at]; + v[at] = conversions_Logged.clone$Clone(held.value); + old5[Symbol.dispose](); + const at2 = rt.idx(v, 0); + const old6 = v[at2]; + v[at2] = conversions_Logged.clone$Clone(b); + old6[Symbol.dispose](); + conversions_Logged.put$conversions_Value(held.value, out); + conversions_Logged.put$conversions_Value(v[rt.idx(v, 0)], out); + conversions_Logged.put$conversions_Value(v[rt.idx(v, 1)], out); + const one: conversions_Logged.Logged[] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: conversions_Logged.Logged = conversions_Logged.clone$Clone(one[0]); + conversions_Logged.put$conversions_Value(one[0], out); + const old7 = a; + a = conversions_Logged.clone$Clone(copied); + old7[Symbol.dispose](); + conversions_Logged.put$conversions_Value(copied, out); + conversions_Logged.put$conversions_Value(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: conversions_Logged.Logged = rt.cellReplace(cell, conversions_Logged.make$conversions_Value(data, 10)); + rt.cellSet(cell, conversions_Logged.make$conversions_Value(data, 11), rt.drop); + conversions_Logged.put$conversions_Value(old, out); + conversions_Logged.put$conversions_Value(c, out); + const at5 = rt.idx(v, 0); + const _91: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 12); + const _88: conversions_Logged.Logged = setThrough$conversions_Logged(v[at5], _91); + conversions_Logged.put$conversions_Value(_88, out); + _88[Symbol.dispose](); + conversions_Logged.put$conversions_Value(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), conversions_Logged.make$conversions_Value(data, 17), rt.drop); + conversions_Logged.put$conversions_Value(held.value, out); + const array: conversions_Logged.Logged[] = [conversions_Logged.make$conversions_Value(data, 13), conversions_Logged.make$conversions_Value(data, 14), conversions_Logged.make$conversions_Value(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: conversions_Logged.Logged = conversions_Logged.clone$Clone(b); + const _116: conversions_Logged.Logged[] = array; + rt.idx(_116, 0); + _116[0][Symbol.dispose](); + _116[0] = _114; + const _124: conversions_Logged.Logged[] = array; + rt.idx(_124, 2); + const old8 = _124[2]; + _124[2] = conversions_Logged.clone$Clone(c); + old8[Symbol.dispose](); + for (const _134 of array) { + conversions_Logged.put$conversions_Value(_134, out); + } + conversions_Logged.put$conversions_Value(b, out); + const q: conversions_Logged.Logged = c; + const _145: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 16); + q[Symbol.dispose](); + rt.ptrWrite(q, _145); + conversions_Logged.put$conversions_Value(c, out); + rt.dropAll(array); + old[Symbol.dispose](); + copied[Symbol.dispose](); + rt.dropAll(v); + held[Symbol.dispose](); + c[Symbol.dispose](); + owned[Symbol.dispose](); + b[Symbol.dispose](); + a[Symbol.dispose](); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$conversions_Named(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: conversions_Named.Named = conversions_Named.make$conversions_Value(data, 0); + const b: conversions_Named.Named = conversions_Named.make$conversions_Value(data, 3); + const owned: conversions_Named.Named = conversions_Named.clone$Clone(a); + a = conversions_Named.clone$Clone(b); + conversions_Named.put$conversions_Value(owned, out); + conversions_Named.put$conversions_Value(a, out); + let c: conversions_Named.Named = conversions_Named.make$conversions_Value(data, 6); + c = conversions_Named.clone$Clone(owned); + conversions_Named.put$conversions_Value(c, out); + cloneFromParam$conversions_Named(c, b); + cloneIntoParam$conversions_Named(owned, a); + conversions_Named.put$conversions_Value(c, out); + conversions_Named.put$conversions_Value(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(conversions_Named.make$conversions_Value(data, 1)); + held.value = conversions_Named.clone$Clone(c); + const v: conversions_Named.Named[] = [conversions_Named.make$conversions_Value(data, 2), conversions_Named.make$conversions_Value(data, 4)]; + v[rt.idx(v, 1)] = conversions_Named.clone$Clone(held.value); + v[rt.idx(v, 0)] = conversions_Named.clone$Clone(b); + conversions_Named.put$conversions_Value(held.value, out); + conversions_Named.put$conversions_Value(v[rt.idx(v, 0)], out); + conversions_Named.put$conversions_Value(v[rt.idx(v, 1)], out); + const one: conversions_Named.Named[] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: conversions_Named.Named = conversions_Named.clone$Clone(one[0]); + conversions_Named.put$conversions_Value(one[0], out); + a = conversions_Named.clone$Clone(copied); + conversions_Named.put$conversions_Value(copied, out); + conversions_Named.put$conversions_Value(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value) => c = value)); + const old: conversions_Named.Named = rt.cellReplace(cell, conversions_Named.make$conversions_Value(data, 10)); + rt.cellSet(cell, conversions_Named.make$conversions_Value(data, 11)); + conversions_Named.put$conversions_Value(old, out); + conversions_Named.put$conversions_Value(c, out); + const at5 = rt.idx(v, 0); + const _91: conversions_Named.Named = conversions_Named.make$conversions_Value(data, 12); + conversions_Named.put$conversions_Value(setThrough$conversions_Named(v[at5], _91), out); + conversions_Named.put$conversions_Value(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), conversions_Named.make$conversions_Value(data, 17)); + conversions_Named.put$conversions_Value(held.value, out); + const array: conversions_Named.Named[] = [conversions_Named.make$conversions_Value(data, 13), conversions_Named.make$conversions_Value(data, 14), conversions_Named.make$conversions_Value(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: conversions_Named.Named = conversions_Named.clone$Clone(b); + const _116: conversions_Named.Named[] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: conversions_Named.Named[] = array; + rt.idx(_124, 2); + _124[2] = conversions_Named.clone$Clone(c); + for (const _134 of array) { + conversions_Named.put$conversions_Value(_134, out); + } + conversions_Named.put$conversions_Value(b, out); + rt.ptrWrite(c, conversions_Named.make$conversions_Value(data, 16)); + conversions_Named.put$conversions_Value(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$u32(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.u32 = make$conversions_Value_u32(data, 0); + const b: rt.u32 = make$conversions_Value_u32(data, 3); + const owned: rt.u32 = a; + a = b; + put$conversions_Value_u32(owned, out); + put$conversions_Value_u32(a, out); + let c: rt.u32 = make$conversions_Value_u32(data, 6); + c = owned; + put$conversions_Value_u32(c, out); + cloneFromParam$u32(rt.place(() => c, (value) => c = value), b); + cloneIntoParam$u32(owned, rt.place(() => a, (value2) => a = value2)); + put$conversions_Value_u32(c, out); + put$conversions_Value_u32(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_u32(data, 1)); + held.value = c; + const v: rt.u32[] = [make$conversions_Value_u32(data, 2), make$conversions_Value_u32(data, 4)]; + v[rt.idx(v, 1)] = held.value; + v[rt.idx(v, 0)] = b; + put$conversions_Value_u32(held.value, out); + put$conversions_Value_u32(v[rt.idx(v, 0)], out); + put$conversions_Value_u32(v[rt.idx(v, 1)], out); + const one: rt.u32[] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.u32 = one[0]; + put$conversions_Value_u32(one[0], out); + a = copied; + put$conversions_Value_u32(copied, out); + put$conversions_Value_u32(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value3) => c = value3)); + const old: rt.u32 = rt.cellReplace(cell, make$conversions_Value_u32(data, 10)); + rt.cellSet(cell, make$conversions_Value_u32(data, 11)); + put$conversions_Value_u32(old, out); + put$conversions_Value_u32(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.u32 = make$conversions_Value_u32(data, 12); + put$conversions_Value_u32(setThrough$u32(rt.place(() => v[at5], (value4) => v[at5] = value4), _91), out); + put$conversions_Value_u32(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value5) => borrowed.value = value5)), make$conversions_Value_u32(data, 17)); + put$conversions_Value_u32(held.value, out); + const array: rt.u32[] = [make$conversions_Value_u32(data, 13), make$conversions_Value_u32(data, 14), make$conversions_Value_u32(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.u32 = b; + const _116: rt.u32[] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: rt.u32[] = array; + rt.idx(_124, 2); + _124[2] = c; + for (const _134 of array) { + put$conversions_Value_u32(_134, out); + } + put$conversions_Value_u32({ v: b }.v, out); + c = make$conversions_Value_u32(data, 16); + put$conversions_Value_u32(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$u64(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.u64 = make$conversions_Value_u64(data, 0); + const b: rt.u64 = make$conversions_Value_u64(data, 3); + const owned: rt.u64 = a; + a = b; + put$conversions_Value_u64(owned, out); + put$conversions_Value_u64(a, out); + let c: rt.u64 = make$conversions_Value_u64(data, 6); + c = owned; + put$conversions_Value_u64(c, out); + cloneFromParam$u64(rt.place(() => c, (value) => c = value), b); + cloneIntoParam$u64(owned, rt.place(() => a, (value2) => a = value2)); + put$conversions_Value_u64(c, out); + put$conversions_Value_u64(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_u64(data, 1)); + held.value = c; + const v: rt.u64[] = [make$conversions_Value_u64(data, 2), make$conversions_Value_u64(data, 4)]; + v[rt.idx(v, 1)] = held.value; + v[rt.idx(v, 0)] = b; + put$conversions_Value_u64(held.value, out); + put$conversions_Value_u64(v[rt.idx(v, 0)], out); + put$conversions_Value_u64(v[rt.idx(v, 1)], out); + const one: rt.u64[] = [b]; + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.u64 = one[0]; + put$conversions_Value_u64(one[0], out); + a = copied; + put$conversions_Value_u64(copied, out); + put$conversions_Value_u64(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value3) => c = value3)); + const old: rt.u64 = rt.cellReplace(cell, make$conversions_Value_u64(data, 10)); + rt.cellSet(cell, make$conversions_Value_u64(data, 11)); + put$conversions_Value_u64(old, out); + put$conversions_Value_u64(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.u64 = make$conversions_Value_u64(data, 12); + put$conversions_Value_u64(setThrough$u64(rt.place(() => v[at5], (value4) => v[at5] = value4), _91), out); + put$conversions_Value_u64(v[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value5) => borrowed.value = value5)), make$conversions_Value_u64(data, 17)); + put$conversions_Value_u64(held.value, out); + const array: rt.u64[] = [make$conversions_Value_u64(data, 13), make$conversions_Value_u64(data, 14), make$conversions_Value_u64(data, 15)]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([array.length, array.length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.u64 = b; + const _116: rt.u64[] = array; + rt.idx(_116, 0); + _116[0] = _114; + const _124: rt.u64[] = array; + rt.idx(_124, 2); + _124[2] = c; + for (const _134 of array) { + put$conversions_Value_u64(_134, out); + } + put$conversions_Value_u64({ v: b }.v, out); + c = make$conversions_Value_u64(data, 16); + put$conversions_Value_u64(c, out); +} + +/** Each conversion of a `T`, its copies put after a write to what they copied. */ +export function converted$u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let a: rt.u8 = make$conversions_Value_u8(data, 0); + const b: rt.u8 = make$conversions_Value_u8(data, 3); + const owned: rt.u8 = a; + a = b; + put$conversions_Value_u8(owned, out); + put$conversions_Value_u8(a, out); + let c: rt.u8 = make$conversions_Value_u8(data, 6); + c = owned; + put$conversions_Value_u8(c, out); + cloneFromParam$u8(rt.place(() => c, (value) => c = value), b); + cloneIntoParam$u8(owned, rt.place(() => a, (value2) => a = value2)); + put$conversions_Value_u8(c, out); + put$conversions_Value_u8(a, out); + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_u8(data, 1)); + held.value = c; + const v: rt.ByteVec = rt.byteVecFrom(Uint8Array.of(make$conversions_Value_u8(data, 2), make$conversions_Value_u8(data, 4))); + v.data[rt.idx(v, 1)] = held.value; + v.data[rt.idx(v, 0)] = b; + put$conversions_Value_u8(held.value, out); + put$conversions_Value_u8(v.data[rt.idx(v, 0)], out); + put$conversions_Value_u8(v.data[rt.idx(v, 1)], out); + const one: rt.ByteSlice = rt.byteSliceFrom(Uint8Array.of(b)); + rt.byteVecPush(out, one.length & 0xff); + const copied: rt.u8 = one.data[one.start]; + put$conversions_Value_u8(one.data[one.start], out); + a = copied; + put$conversions_Value_u8(copied, out); + put$conversions_Value_u8(a, out); + const cell: rt.Cell = rt.cellOfPlace(rt.place(() => c, (value3) => c = value3)); + const old: rt.u8 = rt.cellReplace(cell, make$conversions_Value_u8(data, 10)); + rt.cellSet(cell, make$conversions_Value_u8(data, 11)); + put$conversions_Value_u8(old, out); + put$conversions_Value_u8(c, out); + const at5 = rt.idx(v, 0); + const _91: rt.u8 = make$conversions_Value_u8(data, 12); + put$conversions_Value_u8(setThrough$u8(rt.place(() => v.data[at5], (value4) => v.data[at5] = value4), _91), out); + put$conversions_Value_u8(v.data[rt.idx(v, 0)], out); + const borrowed = held; + rt.cellSet(rt.cellOfPlace(rt.place(() => borrowed.value, (value5) => borrowed.value = value5)), make$conversions_Value_u8(data, 17)); + put$conversions_Value_u8(held.value, out); + const array: Uint8Array = Uint8Array.of(make$conversions_Value_u8(data, 13), make$conversions_Value_u8(data, 14), make$conversions_Value_u8(data, 15)); + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([rt.byteSliceFrom(array).length, rt.byteSliceFrom(array).length], (n: rt.usize): rt.u8 => { + return n & 0xff; + })), undefined, true); + const _114: rt.u8 = b; + const _116: rt.ByteSlice = rt.byteSliceFrom(array); + rt.idx(_116, 0); + _116.data[_116.start] = _114; + const _124: rt.ByteSlice = rt.byteSliceFrom(array); + rt.idx(_124, 2); + _124.data[_124.start + 2] = c; + for (const _134 of rt.byteSliceView(rt.byteSliceFrom(array))) { + put$conversions_Value_u8(_134, out); + } + put$conversions_Value_u8({ v: b }.v, out); + c = make$conversions_Value_u8(data, 16); + put$conversions_Value_u8(c, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [rt.u16 | undefined, rt.u16 | undefined, rt.u16 | undefined] = [make$conversions_Value_Option_u16(data, 0), make$conversions_Value_Option_u16(data, 3), make$conversions_Value_Option_u16(data, 6)]; + let a: rt.u16 | undefined = _6[0]; + const b: rt.u16 | undefined = _6[1]; + let c: rt.u16 | undefined = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_Option_u16(data, 1)); + const v: Array = [make$conversions_Value_Option_u16(data, 2), make$conversions_Value_Option_u16(data, 4)]; + const s: Array = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: rt.u16 | undefined = make$conversions_Value_Option_u16(data, 5); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_Option_u16(old4, out); + put$conversions_Value_Option_u16(a, out); + const borrowed = held; + put$conversions_Value_Option_u16(writeFirst$Option_u16(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_Option_u16(data, 7)), out); + put$conversions_Value_Option_u16(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_Option_u16(writeFirst$Option_u16(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_Option_u16(data, 8)), out); + put$conversions_Value_Option_u16(v[rt.idx(v, 1)], out); + rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)).fill(b); + const iter: rt.Iter> = rt.iterSliceMut(rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))); + while (true) { + const _61: rt.Place | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.v = make$conversions_Value_Option_u16(data, 9); + } + put$conversions_Value_Option_u16(c, out); + put$conversions_Value_Option_u16(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$String(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [string, string, string] = [make$conversions_Value_String(data, 0), make$conversions_Value_String(data, 3), make$conversions_Value_String(data, 6)]; + let a: string = _6[0]; + const b: string = _6[1]; + let c: string = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_String(data, 1)); + const v: string[] = [make$conversions_Value_String(data, 2), make$conversions_Value_String(data, 4)]; + const s: string[] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: string = make$conversions_Value_String(data, 5); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_String(old4, out); + put$conversions_Value_String(a, out); + const borrowed = held; + put$conversions_Value_String(writeFirst$String(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_String(data, 7)), out); + put$conversions_Value_String(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_String(writeFirst$String(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_String(data, 8)), out); + put$conversions_Value_String(v[rt.idx(v, 1)], out); + rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)).fill(b); + const iter: rt.Iter> = rt.iterSliceMut(rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))); + while (true) { + const _61: rt.Place | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.v = make$conversions_Value_String(data, 9); + } + put$conversions_Value_String(c, out); + put$conversions_Value_String(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$Vec_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [rt.u32[], rt.u32[], rt.u32[]] = [make$conversions_Value_Vec_u32(data, 0), make$conversions_Value_Vec_u32(data, 3), make$conversions_Value_Vec_u32(data, 6)]; + let a: rt.u32[] = _6[0]; + const b: rt.u32[] = _6[1]; + let c: rt.u32[] = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_Vec_u32(data, 1)); + const v: rt.u32[][] = [make$conversions_Value_Vec_u32(data, 2), make$conversions_Value_Vec_u32(data, 4)]; + const s: rt.u32[][] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: rt.u32[] = make$conversions_Value_Vec_u32(data, 5); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_Vec_u32(old4, out); + put$conversions_Value_Vec_u32(a, out); + const borrowed = held; + put$conversions_Value_Vec_u32(writeFirst$Vec_u32(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_Vec_u32(data, 7)), out); + put$conversions_Value_Vec_u32(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_Vec_u32(writeFirst$Vec_u32(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_Vec_u32(data, 8)), out); + put$conversions_Value_Vec_u32(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), rt.vecExact(b.slice(), 4), (a0: rt.u32[]): rt.u32[] => { + return rt.vecExact(a0.slice(), 4); + }); + for (const _61 of rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))) { + rt.vecAssign(_61, make$conversions_Value_Vec_u32(data, 9)); + } + put$conversions_Value_Vec_u32(c, out); + put$conversions_Value_Vec_u32(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$Vec_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [rt.ByteVec, rt.ByteVec, rt.ByteVec] = [make$conversions_Value_Vec_u8(data, 0), make$conversions_Value_Vec_u8(data, 3), make$conversions_Value_Vec_u8(data, 6)]; + let a: rt.ByteVec = _6[0]; + const b: rt.ByteVec = _6[1]; + let c: rt.ByteVec = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_Vec_u8(data, 1)); + const v: rt.ByteVec[] = [make$conversions_Value_Vec_u8(data, 2), make$conversions_Value_Vec_u8(data, 4)]; + const s: rt.ByteVec[] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: rt.ByteVec = make$conversions_Value_Vec_u8(data, 5); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_Vec_u8(old4, out); + put$conversions_Value_Vec_u8(a, out); + const borrowed = held; + put$conversions_Value_Vec_u8(writeFirst$Vec_u8(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_Vec_u8(data, 7)), out); + put$conversions_Value_Vec_u8(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_Vec_u8(writeFirst$Vec_u8(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_Vec_u8(data, 8)), out); + put$conversions_Value_Vec_u8(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), rt.byteVecFrom(rt.byteVecView(b)), (a0: rt.ByteVec): rt.ByteVec => { + return rt.byteVecFrom(rt.byteVecView(a0)); + }); + for (const _61 of rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))) { + Object.assign(_61, make$conversions_Value_Vec_u8(data, 9)); + } + put$conversions_Value_Vec_u8(c, out); + put$conversions_Value_Vec_u8(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [Uint8Array, Uint8Array, Uint8Array] = [copy$array_u8(make$conversions_Value_array0_u8(data, 0)), copy$array_u8(make$conversions_Value_array0_u8(data, 3)), copy$array_u8(make$conversions_Value_array0_u8(data, 6))]; + const a: Uint8Array = _6[0]; + const b: Uint8Array = _6[1]; + const c: Uint8Array = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(copy$array_u8(make$conversions_Value_array0_u8(data, 1))); + 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 s: Uint8Array[] = rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a)))); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + rt.byteSliceFrom(s[0]); + put$conversions_Value_array0_u8(rt.byteSliceFrom(copy$array_u8(make$conversions_Value_array0_u8(data, 5))), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(a), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(writeFirst$array0_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(held.value)))), make$conversions_Value_array0_u8(data, 7))), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(writeFirst$array0_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(v[rt.idx(v, 1)])))), make$conversions_Value_array0_u8(data, 8))), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + rt.sliceFill(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(c)))), copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))), copy$array_u8); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a))))), rt.byteSliceFrom); + while (true) { + const _61: rt.ByteSlice | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.data.set(copy$array_u8(make$conversions_Value_array0_u8(data, 9)), _61.start); + } + put$conversions_Value_array0_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array0_u8(rt.byteSliceFrom(a), out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [Uint8Array, Uint8Array, Uint8Array] = [copy$array_u8(make$conversions_Value_array1_u8(data, 0)), copy$array_u8(make$conversions_Value_array1_u8(data, 3)), copy$array_u8(make$conversions_Value_array1_u8(data, 6))]; + const a: Uint8Array = _6[0]; + const b: Uint8Array = _6[1]; + const c: Uint8Array = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(copy$array_u8(make$conversions_Value_array1_u8(data, 1))); + 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 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 old4 = rt.byteSliceToArray(_23); + _23.data.set(_28, _23.start); + put$conversions_Value_array1_u8(rt.byteSliceFrom(old4), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(a), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(writeFirst$array1_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(held.value)))), make$conversions_Value_array1_u8(data, 7))), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(writeFirst$array1_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(v[rt.idx(v, 1)])))), make$conversions_Value_array1_u8(data, 8))), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + rt.sliceFill(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(c)))), copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))), copy$array_u8); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a))))), rt.byteSliceFrom); + while (true) { + const _61: rt.ByteSlice | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.data.set(copy$array_u8(make$conversions_Value_array1_u8(data, 9)), _61.start); + } + put$conversions_Value_array1_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array1_u8(rt.byteSliceFrom(a), out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$array2_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [rt.u32[], rt.u32[], rt.u32[]] = [copy$array_u32(make$conversions_Value_array2_u32(data, 0)), copy$array_u32(make$conversions_Value_array2_u32(data, 3)), copy$array_u32(make$conversions_Value_array2_u32(data, 6))]; + let a: rt.u32[] = _6[0]; + const b: rt.u32[] = _6[1]; + let c: rt.u32[] = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(copy$array_u32(make$conversions_Value_array2_u32(data, 1))); + const v: rt.u32[][] = copy$array_array2_u32([make$conversions_Value_array2_u32(data, 2), make$conversions_Value_array2_u32(data, 4)]).map(copy$array_u32); + const s: rt.u32[][] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: rt.u32[] = copy$array_u32(make$conversions_Value_array2_u32(data, 5)); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_array2_u32(old4, out); + put$conversions_Value_array2_u32(a, out); + const borrowed = held; + put$conversions_Value_array2_u32(writeFirst$array2_u32(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_array2_u32(data, 7)), out); + put$conversions_Value_array2_u32(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_array2_u32(writeFirst$array2_u32(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_array2_u32(data, 8)), out); + put$conversions_Value_array2_u32(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), copy$array_u32(copy$array_u32(b)), copy$array_u32); + for (const _61 of rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))) { + Object.assign(_61, copy$array_u32(make$conversions_Value_array2_u32(data, 9))); + } + put$conversions_Value_array2_u32(c, out); + put$conversions_Value_array2_u32(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [Uint8Array, Uint8Array, Uint8Array] = [copy$array_u8(make$conversions_Value_array3_u8(data, 0)), copy$array_u8(make$conversions_Value_array3_u8(data, 3)), copy$array_u8(make$conversions_Value_array3_u8(data, 6))]; + const a: Uint8Array = _6[0]; + const b: Uint8Array = _6[1]; + const c: Uint8Array = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(copy$array_u8(make$conversions_Value_array3_u8(data, 1))); + 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 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 old4 = rt.byteSliceToArray(_23); + _23.data.set(_28, _23.start); + put$conversions_Value_array3_u8(rt.byteSliceFrom(old4), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(a), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(writeFirst$array3_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(held.value)))), make$conversions_Value_array3_u8(data, 7))), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(writeFirst$array3_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(v[rt.idx(v, 1)])))), make$conversions_Value_array3_u8(data, 8))), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + rt.sliceFill(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(c)))), copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))), copy$array_u8); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a))))), rt.byteSliceFrom); + while (true) { + const _61: rt.ByteSlice | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.data.set(copy$array_u8(make$conversions_Value_array3_u8(data, 9)), _61.start); + } + put$conversions_Value_array3_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array3_u8(rt.byteSliceFrom(a), out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [Uint8Array, Uint8Array, Uint8Array] = [copy$array_u8(make$conversions_Value_array40_u8(data, 0)), copy$array_u8(make$conversions_Value_array40_u8(data, 3)), copy$array_u8(make$conversions_Value_array40_u8(data, 6))]; + const a: Uint8Array = _6[0]; + const b: Uint8Array = _6[1]; + const c: Uint8Array = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(copy$array_u8(make$conversions_Value_array40_u8(data, 1))); + 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 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 old4 = rt.byteSliceToArray(_23); + _23.data.set(_28, _23.start); + put$conversions_Value_array40_u8(rt.byteSliceFrom(old4), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(a), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(writeFirst$array40_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(held.value)))), make$conversions_Value_array40_u8(data, 7))), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(held.value), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(writeFirst$array40_u8(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(v[rt.idx(v, 1)])))), make$conversions_Value_array40_u8(data, 8))), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(v[rt.idx(v, 1)]), out); + rt.sliceFill(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(c)))), copy$array_u8(rt.byteSliceToArray(rt.byteSliceFrom(b))), copy$array_u8); + const iter: rt.Iter = rt.iterLend(rt.iterSlice(rt.sliceOfPlace(rt.bytesPlace(rt.byteSliceView(rt.byteSliceFrom(a))))), rt.byteSliceFrom); + while (true) { + const _61: rt.ByteSlice | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.data.set(copy$array_u8(make$conversions_Value_array40_u8(data, 9)), _61.start); + } + put$conversions_Value_array40_u8(rt.byteSliceFrom(c), out); + put$conversions_Value_array40_u8(rt.byteSliceFrom(a), out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$conversions_Logged(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [conversions_Logged.Logged, conversions_Logged.Logged, conversions_Logged.Logged] = [conversions_Logged.make$conversions_Value(data, 0), conversions_Logged.make$conversions_Value(data, 3), conversions_Logged.make$conversions_Value(data, 6)]; + let a: conversions_Logged.Logged = _6[0]; + const b: conversions_Logged.Logged = _6[1]; + let c: conversions_Logged.Logged = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(conversions_Logged.make$conversions_Value(data, 1)); + const v: conversions_Logged.Logged[] = [conversions_Logged.make$conversions_Value(data, 2), conversions_Logged.make$conversions_Value(data, 4)]; + const s: conversions_Logged.Logged[] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 5); + const old4 = s[0]; + s[0] = _28; + const old: conversions_Logged.Logged = old4; + conversions_Logged.put$conversions_Value(old, out); + conversions_Logged.put$conversions_Value(a, out); + const borrowed = held; + const old2: conversions_Logged.Logged = writeFirst$conversions_Logged(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), conversions_Logged.make$conversions_Value(data, 7)); + conversions_Logged.put$conversions_Value(old2, out); + conversions_Logged.put$conversions_Value(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + const old3: conversions_Logged.Logged = writeFirst$conversions_Logged(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), conversions_Logged.make$conversions_Value(data, 8)); + conversions_Logged.put$conversions_Value(old3, out); + conversions_Logged.put$conversions_Value(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), conversions_Logged.clone$Clone(b), conversions_Logged.clone$Clone, rt.drop); + for (const _61 of rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))) { + const _65: conversions_Logged.Logged = conversions_Logged.make$conversions_Value(data, 9); + _61[Symbol.dispose](); + Object.assign(_61, _65); + } + conversions_Logged.put$conversions_Value(c, out); + conversions_Logged.put$conversions_Value(a, out); + old3[Symbol.dispose](); + old2[Symbol.dispose](); + old[Symbol.dispose](); + rt.dropAll(v); + held[Symbol.dispose](); + c[Symbol.dispose](); + b[Symbol.dispose](); + a[Symbol.dispose](); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$conversions_Named(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [conversions_Named.Named, conversions_Named.Named, conversions_Named.Named] = [conversions_Named.make$conversions_Value(data, 0), conversions_Named.make$conversions_Value(data, 3), conversions_Named.make$conversions_Value(data, 6)]; + let a: conversions_Named.Named = _6[0]; + const b: conversions_Named.Named = _6[1]; + let c: conversions_Named.Named = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(conversions_Named.make$conversions_Value(data, 1)); + const v: conversions_Named.Named[] = [conversions_Named.make$conversions_Value(data, 2), conversions_Named.make$conversions_Value(data, 4)]; + const s: conversions_Named.Named[] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: conversions_Named.Named = conversions_Named.make$conversions_Value(data, 5); + const old4 = s[0]; + s[0] = _28; + conversions_Named.put$conversions_Value(old4, out); + conversions_Named.put$conversions_Value(a, out); + const borrowed = held; + conversions_Named.put$conversions_Value(writeFirst$conversions_Named(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), conversions_Named.make$conversions_Value(data, 7)), out); + conversions_Named.put$conversions_Value(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + conversions_Named.put$conversions_Value(writeFirst$conversions_Named(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), conversions_Named.make$conversions_Value(data, 8)), out); + conversions_Named.put$conversions_Value(v[rt.idx(v, 1)], out); + rt.sliceFill(rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)), conversions_Named.clone$Clone(b), conversions_Named.clone$Clone); + for (const _61 of rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))) { + Object.assign(_61, conversions_Named.make$conversions_Value(data, 9)); + } + conversions_Named.put$conversions_Value(c, out); + conversions_Named.put$conversions_Value(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$u32(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [rt.u32, rt.u32, rt.u32] = [make$conversions_Value_u32(data, 0), make$conversions_Value_u32(data, 3), make$conversions_Value_u32(data, 6)]; + let a: rt.u32 = _6[0]; + const b: rt.u32 = _6[1]; + let c: rt.u32 = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_u32(data, 1)); + const v: rt.u32[] = [make$conversions_Value_u32(data, 2), make$conversions_Value_u32(data, 4)]; + const s: rt.u32[] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: rt.u32 = make$conversions_Value_u32(data, 5); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_u32(old4, out); + put$conversions_Value_u32(a, out); + const borrowed = held; + put$conversions_Value_u32(writeFirst$u32(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_u32(data, 7)), out); + put$conversions_Value_u32(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_u32(writeFirst$u32(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_u32(data, 8)), out); + put$conversions_Value_u32(v[rt.idx(v, 1)], out); + rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)).fill(b); + const iter: rt.Iter> = rt.iterSliceMut(rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))); + while (true) { + const _61: rt.Place | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.v = make$conversions_Value_u32(data, 9); + } + put$conversions_Value_u32(c, out); + put$conversions_Value_u32(a, out); +} + +/** + * Slices and arrays of one value of a local, a field, and an element, written through as + * a whole, the old value read out, and through std's slice methods. + */ +export function lentOne$u64(data: rt.ByteSlice, out: rt.ByteVec): void { + const _6: [rt.u64, rt.u64, rt.u64] = [make$conversions_Value_u64(data, 0), make$conversions_Value_u64(data, 3), make$conversions_Value_u64(data, 6)]; + let a: rt.u64 = _6[0]; + const b: rt.u64 = _6[1]; + let c: rt.u64 = _6[2]; + const held: conversions_Held.Held = new conversions_Held.Held(make$conversions_Value_u64(data, 1)); + const v: rt.u64[] = [make$conversions_Value_u64(data, 2), make$conversions_Value_u64(data, 4)]; + const s: rt.u64[] = rt.sliceOfPlace(rt.place(() => a, (value) => a = value)); + rt.byteVecPush(out, s.length & 0xff); + rt.idx(s, 0); + const _28: rt.u64 = make$conversions_Value_u64(data, 5); + const old4 = s[0]; + s[0] = _28; + put$conversions_Value_u64(old4, out); + put$conversions_Value_u64(a, out); + const borrowed = held; + put$conversions_Value_u64(writeFirst$u64(rt.sliceOfPlace(rt.place(() => borrowed.value, (value2) => borrowed.value = value2)), make$conversions_Value_u64(data, 7)), out); + put$conversions_Value_u64(held.value, out); + const at = rt.idx(v, 1); + const borrowed2 = v; + const borrowed3 = at; + put$conversions_Value_u64(writeFirst$u64(rt.sliceOfPlace(rt.place(() => borrowed2[borrowed3], (value3) => borrowed2[borrowed3] = value3)), make$conversions_Value_u64(data, 8)), out); + put$conversions_Value_u64(v[rt.idx(v, 1)], out); + rt.sliceOfPlace(rt.place(() => c, (value4) => c = value4)).fill(b); + const iter: rt.Iter> = rt.iterSliceMut(rt.sliceOfPlace(rt.place(() => a, (value5) => a = value5))); + while (true) { + const _61: rt.Place | rt.Done = iter.next(); + if (_61 === rt.DONE) { + break; + } + _61.v = make$conversions_Value_u64(data, 9); + } + put$conversions_Value_u64(c, out); + put$conversions_Value_u64(a, out); +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$Option_u16(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: Array = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.u16 | undefined => { + return make$conversions_Value_Option_u16(data, i2); + }), undefined, 4, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpOption(rt.cmp))); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: Array = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_Option_u16(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmpOption(rt.cmp)); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$String(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: string[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): string => { + return make$conversions_Value_String(data, i2); + }), undefined, 12, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpStr)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: string[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_String(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmpStr); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$Vec_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: rt.u32[][] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.u32[] => { + return make$conversions_Value_Vec_u32(data, i2); + }), undefined, 12, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpSlice(rt.cmp))); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: rt.u32[][] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_Vec_u32(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmpSlice(rt.cmp)); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$Vec_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: rt.ByteVec[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.ByteVec => { + return make$conversions_Value_Vec_u8(data, i2); + }), undefined, 12, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpBytes)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: rt.ByteVec[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_Vec_u8(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmpBytes); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$array0_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: Uint8Array[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): Uint8Array => { + return make$conversions_Value_array0_u8(data, i2); + }), undefined, 0, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpBytes)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: Uint8Array[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, rt.byteSliceView(rt.byteSliceFrom(make$conversions_Value_array0_u8(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)))), rt.cmpBytes); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$array1_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: Uint8Array[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): Uint8Array => { + return make$conversions_Value_array1_u8(data, i2); + }), undefined, 1, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpBytes)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: Uint8Array[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, rt.byteSliceView(rt.byteSliceFrom(make$conversions_Value_array1_u8(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)))), rt.cmpBytes); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$array2_u32(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: rt.u32[][] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.u32[] => { + return make$conversions_Value_array2_u32(data, i2); + }), undefined, 8, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpSlice(rt.cmp))); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: rt.u32[][] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_array2_u32(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmpSlice(rt.cmp)); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$array3_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: Uint8Array[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): Uint8Array => { + return make$conversions_Value_array3_u8(data, i2); + }), undefined, 3, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpBytes)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: Uint8Array[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, rt.byteSliceView(rt.byteSliceFrom(make$conversions_Value_array3_u8(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)))), rt.cmpBytes); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$array40_u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: Uint8Array[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): Uint8Array => { + return make$conversions_Value_array40_u8(data, i2); + }), undefined, 40, true); + rt.sliceSort(v, rt.cmpLt(rt.cmpBytes)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: Uint8Array[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, rt.byteSliceView(rt.byteSliceFrom(make$conversions_Value_array40_u8(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)))), rt.cmpBytes); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$conversions_Named(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: conversions_Named.Named[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): conversions_Named.Named => { + return conversions_Named.make$conversions_Value(data, i2); + }), undefined, 16, true); + rt.sliceSort(v, rt.cmpLt(conversions_Named.partialCmp$cmp_PartialOrd)); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: conversions_Named.Named[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, conversions_Named.make$conversions_Value(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), conversions_Named.cmp$cmp_Ord); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$u32(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: rt.u32[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.u32 => { + return make$conversions_Value_u32(data, i2); + }), undefined, 4, true); + rt.sliceSort(v, rt.lt); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: rt.u32[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_u32(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmp); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$u64(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: rt.u64[] = rt.iterToArray(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.u64 => { + return make$conversions_Value_u64(data, i2); + }), undefined, 8, true); + rt.sliceSort(v, rt.lt); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const s: rt.u64[] = rt.sliceRange(v, 0, rt.min(_17, v.length)); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const found: rt.Result = rt.sliceBinarySearch(s, make$conversions_Value_u64(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)), rt.cmp); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** + * `binary_search` of each value `data` makes in a sorted run of them, where equal ones + * repeat: `Ok` or `Err` as a byte, then the index. + */ +export function searched$u8(data: rt.ByteSlice, out: rt.ByteVec): void { + let _34!: rt.usize; + let _47!: [rt.u8, rt.usize]; + const v: rt.ByteVec = rt.iterToByteVec(rt.iterMap(new rt.Range(0, rt.min(data.length, 24)), (i2: rt.usize): rt.u8 => { + return make$conversions_Value_u8(data, i2); + }), undefined, true); + rt.byteSliceView(rt.byteVecSlice(v)).sort(); + const iter: rt.Iter = rt.iterSlice([0, 1, 2, 3, v.length]); + l1: while (true) { + const _17: rt.usize | rt.Done = iter.next(); + if (_17 === rt.DONE) { + break; + } + const part = rt.min(_17, v.length); + const s: rt.ByteSlice = rt.byteSliceRange(rt.byteVecSlice(v), 0, part); + const _29: rt.usize = rt.usizeAdd(rt.min(data.length, 8), 1); + let iterStart: rt.usize = 0; + const iterEnd: rt.usize = _29; + while (true) { + if (!((_34 = iterStart++) < iterEnd)) { + continue l1; + } + const _40: rt.u8 = make$conversions_Value_u8(data, rt.usizeAdd(rt.usizeMul(_34, 2), 1)); + const found: rt.Result = rt.sliceBinarySearch(rt.byteSliceView(s), _40, rt.cmp); + if (found.ok) { + _47 = [1, found.value] as [rt.u8, rt.usize]; + } else { + _47 = [0, found.error] as [rt.u8, rt.usize]; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_47[0], _47[1] & 0xff)), undefined, true); + } + } +} + +/** What wasm32 lays out each value in, and a slice or a `str` of what `data` holds. */ +export function measured(data: rt.ByteSlice, out: rt.ByteVec): void { + const n: rt.usize = data.length; + const wide: rt.u64[] = rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_2: rt.u8): rt.u64 => { + return _2 as rt.u64; + }), undefined, 8, true); + const text: string = rt.stringExtendChars("", rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): rt.char => { + return _25 as rt.char; + })); + conversions_Named.make$conversions_Value(data, 0); + const _13: rt.usize = rt.byteSliceRange(data, 0, 0).length; + rt.byteSliceRange(data, 0, 0); + const _12: [rt.usize, rt.usize] = [_13, 1]; + const _19: [rt.usize, rt.usize] = [data.length, 1]; + const _23: rt.usize = rt.sliceRange(wide, 0).length * 8; + rt.sliceRange(wide, 0); + const _22: [rt.usize, rt.usize] = [_23, 8]; + const _29: [rt.usize, rt.usize] = [rt.stringLen(text), 1]; + const _36: [rt.usize, rt.usize] = [4, 4]; + const _41: [rt.usize, rt.usize] = [16, 16]; + [n & 0xff, n & 0xffff] as [rt.u8, rt.u16]; + const _49: rt.usize = 4; + [n & 0xff, n & 0xffff] as [rt.u8, rt.u16]; + const _48: [rt.usize, rt.usize] = [_49, 2]; + const _59: [rt.usize, rt.usize] = [8, 4]; + const _72: rt.u16 = n & 0xffff; + Array.from({ length: 3 }, (): rt.u16 => { + return _72; + }); + const _69: rt.usize = 6; + const _76: rt.u16 = n & 0xffff; + const iter: rt.Iter<[rt.usize, rt.usize]> = rt.iterSlice(copy$array_tuple2_usize_usize([_12, _19, _22, _29, _36, _41, _48, _59, [_69, 2] as [rt.usize, rt.usize], [16, 4] as [rt.usize, rt.usize], [12, 4] as [rt.usize, rt.usize], [0, 1] as [rt.usize, rt.usize]])); + while (true) { + const _94: [rt.usize, rt.usize] | rt.Done = iter.next(); + Array.from({ length: 3 }, (): rt.u16 => { + return _76; + }); + if (_94 === rt.DONE) { + break; + } + rt.iterExtendBytes(out, rt.iterSlice(Uint8Array.of(_94[0] & 0xff, _94[1] & 0xff)), undefined, true); + } +} + +/** + * Raw pointers of references to the bytes of arrays and to objects, compared by where + * they point, and an array of an `u8`. + */ +export function pointed(data: rt.ByteSlice, out: rt.ByteVec): void { + const _5: [Uint8Array, Uint8Array] = [make$conversions_Value_array2_u8(data, 0), make$conversions_Value_array2_u8(data, 2)]; + const a: Uint8Array = copy$array_u8(_5[0]); + const b: Uint8Array = _5[1]; + const _10: [conversions_Named.Named, conversions_Named.Named] = [conversions_Named.make$conversions_Value(data, 0), conversions_Named.make$conversions_Value(data, 3)]; + const x: conversions_Named.Named = _10[0]; + const y: conversions_Named.Named = _10[1]; + rt.iterExtendBytes(out, rt.iterSlice(rt.bytesMap([rt.byteSliceSame(rt.byteSliceFrom(rt.byteSliceView(rt.byteSliceFrom(a))), rt.byteSliceFrom(a)), rt.byteSliceSame(rt.byteSliceFrom(rt.byteSliceView(rt.byteSliceFrom(a))), rt.byteSliceFrom(b)), x === x, x === y], (a0: boolean): rt.u8 => { + return a0 ? 1 : 0; + })), undefined, true); + const p: rt.ByteSlice = rt.byteSliceFrom(a); + p.data[p.start] = p.data[p.start] ^ 16; + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(a)); + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(a[1]))); +} + +//# sourceMappingURL=conversions.ts.map diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts index b208d2561..8c9c5641c 100644 --- a/ts/fixtures/lang/expected/harness.ts +++ b/ts/fixtures/lang/expected/harness.ts @@ -16,6 +16,7 @@ import { chunks } from "./chunks.ts"; import { iters as clones_iters } from "./clones.ts"; import { hashMaps, sets, btreeMaps, deques as collections_deques, vecs as collections_vecs, stores, optionals, setOps, unlikeEqs, ownNes, cellEqs, unlikeCompares, refOrders } from "./collections.ts"; import { combinators } from "./combinators.ts"; +import { conversions } from "./conversions.ts"; import { arcs as counts_arcs, clonedArcs, cyclicArcs, uniqueArcs, clonedRcs, cyclicRcs, rcs, uniqueRcs, copies as counts_copies } from "./counts.ts"; import { cows, slices as cows_slices, bytes as cows_bytes } from "./cows.ts"; import { cycles } from "./cycles.ts"; @@ -261,18 +262,18 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) borrows_maps(data91, out92); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mapped", (_2192: rt.u8, data92: rt.ByteSlice, out93: rt.ByteVec): undefined => { mapped(data92, out93); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::tries", (_2193: rt.u8, data93: rt.ByteSlice, out94: rt.ByteVec): undefined => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["conversions::conversions", conversions as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::tries", (_2193: rt.u8, data93: rt.ByteSlice, out94: rt.ByteVec): undefined => { tries(data93, out94); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::mutex_mapped", (_2194: rt.u8, data94: rt.ByteSlice, out95: rt.ByteVec): undefined => { mutexMapped(data94, out95); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::printed", (_2195: rt.u8, data95: rt.ByteSlice, out96: rt.ByteVec): undefined => { locks_printed(data95, out96); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::vecs", (a0152: rt.u8, a1152: rt.ByteSlice, a2152: rt.ByteVec): undefined => { - capacity_vecs(a0152, a1152.data, a1152.start, a1152.length, a2152); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::deques", (a0153: rt.u8, a1153: rt.ByteSlice, a2153: rt.ByteVec): undefined => { - capacity_deques(a0153, a1153.data, a1153.start, a1153.length, a2153); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::heaps", (a0154: rt.u8, a1154: rt.ByteSlice, a2154: rt.ByteVec): undefined => { - capacity_heaps(a0154, a1154.data, a1154.start, a1154.length, a2154); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::vecs", (a0153: rt.u8, a1153: rt.ByteSlice, a2153: rt.ByteVec): undefined => { + capacity_vecs(a0153, a1153.data, a1153.start, a1153.length, a2153); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::deques", (a0154: rt.u8, a1154: rt.ByteSlice, a2154: rt.ByteVec): undefined => { + capacity_deques(a0154, a1154.data, a1154.start, a1154.length, a2154); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::heaps", (a0155: rt.u8, a1155: rt.ByteSlice, a2155: rt.ByteVec): undefined => { + capacity_heaps(a0155, a1155.data, a1155.start, a1155.length, a2155); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::collects", collects as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["capacity::maps", capacity_maps as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["locks::downgraded", (_2196: rt.u8, data96: rt.ByteSlice, out97: rt.ByteVec): undefined => { downgraded(data96, out97); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["borrows::leaks", (_2197: rt.u8, data97: rt.ByteSlice, out98: rt.ByteVec): undefined => { diff --git a/ts/fixtures/lang/expected/lib.ts b/ts/fixtures/lang/expected/lib.ts index 988119ea2..2da6701b8 100644 --- a/ts/fixtures/lang/expected/lib.ts +++ b/ts/fixtures/lang/expected/lib.ts @@ -231,6 +231,10 @@ export function copy$array_array1_u8(v: Uint8Array[]): Uint8Array[] { return v.map(copy$array_u8); } +export function copy$array_array2_u32(v: rt.u32[][]): rt.u32[][] { + return v.map(copy$array_u32); +} + export function copy$array_array2_u8(v: Uint8Array[]): Uint8Array[] { return v.map(copy$array_u8); } @@ -239,6 +243,10 @@ export function copy$array_array3_u8(v: Uint8Array[]): Uint8Array[] { return v.map(copy$array_u8); } +export function copy$array_array40_u8(v: Uint8Array[]): Uint8Array[] { + return v.map(copy$array_u8); +} + export function copy$array_array5_u8(v: Uint8Array[]): Uint8Array[] { return v.map(copy$array_u8); } @@ -279,6 +287,10 @@ export function copy$array_tuple2_u8_u8(v: [rt.u8, rt.u8][]): [rt.u8, rt.u8][] { return v.map(copy$tuple2_u8_u8); } +export function copy$array_tuple2_usize_usize(v: [rt.usize, rt.usize][]): [rt.usize, rt.usize][] { + return v.map(copy$tuple2_usize_usize); +} + export function copy$array_u16(v: rt.u16[]): rt.u16[] { return v.slice(); } @@ -764,6 +776,10 @@ export function copy$tuple2_u8_u8(v: [rt.u8, rt.u8]): [rt.u8, rt.u8] { return [v[0], v[1]]; } +export function copy$tuple2_usize_usize(v: [rt.usize, rt.usize]): [rt.usize, rt.usize] { + return [v[0], v[1]]; +} + export function copy$tuples_Spot(v: Spot.Spot): Spot.Spot { return { x: v.x, y: v.y }; } diff --git a/ts/fixtures/lang/src/conversions.rs b/ts/fixtures/lang/src/conversions.rs new file mode 100644 index 000000000..44794749f --- /dev/null +++ b/ts/fixtures/lang/src/conversions.rs @@ -0,0 +1,444 @@ +//! std's functions that take a reference and convert, copy, or measure what it points at: +//! `to_owned`, `clone_into`, and `clone_from` into a local, a field, an element, and a +//! parameter; `binary_search` over runs of equal elements; `size_of_val` and +//! `align_of_val`; slices, arrays, and cells of one value, written through; arrays as +//! slices by `AsRef`, `AsMut`, `Borrow`, and `BorrowMut`; and raw pointers of references. +//! Each is generic over the value, run for numbers JS copies, strings, `Option`s, arrays +//! and `Vec`s of bytes and of numbers, a struct, and one that logs its clones and drops. + +use std::borrow::{Borrow, BorrowMut}; +use std::cell::{Cell, RefCell}; +use std::rc::Rc; + +/// A value made from the case's bytes, put back as bytes. +trait Value: Clone { + /// The value `data` makes from `at`. + fn make(data: &[u8], at: usize) -> Self; + + /// Its bytes. + fn put(&self, out: &mut Vec); +} + +/// The byte at `at`, past `data`'s end its index. +fn byte(data: &[u8], at: usize) -> u8 { + data.get(at).copied().unwrap_or(at as u8) +} + +impl Value for u8 { + fn make(data: &[u8], at: usize) -> Self { + byte(data, at) + } + + fn put(&self, out: &mut Vec) { + out.push(*self); + } +} + +impl Value for u32 { + fn make(data: &[u8], at: usize) -> Self { + u32::from(byte(data, at)) * 0x0101_0101 + } + + fn put(&self, out: &mut Vec) { + out.extend(self.to_be_bytes()); + } +} + +/// Past 2^53, where the runtime holds it as limbs. +impl Value for u64 { + fn make(data: &[u8], at: usize) -> Self { + u64::from(byte(data, at)) << 56 | u64::from(byte(data, at + 1)) + } + + fn put(&self, out: &mut Vec) { + out.extend(self.to_be_bytes()); + } +} + +impl Value for String { + fn make(data: &[u8], at: usize) -> Self { + format!("s{}", byte(data, at) % 16) + } + + fn put(&self, out: &mut Vec) { + out.extend(self.as_bytes()); + out.push(0xff); + } +} + +impl Value for Option { + fn make(data: &[u8], at: usize) -> Self { + let b = byte(data, at); + (b % 4 != 0).then_some(u16::from(b) << 4) + } + + fn put(&self, out: &mut Vec) { + match self { + Some(x) => out.extend(x.to_be_bytes()), + None => out.push(0xff), + } + } +} + +impl Value for [u8; N] { + fn make(data: &[u8], at: usize) -> Self { + std::array::from_fn(|i| byte(data, at + i) % 4) + } + + fn put(&self, out: &mut Vec) { + out.extend_from_slice(self); + } +} + +impl Value for [u32; 2] { + fn make(data: &[u8], at: usize) -> Self { + [u32::from(byte(data, at) % 4), u32::from(byte(data, at + 1)) << 20] + } + + fn put(&self, out: &mut Vec) { + for x in self { + out.extend(x.to_be_bytes()); + } + } +} + +/// Of up to three elements, so a write shrinks, clears, and grows it. +impl Value for Vec { + fn make(data: &[u8], at: usize) -> Self { + (0..usize::from(byte(data, at) % 4)) + .map(|i| u32::from(byte(data, at + i + 1))) + .collect() + } + + fn put(&self, out: &mut Vec) { + out.push(self.len() as u8); + for x in self { + out.extend(x.to_be_bytes()); + } + } +} + +/// Of up to three bytes, as [`Vec`]'s. +impl Value for Vec { + fn make(data: &[u8], at: usize) -> Self { + (0..usize::from(byte(data, at) % 4)) + .map(|i| byte(data, at + i + 1)) + .collect() + } + + fn put(&self, out: &mut Vec) { + out.push(self.len() as u8); + out.extend_from_slice(self); + } +} + +/// A struct, which JS holds as an object. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] +struct Named { + id: u16, + name: String, +} + +impl Value for Named { + fn make(data: &[u8], at: usize) -> Self { + Named { + id: u16::from(byte(data, at) % 4), + name: String::make(data, at + 1), + } + } + + fn put(&self, out: &mut Vec) { + out.extend(self.id.to_be_bytes()); + self.name.put(out); + } +} + +/// What [`Logged`]s log to. +type Log = Rc>>; + +thread_local! { + static LOG: Log = Rc::new(RefCell::new(Vec::new())); +} + +/// Logs its id as it drops, and as it is cloned, the id with the high bit set: its clone's +/// id is one more. +struct Logged { + id: u8, + log: Log, +} + +impl Clone for Logged { + fn clone(&self) -> Self { + RefCell::borrow_mut(&self.log).push(0x80 | self.id); + Self { + id: self.id.wrapping_add(1), + log: self.log.clone(), + } + } +} + +impl Drop for Logged { + fn drop(&mut self) { + RefCell::borrow_mut(&self.log).push(self.id); + } +} + +impl Value for Logged { + fn make(data: &[u8], at: usize) -> Self { + Logged { + id: byte(data, at) & 0x7f, + log: LOG.with(Rc::clone), + } + } + + fn put(&self, out: &mut Vec) { + out.push(self.id); + // What was logged so far, after a marker. + out.push(0xfd); + out.extend(RefCell::borrow_mut(&self.log).drain(..)); + } +} + +/// Holds a value in a field. +struct Held { + value: T, +} + +/// Runs each conversion of the type `kind` picks, but for `u8`, whose `&mut` no slice can +/// view, and [`searched`] of those that order. +pub fn conversions(kind: u8, data: &[u8], out: &mut Vec) { + match kind % 14 { + 0 => { + ordered::(data, out); + lent_through::(data, out); + } + 1 => ordered::(data, out), + 2 => { + ordered::(data, out); + lent_through::(data, out); + } + 3 => { + ordered::>(data, out); + lent_through::>(data, out); + } + 4 => ordered::<[u8; 0]>(data, out), + 5 => ordered::<[u8; 1]>(data, out), + 6 => { + ordered::<[u8; 3]>(data, out); + lent_through::<[u8; 3]>(data, out); + } + 7 => ordered::<[u8; 40]>(data, out), + 8 => ordered::<[u32; 2]>(data, out), + 9 => ordered::(data, out), + 10 => ordered::>(data, out), + 11 => ordered::>(data, out), + 12 => { + converted::(data, out); + searched::(data, out); + } + _ => { + // What an earlier case dropped at its end, which JS runs on after. + LOG.with(|log| RefCell::borrow_mut(log).clear()); + converted::(data, out); + lent_one::(data, out); + } + } + measured(data, out); + pointed(data, out); +} + +/// Each conversion of a `T` that orders. +fn ordered(data: &[u8], out: &mut Vec) { + converted::(data, out); + lent_one::(data, out); + searched::(data, out); +} + +/// `clone_from` through a `&mut` whose place only the caller knows. +fn clone_from_param(to: &mut T, from: &T) { + to.clone_from(from); +} + +/// `clone_into` through a `&mut` whose place only the caller knows. +fn clone_into_param(from: &T, to: &mut T) { + from.clone_into(to); +} + +/// A whole write into what a slice holds, as a function given any slice makes it. +fn write_first(s: &mut [T], value: T) -> T { + let old = std::mem::replace(&mut s[0], value.clone()); + s[0] = value; + old +} + +/// A slice of what a `&mut` whose place only the caller knows points at, written through: +/// one to a value JS copies or to an array of bytes, which a whole write reaches, unlike +/// an object's slot. +fn lent_param(to: &mut T, value: T) -> T { + write_first(std::slice::from_mut(to), value) +} + +/// [`lent_param`] of an element. +fn lent_through(data: &[u8], out: &mut Vec) { + let mut v = vec![T::make(data, 2), T::make(data, 4)]; + lent_param(&mut v[1], T::make(data, 18)).put(out); + v[1].put(out); +} + +/// A cell of what a `&mut` whose place only the caller knows points at, written through. +fn set_through(to: &mut T, value: T) -> T { + Cell::from_mut(to).replace(value) +} + +/// Each conversion of a `T`, its copies put after a write to what they copied. +fn converted(data: &[u8], out: &mut Vec) { + let mut a = T::make(data, 0); + let b = T::make(data, 3); + // A copy shares nothing with what it copied. + let owned = a.to_owned(); + a.clone_from(&b); + owned.put(out); + a.put(out); + let mut c = T::make(data, 6); + owned.clone_into(&mut c); + c.put(out); + clone_from_param(&mut c, &b); + clone_into_param(&owned, &mut a); + c.put(out); + a.put(out); + // Through a field and an element. + let mut held = Held { + value: T::make(data, 1), + }; + held.value.clone_from(&c); + let mut v = vec![T::make(data, 2), T::make(data, 4)]; + v[1].clone_from(&held.value); + b.clone_into(&mut v[0]); + held.value.put(out); + v[0].put(out); + v[1].put(out); + // Read, and its clone a value of its own. + let one = std::array::from_ref(&b); + out.push(one.len() as u8); + let copied = one[0].clone(); + one[0].put(out); + a.clone_from(&copied); + copied.put(out); + a.put(out); + // A cell of a local and of what a parameter points at, its old value read out. + let cell = Cell::from_mut(&mut c); + let old = cell.replace(T::make(data, 10)); + cell.set(T::make(data, 11)); + old.put(out); + c.put(out); + set_through(&mut v[0], T::make(data, 12)).put(out); + v[0].put(out); + Cell::from_mut(&mut held.value).set(T::make(data, 17)); + held.value.put(out); + // Arrays as slices. + let mut array = [T::make(data, 13), T::make(data, 14), T::make(data, 15)]; + let lens = [AsRef::<[T]>::as_ref(&array).len(), Borrow::<[T]>::borrow(&array).len()]; + out.extend(lens.map(|n| n as u8)); + AsMut::<[T]>::as_mut(&mut array)[0] = b.clone(); + BorrowMut::<[T]>::borrow_mut(&mut array)[2].clone_from(&c); + for x in &array { + x.put(out); + } + // A pointer, read and written through. + let p = std::ptr::from_ref(&b); + unsafe { (*p).put(out) }; + let q = std::ptr::from_mut(&mut c); + unsafe { *q = T::make(data, 16) }; + c.put(out); +} + +/// Slices and arrays of one value of a local, a field, and an element, written through as +/// a whole, the old value read out, and through std's slice methods. +fn lent_one(data: &[u8], out: &mut Vec) { + let (mut a, b, mut c) = (T::make(data, 0), T::make(data, 3), T::make(data, 6)); + let mut held = Held { + value: T::make(data, 1), + }; + let mut v = vec![T::make(data, 2), T::make(data, 4)]; + let s = std::slice::from_mut(&mut a); + out.push(s.len() as u8); + let old = std::mem::replace(&mut s[0], T::make(data, 5)); + old.put(out); + a.put(out); + let old = write_first(std::slice::from_mut(&mut held.value), T::make(data, 7)); + old.put(out); + held.value.put(out); + let old = write_first(std::array::from_mut(&mut v[1]), T::make(data, 8)); + old.put(out); + v[1].put(out); + // Through std's slice methods. + std::slice::from_mut(&mut c).fill(b.clone()); + for x in std::array::from_mut(&mut a) { + *x = T::make(data, 9); + } + c.put(out); + a.put(out); +} + +/// `binary_search` of each value `data` makes in a sorted run of them, where equal ones +/// repeat: `Ok` or `Err` as a byte, then the index. +fn searched(data: &[u8], out: &mut Vec) { + let mut v: Vec = (0..data.len().min(24)).map(|i| T::make(data, i)).collect(); + v.sort(); + for n in [0, 1, 2, 3, v.len()] { + let s = &v[..n.min(v.len())]; + for i in 0..data.len().min(8) + 1 { + let found = s.binary_search(&T::make(data, i * 2 + 1)); + let (tag, at) = match found { + Ok(at) => (1, at), + Err(at) => (0, at), + }; + out.extend([tag, at as u8]); + } + } +} + +/// What wasm32 lays out each value in, and a slice or a `str` of what `data` holds. +fn measured(data: &[u8], out: &mut Vec) { + let n = data.len(); + let wide: Vec = data.iter().map(|&b| u64::from(b)).collect(); + // Past ASCII, where a `char` takes two bytes. + let text: String = data.iter().map(|&b| char::from(b)).collect(); + let named = Named::make(data, 0); + let sizes = [ + (size_of_val(&data[0..0]), align_of_val(&data[0..0])), + (size_of_val(data), align_of_val(data)), + (size_of_val(&wide[..]), align_of_val(&wide[..])), + (size_of_val(&*text), align_of_val(&*text)), + (size_of_val(&n), align_of_val(&n)), + (size_of_val(&(n as u128)), align_of_val(&(n as u128))), + (size_of_val(&(n as u8, n as u16)), align_of_val(&(n as u8, n as u16))), + (size_of_val(&Some(n as u32)), align_of_val(&Some(n as u32))), + (size_of_val(&[n as u16; 3]), align_of_val(&[n as u16; 3])), + (size_of_val(&named), align_of_val(&named)), + (size_of_val(&text), align_of_val(&text)), + (size_of_val(&()), align_of_val(&())), + ]; + for (size, align) in sizes { + out.extend([size as u8, align as u8]); + } +} + +/// Raw pointers of references to the bytes of arrays and to objects, compared by where +/// they point, and an array of an `u8`. +fn pointed(data: &[u8], out: &mut Vec) { + let (mut a, b) = (<[u8; 2]>::make(data, 0), <[u8; 2]>::make(data, 2)); + let (x, y) = (Named::make(data, 0), Named::make(data, 3)); + let same = [ + std::ptr::eq(std::ptr::from_ref(&a), &a), + std::ptr::eq(std::ptr::from_ref(&a), &b), + std::ptr::eq(std::ptr::from_ref(&x), &x), + std::ptr::eq(std::ptr::from_ref(&x), &y), + ]; + out.extend(same.map(u8::from)); + let p = std::ptr::from_mut(&mut a); + unsafe { (*p)[0] ^= 0x10 }; + out.extend_from_slice(&a); + let one = std::array::from_ref(&a[1]); + out.extend_from_slice(one); +} diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs index 847fb3085..1fa621a15 100644 --- a/ts/fixtures/lang/src/harness.rs +++ b/ts/fixtures/lang/src/harness.rs @@ -3,10 +3,10 @@ use crate::{ args, arrays, ascii, atomics, borrows, bounds, boxes, capacity, captures, cells, chars, chunks, clones, - collections, combinators, counts, cows, cycles, defaults, durations, dyns, edits, errors, fields, floats, fmt, - folds, generics, hashes, hints, holds, ints, iters, joins, keys, lengths, lists, locals, locks, methods, nested, - objects, orders, pointers, refs, results, returns, saturates, separated, shapes, singles, slices, splits, statics, - strs, tuples, utf8, wrappers, wraps, zeros, + collections, combinators, conversions, counts, cows, cycles, defaults, durations, dyns, edits, errors, fields, + floats, fmt, folds, generics, hashes, hints, holds, ints, iters, joins, keys, lengths, lists, locals, locks, + methods, nested, objects, orders, pointers, refs, results, returns, saturates, separated, shapes, singles, slices, + splits, statics, strs, tuples, utf8, wrappers, wraps, zeros, }; /// The native side's entry: [`run`], except that a case starting with 0xff prints a @@ -275,6 +275,7 @@ fn cases() -> Vec<(&'static str, Case)> { ("strs::gets", strs::gets), ("borrows::maps", |_, data, out| borrows::maps(data, out)), ("locks::mapped", |_, data, out| locks::mapped(data, out)), + ("conversions::conversions", conversions::conversions), ("borrows::tries", |_, data, out| borrows::tries(data, out)), ("locks::mutex_mapped", |_, data, out| locks::mutex_mapped(data, out)), ("locks::printed", |_, data, out| locks::printed(data, out)), diff --git a/ts/fixtures/lang/src/lib.rs b/ts/fixtures/lang/src/lib.rs index 47fc86bec..a5f78962a 100644 --- a/ts/fixtures/lang/src/lib.rs +++ b/ts/fixtures/lang/src/lib.rs @@ -20,7 +20,9 @@ //! size hints, the capacity overflows collections reserving by them panic with, the //! capacity of a `Vec`, `VecDeque`, and `BinaryHeap` as each grows and shrinks, tuples of //! collections collected and extended by their items, zero-sized values, which MIR -//! never assigns, with std's impls of them, and functions generic over an array's length. +//! never assigns, with std's impls of them, functions generic over an array's length, and +//! std's conversions of a reference: clones into it, searches, sizes, slices, cells, and +//! pointers of one value. //! //! `harness::run` is the entry point both sides of the differential test run, and //! `fmt::Fault` an error only `caller.ts` prints. @@ -51,6 +53,7 @@ mod chunks; mod clones; mod collections; mod combinators; +mod conversions; mod counts; mod cows; mod cycles; diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 340b228b8..76ceb4d1c 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,7 +1,7 @@ # Census of `reject-fixture` -- Refusals: 218 -- Function instances: 271 +- Refusals: 227 +- Function instances: 281 - Generic functions no instance reached, lowered over their type parameters: 13 ## By construct @@ -10,19 +10,20 @@ | ---: | --- | --- | | 45 | a raw pointer to `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:608:10 | | 25 | unsupported call to `_` | fixtures/reject/src/lib.rs:160:8 | -| 19 | a raw pointer to `_` in a variable assigned again while it may point there | fixtures/reject/src/lib.rs:616:10 | +| 22 | a raw pointer to `_` in a variable assigned again while it may point there | fixtures/reject/src/lib.rs:616:10 | | 15 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:1337:33 | | 15 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | fixtures/reject/src/lib.rs:1655:18 | | 5 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:1235:22 | | 5 | a raw pointer to `_` in an element, a payload, or a union field, which is not supported yet | fixtures/reject/src/lib.rs:679:10 | | 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:331:2 | +| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:83:2 | +| 3 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | fixtures/reject/src/lib.rs:21:4 | | 3 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:224:14 | -| 3 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:83:2 | +| 3 | a slice or a cell of a mutable reference to `_` that names no place, which a whole write would replace only there | fixtures/reject/src/lib.rs:2164:2 | | 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:91:2 | | 3 | unsupported type `_` | fixtures/reject/src/lib.rs:7:14 | | 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | fixtures/reject/src/lib.rs:16:15 | | 2 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | fixtures/reject/src/lib.rs:37:4 | -| 2 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | fixtures/reject/src/lib.rs:21:4 | | 2 | `_`, a trait object of another crate's trait, which is not supported yet | fixtures/reject/src/lib.rs:11:16 | | 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | fixtures/reject/src/lib.rs:464:23 | | 2 | a cast from a pointer to `_` to one to `_`, which reads the bytes of one type as another | fixtures/reject/src/lib.rs:555:27 | @@ -66,6 +67,7 @@ | 1 | a raw pointer to `_` behind a reference, which is the object and not where it is kept | fixtures/reject/src/lib.rs:577:10 | | 1 | a reference through which a raw pointer may be made into `_` in an element, a payload, or a union field, which is not supported yet | fixtures/reject/src/lib.rs:1364:11 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | +| 1 | a slice of one byte's place, which a byte slice can view only in an array of bytes | fixtures/reject/src/lib.rs:2158:2 | | 1 | a trait object of `_`, which is not supported yet | fixtures/reject/src/lib.rs:481:26 | | 1 | an upcast from `_` to `_`, which is not supported yet | fixtures/reject/src/lib.rs:532:32 | | 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | @@ -88,7 +90,7 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | | 39 | `std::cell::UnsafeCell` | fixtures/reject/src/lib.rs:687:15 | -| 24 | `(u32, u32)` | fixtures/reject/src/lib.rs:608:10 | +| 27 | `(u32, u32)` | fixtures/reject/src/lib.rs:608:10 | | 6 | `[u8; 4]` | fixtures/reject/src/lib.rs:481:26 | | 6 | `f16` | fixtures/reject/src/lib.rs:7:14 | | 6 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:331:2 | @@ -103,6 +105,7 @@ The type or module each refused type or path belongs to. | 3 | `*const [u8; 4]` | fixtures/reject/src/lib.rs:1713:33 | | 3 | `Mid` | fixtures/reject/src/lib.rs:1355:34 | | 3 | `Outer` | fixtures/reject/src/lib.rs:1355:34 | +| 3 | `Reused` | fixtures/reject/src/lib.rs:21:4 | | 3 | `std::ptr` | fixtures/reject/src/lib.rs:1710:3 | | 3 | `std::vec::Vec` | fixtures/reject/src/lib.rs:310:16 | | 2 | `(u16, u16)` | fixtures/reject/src/lib.rs:1176:31 | @@ -113,7 +116,6 @@ The type or module each refused type or path belongs to. | 2 | `InWritten` | fixtures/reject/src/lib.rs:1326:9 | | 2 | `Inside` | fixtures/reject/src/lib.rs:1845:20 | | 2 | `Poll` | fixtures/reject/src/lib.rs:72:20 | -| 2 | `Reused` | fixtures/reject/src/lib.rs:21:4 | | 2 | `Scaled` | fixtures/reject/src/lib.rs:464:23 | | 2 | `[u8; 2]` | fixtures/reject/src/lib.rs:1726:37 | | 2 | `[u8; 3]` | fixtures/reject/src/lib.rs:1726:15 | @@ -168,6 +170,7 @@ The type or module each refused type or path belongs to. | 1 | `BytesMut` | fixtures/reject/src/lib.rs:383:6 | | 1 | `Called` | fixtures/reject/src/lib.rs:1086:28 | | 1 | `Chosen` | fixtures/reject/src/lib.rs:1906:17 | +| 1 | `Clone` | fixtures/reject/src/lib.rs:2169:4 | | 1 | `Closed` | fixtures/reject/src/lib.rs:2078:15 | | 1 | `Compared` | fixtures/reject/src/lib.rs:1873:22 | | 1 | `Copied` | fixtures/reject/src/lib.rs:1176:31 | @@ -224,12 +227,14 @@ The type or module each refused type or path belongs to. | 1 | `rt.Poll` | fixtures/reject/src/lib.rs:502:2 | | 1 | `std::any::Any` | fixtures/reject/src/lib.rs:538:4 | | 1 | `std::cell::Cell` | fixtures/reject/src/lib.rs:955:22 | +| 1 | `std::cell::LazyCell` | fixtures/reject/src/lib.rs:2206:3 | | 1 | `std::collections::BTreeMap` | fixtures/reject/src/lib.rs:955:22 | | 1 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:253:6 | | 1 | `std::default::Default` | fixtures/reject/src/lib.rs:2119:2 | | 1 | `std::iter::Map` | fixtures/reject/src/lib.rs:209:40 | | 1 | `std::iter::Zip` | fixtures/reject/src/lib.rs:202:8 | | 1 | `std::iter` | fixtures/reject/src/lib.rs:1235:22 | +| 1 | `std::mem` | fixtures/reject/src/lib.rs:2174:2 | | 1 | `std::net::AddrParseError` | fixtures/reject/src/lib.rs:438:32 | | 1 | `std::net::Ipv4Addr` | fixtures/reject/src/lib.rs:438:32 | | 1 | `std::num` | fixtures/reject/src/lib.rs:1277:4 | @@ -238,8 +243,10 @@ The type or module each refused type or path belongs to. | 1 | `std::ptr::mut_ptr` | fixtures/reject/src/lib.rs:1713:56 | | 1 | `std::slice::IterMut` | fixtures/reject/src/lib.rs:766:15 | | 1 | `std::std::Layout` | fixtures/reject/src/lib.rs:565:15 | +| 1 | `std::sync::LazyLock` | fixtures/reject/src/lib.rs:2211:2 | | 1 | `std::sync::Weak` | fixtures/reject/src/lib.rs:455:40 | | 1 | `std::task::Poll` | fixtures/reject/src/lib.rs:77:34 | +| 1 | `std::thread::LocalKey` | fixtures/reject/src/lib.rs:2217:2 | | 1 | `str` | fixtures/reject/src/lib.rs:326:4 | | 1 | `u64` | fixtures/reject/src/lib.rs:68:2 | | 1 | `value` | fixtures/reject/src/lib.rs:31:2 | @@ -248,7 +255,7 @@ The type or module each refused type or path belongs to. | Count | Construct | Type or path | First | | ---: | --- | --- | --- | -| 14 | a raw pointer to `_` in a variable assigned again while it may point there | `(u32, u32)` | fixtures/reject/src/lib.rs:616:10 | +| 17 | a raw pointer to `_` in a variable assigned again while it may point there | `(u32, u32)` | fixtures/reject/src/lib.rs:616:10 | | 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:331:2 | | 3 | a raw pointer to `_` in `_`, which the crate may put another object in place of | `(u32, u32)`, `Gap` | fixtures/reject/src/lib.rs:908:10 | | 3 | a reference through which a raw pointer may be made into `_` in `_`, which the crate may put another object in place of | `Mid`, `Outer` | fixtures/reject/src/lib.rs:1355:34 | @@ -278,6 +285,7 @@ The type or module each refused type or path belongs to. | 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` | `Waiting`, `poll`, `Poll`, `rt.Poll`, `Poll` | fixtures/reject/src/lib.rs:502:2 | | 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:253:6 | | 1 | `_` of `_`, which is not supported yet | `std::any::Any::type_id`, `dyn std::any::Any` | fixtures/reject/src/lib.rs:538:4 | +| 1 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | `Clone::clone_from`, `std::vec::Vec` | fixtures/reject/src/lib.rs:2169:4 | | 1 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | `slice::clone_from_slice`, `Reused` | fixtures/reject/src/lib.rs:286:4 | | 1 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | `slice::fill`, `Reused` | fixtures/reject/src/lib.rs:21:4 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::collections::LinkedList::retain` | fixtures/reject/src/lib.rs:2117:4 | @@ -372,7 +380,11 @@ The type or module each refused type or path belongs to. | 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `std::cell::UnsafeCell` | fixtures/reject/src/lib.rs:1655:18 | | 1 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | `std::option::Option` | fixtures/reject/src/lib.rs:2108:13 | | 1 | a scalar constant of type `_` | `f16` | fixtures/reject/src/lib.rs:8:2 | +| 1 | a slice or a cell of a mutable reference to `_` that names no place, which a whole write would replace only there | `Reused` | fixtures/reject/src/lib.rs:2164:2 | +| 1 | a slice or a cell of a mutable reference to `_` that names no place, which a whole write would replace only there | `std::cell::LazyCell` | fixtures/reject/src/lib.rs:2206:3 | +| 1 | a slice or a cell of a mutable reference to `_` that names no place, which a whole write would replace only there | `std::thread::LocalKey` | fixtures/reject/src/lib.rs:2217:2 | | 1 | a trait object of `_`, which is not supported yet | `[u8; 4]` | fixtures/reject/src/lib.rs:481:26 | +| 1 | an assignment through a reference to `_` | `std::sync::LazyLock` | fixtures/reject/src/lib.rs:2211:2 | | 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:83:2 | | 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:145:1 | | 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:193:1 | @@ -398,10 +410,10 @@ The type or module each refused type or path belongs to. | 1 | unsupported call to `_` | `::contains` | fixtures/reject/src/lib.rs:984:32 | | 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:369:2 | | 1 | unsupported call to `_` | `::is_sorted` | fixtures/reject/src/lib.rs:766:15 | -| 1 | unsupported call to `_` | `::clone_from` | fixtures/reject/src/lib.rs:886:10 | | 1 | unsupported call to `_` | `::hash` | fixtures/reject/src/lib.rs:301:10 | | 1 | unsupported call to `_` | `std::any::TypeId::of` | fixtures/reject/src/lib.rs:538:17 | | 1 | unsupported call to `_` | `std::borrow::Cow::is_borrowed` | fixtures/reject/src/lib.rs:343:2 | +| 1 | unsupported call to `_` | `std::mem::size_of_val` | fixtures/reject/src/lib.rs:2174:2 | | 1 | unsupported call to `_` | `std::num::is_ascii_octdigit` | fixtures/reject/src/lib.rs:1277:4 | | 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:160:8 | | 1 | unsupported call to `_` | `std::ops::Range::is_empty` | fixtures/reject/src/lib.rs:989:9 | @@ -487,7 +499,6 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:567:11: unsupported call to `std::alloc::alloc` - fixtures/reject/src/lib.rs:570:3: unsupported call to `std::alloc::dealloc` - fixtures/reject/src/lib.rs:766:15: unsupported call to ` as std::iter::Iterator>::is_sorted` -- fixtures/reject/src/lib.rs:886:10: unsupported call to ` as std::clone::Clone>::clone_from` - fixtures/reject/src/lib.rs:984:11: unsupported call to `std::ops::RangeTo::::contains::` - fixtures/reject/src/lib.rs:984:32: unsupported call to ` as std::ops::RangeBounds>::contains::` - fixtures/reject/src/lib.rs:989:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty` @@ -499,10 +510,11 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:1713:56: unsupported call to `std::ptr::mut_ptr::::add` - fixtures/reject/src/lib.rs:1713:73: unsupported call to `std::ptr::const_ptr::::offset` - fixtures/reject/src/lib.rs:1717:58: unsupported call to `std::ptr::const_ptr::::len` +- fixtures/reject/src/lib.rs:2174:2: unsupported call to `std::mem::size_of_val::` -
a raw pointer to `_` in a variable assigned again while it may point there (19) +
a raw pointer to `_` in a variable assigned again while it may point there (22) - fixtures/reject/src/lib.rs:616:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there - fixtures/reject/src/lib.rs:624:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there @@ -523,6 +535,9 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:1697:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there - fixtures/reject/src/lib.rs:1733:26: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there - fixtures/reject/src/lib.rs:1734:10: a raw pointer to `[u8; 4]` in a variable assigned again while it may point there +- fixtures/reject/src/lib.rs:2180:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +- fixtures/reject/src/lib.rs:2188:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +- fixtures/reject/src/lib.rs:2196:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there
@@ -595,6 +610,23 @@ The type or module each refused type or path belongs to.
+
an assignment through a reference to `_` (4) + +- fixtures/reject/src/lib.rs:83:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +- fixtures/reject/src/lib.rs:107:2: an assignment through a reference to `std::pin::Pin>>` +- fixtures/reject/src/lib.rs:214:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` +- fixtures/reject/src/lib.rs:2211:2: an assignment through a reference to `std::sync::LazyLock` + +
+ +
`_` of `_`, whose `clone_from` is its own, which is not supported yet (3) + +- fixtures/reject/src/lib.rs:21:4: `slice::fill` of `Reused`, whose `clone_from` is its own, which is not supported yet +- fixtures/reject/src/lib.rs:286:4: `slice::clone_from_slice` of `Reused`, whose `clone_from` is its own, which is not supported yet +- fixtures/reject/src/lib.rs:2169:4: `Clone::clone_from` of `std::vec::Vec`, whose `clone_from` is its own, which is not supported yet + +
+
a copy of a closure that changes what it captured (3) - fixtures/reject/src/lib.rs:224:14: a copy of a closure that changes what it captured @@ -603,11 +635,11 @@ The type or module each refused type or path belongs to.
-
an assignment through a reference to `_` (3) +
a slice or a cell of a mutable reference to `_` that names no place, which a whole write would replace only there (3) -- fixtures/reject/src/lib.rs:83:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` -- fixtures/reject/src/lib.rs:107:2: an assignment through a reference to `std::pin::Pin>>` -- fixtures/reject/src/lib.rs:214:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` +- fixtures/reject/src/lib.rs:2164:2: a slice or a cell of a mutable reference to `Reused` that names no place, which a whole write would replace only there +- fixtures/reject/src/lib.rs:2206:3: a slice or a cell of a mutable reference to `std::cell::LazyCell` that names no place, which a whole write would replace only there +- fixtures/reject/src/lib.rs:2217:2: a slice or a cell of a mutable reference to `std::thread::LocalKey` that names no place, which a whole write would replace only there
@@ -641,13 +673,6 @@ The type or module each refused type or path belongs to.
-
`_` of `_`, whose `clone_from` is its own, which is not supported yet (2) - -- fixtures/reject/src/lib.rs:21:4: `slice::fill` of `Reused`, whose `clone_from` is its own, which is not supported yet -- fixtures/reject/src/lib.rs:286:4: `slice::clone_from_slice` of `Reused`, whose `clone_from` is its own, which is not supported yet - -
-
`_`, a trait object of another crate's trait, which is not supported yet (2) - fixtures/reject/src/lib.rs:11:16: `dyn std::iter::Iterator`, a trait object of another crate's trait, which is not supported yet @@ -916,6 +941,12 @@ The type or module each refused type or path belongs to.
+
a slice of one byte's place, which a byte slice can view only in an array of bytes (1) + +- fixtures/reject/src/lib.rs:2158:2: a slice of one byte's place, which a byte slice can view only in an array of bytes + +
+
a trait object of `_`, which is not supported yet (1) - fixtures/reject/src/lib.rs:481:26: a trait object of `[u8; 4]`, which is not supported yet diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index ea34aacc6..826cd6ea7 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -199,6 +199,16 @@ const generic types are not supported: `Block` at fixtures/reject/src/lib.rs:210 `clone_from` of `std::collections::LinkedList`, whose items' `clone_from` is their own, which is not supported yet at fixtures/reject/src/lib.rs:2118:4 `std::default::Default::default` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:2119:2 a mapped guard of `{closure@fixtures/reject/src/lib.rs:2151:38: 2151:50}`, which JS can't write in place at fixtures/reject/src/lib.rs:2152:10 +a slice of one byte's place, which a byte slice can view only in an array of bytes at fixtures/reject/src/lib.rs:2158:2 +a slice or a cell of a mutable reference to `Reused` that names no place, which a whole write would replace only there at fixtures/reject/src/lib.rs:2164:2 +`Clone::clone_from` of `std::vec::Vec`, whose `clone_from` is its own, which is not supported yet at fixtures/reject/src/lib.rs:2169:4 +unsupported call to `std::mem::size_of_val::` at fixtures/reject/src/lib.rs:2174:2 +a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2180:10 +a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2188:10 +a raw pointer to `(u32, u32)` in a variable assigned again while it may point there at fixtures/reject/src/lib.rs:2196:10 +a slice or a cell of a mutable reference to `std::cell::LazyCell` that names no place, which a whole write would replace only there at fixtures/reject/src/lib.rs:2206:3 +an assignment through a reference to `std::sync::LazyLock` at fixtures/reject/src/lib.rs:2211:2 +a slice or a cell of a mutable reference to `std::thread::LocalKey` that names no place, which a whole write would replace only there at fixtures/reject/src/lib.rs:2217:2 overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:125:2 an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:145:1 overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:173:2 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 4b7698a35..7f7ee009a 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -2152,3 +2152,68 @@ pub fn mapped_closure(add: u8) -> u8 { let f = std::cell::RefMut::map(cell.borrow_mut(), |pair| &mut pair.0); f(1) } + +/// A slice of one `u8`'s place, which no `rt.ByteSlice` views. +pub fn byte_slice_of_place(b: &mut u8) { + std::slice::from_mut(b)[0] = 1; +} + +/// A slice of the object a parameter is, whose element a whole write would replace only +/// in the slice, not where the caller holds it. +pub fn slice_of_object(r: &mut Reused, by: Reused) { + std::slice::from_mut(r)[0] = by; +} + +/// `clone_from` of a `Vec` whose elements' is their own. +pub fn vec_clone_from(v: &mut Vec, from: &Vec) { + v.clone_from(from); +} + +/// `size_of_val` of a trait object, which its vtable gives. +pub fn dyn_size(d: &dyn std::fmt::Debug) -> usize { + size_of_val(d) +} + +/// A pointer to a variable's object, which `clone_from` of the whole variable replaces. +pub fn variable_cloned_from(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + pair.clone_from(&(0, 0)); + unsafe { (*p).0 + pair.1 } +} + +/// A pointer to a variable's object, which `clone_into` the whole variable replaces. +pub fn variable_cloned_into(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + (0, 0).clone_into(&mut pair); + unsafe { (*p).0 + pair.1 } +} + +/// A pointer to a variable's object, which a cell of the whole variable replaces. +pub fn variable_celled(n: u32) -> u32 { + let mut pair = (n, n); + let p = &raw mut pair; + std::cell::Cell::from_mut(&mut pair).set((0, 0)); + unsafe { (*p).0 + pair.1 } +} + +const LAZY_CELL: std::cell::LazyCell = std::cell::LazyCell::new(|| 2); +const LAZY_LOCK: std::sync::LazyLock = std::sync::LazyLock::new(|| 2); + +/// A lazy cell's state, which JS keeps private, so copying its fields can't move it. +pub fn lazy_celled(c: &mut std::cell::LazyCell) -> u32 { + *std::cell::Cell::from_mut(c).replace(LAZY_CELL) + **c +} + +/// A lazy lock written whole through a reference, which can't copy its private state. +pub fn lazy_assigned(c: &mut std::sync::LazyLock) -> u32 { + *c = LAZY_LOCK; + **c +} + +/// A thread local's key, whose state JS keeps private, set whole through a cell. +pub fn key_celled(key: &'static mut std::thread::LocalKey, next: std::thread::LocalKey) -> u32 { + std::cell::Cell::from_mut(key).set(next); + key.with(|v| *v) +} diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index 893fa2fb6..80f312618 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -166,5 +166,15 @@ roots = [ "block_cloned", "lists", "mapped_closure", + "byte_slice_of_place", + "slice_of_object", + "vec_clone_from", + "dyn_size", + "variable_cloned_from", + "variable_cloned_into", + "variable_celled", + "lazy_celled", + "lazy_assigned", + "key_celled", ] printable = ["Meters"] diff --git a/ts/runtime/rt.ts b/ts/runtime/rt.ts index 605b72ce4..916868520 100644 --- a/ts/runtime/rt.ts +++ b/ts/runtime/rt.ts @@ -114,6 +114,14 @@ export function place(get: () => T, set: (value: T) => void): Place { return new Accessed(get, set); } +/** The place of the `[u8; N]` whose bytes `view` is: read as the view, written into it. */ +export function bytesPlace(view: Uint8Array): Place { + return place( + () => view, + (value) => view.set(value), + ); +} + // Raw pointers /** A null raw pointer, of any type: nothing reads through it. */ @@ -314,16 +322,32 @@ export function sliceView(s: T[], start: number, end: number): T[] { return new Proxy(new Array(end - start), view); } +/** + * `slice::from_mut` or `array::from_mut`: a slice of the one value at `p`, read and + * written there, as a `sliceView` is of its array's. + */ +export function sliceOfPlace(p: Place): T[] { + const one = { + get 0() { + return p.v; + }, + set 0(value: T) { + p.v = value; + }, + }; + return new Proxy(new Array(1), new View(one, 0, 1)); +} + /** What a `sliceView` answers to its own `View` by. */ const VIEW = /* @__PURE__ */ Symbol("view"); /** A `sliceView`'s traps: of `length` elements of `s` from `start`. */ class View implements ProxyHandler { - readonly s: T[]; + readonly s: { [index: number]: T }; readonly start: number; readonly length: number; - constructor(s: T[], start: number, length: number) { + constructor(s: { [index: number]: T }, start: number, length: number) { this.s = s; this.start = start; this.length = length; @@ -502,6 +526,24 @@ export function sliceContains(s: ArrayLike, x: T, eq: (a: T, b: T) => bool return false; } +/** + * `binary_search`: `Ok` of where an element `cmp` finds equal to `x` is, or else `Err` of + * where `x` would go, probing as std's does, so a run of equal elements gives std's index. + */ +export function sliceBinarySearch(s: ArrayLike, x: T, cmp: (a: T, b: T) => Ordering): Result { + let size = s.length; + if (size === 0) return Err(0); + let base = 0; + while (size > 1) { + const half = Math.floor(size / 2); + const mid = base + half; + if (cmp(s[mid]!, x) !== 1) base = mid; + size -= half; + } + const order = cmp(s[base]!, x); + return order === 0 ? Ok(base) : Err(order === -1 ? base + 1 : base); +} + /** `swap`, panicking on either index past the end, `a` first, as std's indexing does. */ export function sliceSwap(s: T[], a: number, b: number): void { const x = s[idx(s, a)]; diff --git a/ts/runtime/rt/task.ts b/ts/runtime/rt/task.ts index b600f31ca..b6ed9b31e 100644 --- a/ts/runtime/rt/task.ts +++ b/ts/runtime/rt/task.ts @@ -646,6 +646,28 @@ export class Cell implements Place, Disposable { } } +/** `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; +} + +/** + * `Cell::from_mut` of the object or the bytes a `&mut` is: a read is a copy, as a `Cell` + * only moves or copies its value out, and a write lands in place, a JS array's taking + * the new one's length. + */ +export function cellIn(p: T): Cell { + const copy = (): T => { + if (ArrayBuffer.isView(p) || Array.isArray(p)) return (p as unknown as T[]).slice() as T; + return Object.assign(Object.create(Object.getPrototypeOf(p)) as T, p); + }; + const write = (value: T): void => { + if (Array.isArray(p)) vecAssign(p, value as unknown[]); + else ptrWrite(p, value); + }; + return cellOfPlace(place(copy, write)); +} + /** * `PartialEq`, `PartialOrd`, or `Ord` of `Cell`s, or `PartialEq` of `OnceCell`s or * `OnceLock`s, by `f` of what each holds. diff --git a/ts/src/lower/copy.rs b/ts/src/lower/copy.rs index a7bd83a66..82d0f206a 100644 --- a/ts/src/lower/copy.rs +++ b/ts/src/lower/copy.rs @@ -755,7 +755,7 @@ fn retargeted_in<'tcx>( for (data, bb) in body.basic_blocks.iter().zip(body.basic_blocks.indices()) { if let mir::TerminatorKind::Call { func, args, .. } = &data.terminator().kind && let Some((i, _, rebinds)) = rebinding(args, func) - && i < rebinds + && rebinds.contains(&i) { let by = args[i].node.place().and_then(|p| p.as_local()); if by.is_some_and(|by| uses.get(&by) == Some(&vec![body.terminator_loc(bb)])) { @@ -1111,8 +1111,8 @@ impl<'tcx> Visitor<'tcx> for BodyWrites<'_, '_, '_, 'tcx> { } let rebound = func .const_fn_def() - .map_or(0, |(def_id, _)| super::pointer::rebinds(self.tcx, def_id)); - for arg in args[..rebound].iter().filter_map(|a| a.node.place()) { + .map_or(&[][..], |(def_id, _)| super::pointer::rebinds(self.tcx, def_id)); + for arg in rebound.iter().filter_map(|&i| args.get(i)?.node.place()) { self.store_through(self.tcx.mk_place_deref(arg), location); } } diff --git a/ts/src/lower/lend.rs b/ts/src/lower/lend.rs index e0029fb6a..e6979fc94 100644 --- a/ts/src/lower/lend.rs +++ b/ts/src/lower/lend.rs @@ -71,7 +71,15 @@ pub fn plan<'tcx>(t: &Translator<'_, 'tcx>, def_id: DefId, args: GenericArgsRef< ("PartialOrd" | "Ord" | "PartialEq", _) | ("Hash", "hash") => true, ("slice", "iter" | "iter_mut") | ("array", "each_ref" | "each_mut") => true, // Lowered from MIR, which writes through the slice. - ("mem", "swap" | "replace" | "take") => true, + ("mem", "swap" | "replace" | "take") + | ("Clone", "clone_from") + | ("ToOwned", "clone_into") + | ("raw" | "array" | "Cell" | "ptr", "from_mut") => true, + // `Clone::clone`, which takes the slice, and an array as a slice, which it is. + ("ToOwned", "to_owned") => true, + ("AsRef" | "AsMut" | "Borrow" | "BorrowMut", _) => { + args.type_at(0).is_array() && args.type_at(1).is_slice() + } ("IntoIterator", "into_iter") => self_ty.is_some_and(|s| { let s = super::iter::unbox_ref(tcx, s).peel_refs(); matches!(s.kind(), ty::Slice(_) | ty::Array(..)) || t.std_of(s) == Some(Std::Vec) diff --git a/ts/src/lower/library.rs b/ts/src/lower/library.rs index ab5f8ed2f..31abba0ee 100644 --- a/ts/src/lower/library.rs +++ b/ts/src/lower/library.rs @@ -1839,8 +1839,10 @@ fn mapping<'tcx>( }; rt2(values, of, &super::camel(name)) } - // A slice of the one value. - ("raw", "from_ref") if std_path(tcx, call.def_id) == ["slice", "raw", "from_ref"] => { + // A slice or an array of the one value. + ("raw" | "array", "from_ref") + if owner == "array" || std_path(tcx, call.def_id) == ["slice", "raw", "from_ref"] => + { let value = args.pop()?; match is_u8(targ(gargs, 0)) { true => Expr::rt( @@ -1850,6 +1852,20 @@ fn mapping<'tcx>( false => Expr::Array(vec![value]), } } + // The array is its own slice, as `as_slice` has it. + ("AsRef", "as_ref") | ("AsMut", "as_mut") | ("Borrow", "borrow") | ("BorrowMut", "borrow_mut") + if targ(gargs, 0).is_array() && targ(gargs, 1).is_slice() => + { + args.pop()? + } + // `Ord::cmp` of each element it compares with `x`, in std's order. + ("slice", "binary_search") => { + let elem = targ(gargs, 0); + let [s, x] = <[Expr; 2]>::try_from(args).ok()?; + let s = elements(s, Ty::new_slice(tcx, elem)); + let cmp = super::collections::cmp_fn(b, elem, false, span); + Expr::rt("sliceBinarySearch", vec![s, x, cmp]) + } // Each slot but the last a clone, as `clone_from` makes it, and the last the value; // a `TrivialClone`'s copies, as std specializes `fill` to. ("slice", "fill") => { @@ -2249,6 +2265,11 @@ fn mapping<'tcx>( ("ToString", "to_string") | ("ToOwned", "to_owned") if matches!(self_ty()?.peel_refs().kind(), ty::Str) => { b.t.pointee_value(self_ty()?, args.pop()?) } + // std's `ToOwned` for a `T: Clone` is its `clone`. + ("ToOwned", "to_owned") if self_ty()?.is_sized(tcx, b.t.typing_env_pub()) => { + let clone = super::collections::trait_fn(tcx, "Clone", "clone"); + return Some(b.call_def(clone, tcx.mk_args(&[self_ty()?.into()]), args, span, out)); + } // Panics, which format their message as std does. ("panicking", "panic_fmt") => { @@ -2289,6 +2310,27 @@ fn mapping<'tcx>( let layout = tcx.layout_of(env.as_query_input(targ(gargs, 0))).ok()?; Expr::lit(layout.size.bytes().to_string()) } + // What wasm32 lays out the value in: its type's, or a slice's elements' or a `str`'s + // bytes'. A trait object's is its vtable's, which is left to the refusal of any other call. + ("mem", "size_of_val" | "align_of_val") => { + let env = b.t.typing_env_pub(); + let ty = targ(gargs, 0); + let value = args.pop()?; + let (elem, len) = match ty.kind() { + ty::Slice(elem) => (*elem, Some(super::mir::slice_member(value, "length"))), + ty::Str => (tcx.types.u8, Some(Expr::rt("stringLen", vec![value]))), + _ if ty.is_sized(tcx, env) => (ty, None), + _ => return None, + }; + let layout = tcx.layout_of(env.as_query_input(elem)).ok()?; + let size = layout.size.bytes(); + match (name.as_str(), len) { + ("align_of_val", _) => Expr::lit(layout.align.abi.bytes().to_string()), + (_, None) => Expr::lit(size.to_string()), + (_, Some(len)) if size == 1 => len, + (_, Some(len)) => len.binary("*", Expr::lit(size.to_string())), + } + } // A reference to an array of bytes is an `rt.ByteSlice` already, and to one of other // values its JS array, so each is its own slice, and writes through it land in it. ("array", "as_slice" | "as_mut_slice") => args.pop()?, diff --git a/ts/src/lower/mir/call.rs b/ts/src/lower/mir/call.rs index ce3fc859d..4065f0dc2 100644 --- a/ts/src/lower/mir/call.rs +++ b/ts/src/lower/mir/call.rs @@ -516,6 +516,54 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { self.set_borrowed(&c, old, span, out); done(Expr::undefined(), false) } + // `*self = source.clone()`, as std's `Clone` for a `T: Clone` has `clone_from` and + // its `ToOwned` has `clone_into`, cloning before it drops what it writes over. A + // list's maps, as it clones each element into one of its own nodes. + ("Clone", "clone_from") | ("ToOwned", "clone_into") + if !self.b.t.translated(def_id, gargs) && self.b.t.std_of(targ(0)?) != Some(Std::LinkedList) => + { + let ty = targ(0)?; + if !ty.is_sized(tcx, self.b.t.typing_env_pub()) { + return None; + } + if !library::clone_from_clones(self.b.t, ty) { + let msg = format!( + "`{owner}::{name}` of `{ty}`, whose `clone_from` is its own, which is not supported yet" + ); + return done(self.err(span, msg), false); + } + let (target, source) = match name.as_str() { + "clone_from" => (&args[0].node, &args[1].node), + _ => (&args[1].node, &args[0].node), + }; + let place = self.borrowed_place(target, span, out)?; + let source = self.operand(source, span, out); + let clone = crate::lower::collections::trait_fn(tcx, "Clone", "clone"); + let clone = self + .b + .call_def(clone, tcx.mk_args(&[ty.into()]), vec![source], span, out); + let drops = self.b.t.drops(ty); + let old = self.swap_out(place, ty, clone, drops.then_some("old"), span, out); + if drops && let Some(drop) = self.b.t.drop_value(old, ty, span) { + out.push(StmtKind::Expr(drop).at(None)); + } + done(Expr::undefined(), false) + } + // `&raw mut *r`, of the place `r` names where it is an alias of one. + ("ptr", "from_mut") => { + let place = args[0].node.place()?; + let target = self.through_aliases(tcx.mk_place_deref(place)); + let raw = rustc_middle::mir::Rvalue::RawPtr(rustc_middle::mir::RawPtrKind::Mut, target); + done(self.rvalue(&raw, dest, span, out)?, false) + } + // A slice or an array of the one value, or a cell of it, read and written where the + // `&mut` points. + ("raw" | "array", "from_mut") | ("Cell", "from_mut") + if owner != "raw" || library::std_path(tcx, def_id) == ["slice", "raw", "from_mut"] => + { + let made = self.one_of(owner == "Cell", targ(0)?, &args[0].node, span, out)?; + done(made, true) + } // A range of numbers steps in place, with nothing between it and the loop. ("Iterator", "next") if super::small_range(tcx, targ(0)?) => { let range = self.alias_place(&args[0].node)?; @@ -1123,6 +1171,65 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { } } + /// `slice::from_mut`, `array::from_mut`, or with `cell`, `Cell::from_mut` of `op`, a + /// `&mut` to a `ty`: of the `rt.Place` it is or of the place it names, or else in place + /// of the bytes or the object it is, which a cell reads a copy of, as a `Cell` only + /// moves or copies a value out. A slice of an object no place names is refused, as a + /// whole write of its element would give the slice another object, not the place, as + /// is a cell of an object JS can't write a whole value into. + fn one_of( + &mut self, + cell: bool, + ty: Ty<'tcx>, + op: &Operand<'tcx>, + span: Span, + out: &mut Vec, + ) -> Option { + let tcx = self.tcx; + let place = op.place().filter(|p| p.projection.is_empty())?; + let deref = tcx.mk_place_deref(place); + let of = |made: Expr| match cell { + true => Expr::rt("cellOfPlace", vec![made]), + false => Expr::rt("sliceOfPlace", vec![made]), + }; + if !cell && matches!(ty.kind(), ty::Uint(ty::UintTy::U8)) { + return Some(self.err( + span, + "a slice of one byte's place, which a byte slice can view only in an array of bytes", + )); + } + if self.in_bytes(deref) { + let slice = self.place_expr(deref, span, out); + let view = Expr::rt("byteSliceView", vec![slice]); + return Some(match cell { + true => Expr::rt("cellIn", vec![view]), + false => of(Expr::rt("bytesPlace", vec![view])), + }); + } + if let Slot::Alias(Some(target)) = &self.slots[place.local] + && assignable(target) + && self.alias_of_place(place.local) + { + let target = target.clone(); + let target = self.stable_target(deref, target, span, out); + return Some(of(self.place_of(target, None))); + } + if self.b.t.needs_place(ty) { + let made = self.operand(op, span, out); + return Some(of(made)); + } + if cell && self.b.t.write_in(ty).is_some() { + let object = self.operand(op, span, out); + return Some(Expr::rt("cellIn", vec![object])); + } + Some(self.err( + span, + format!( + "a slice or a cell of a mutable reference to `{ty}` that names no place, which a whole write would replace only there" + ), + )) + } + /// The place the `&mut` receiver borrows, as the `&mut` the call returns: an alias of it /// where the destination is read only as one. fn same_place( diff --git a/ts/src/lower/mir/place.rs b/ts/src/lower/mir/place.rs index e36ed3a2c..4debb5135 100644 --- a/ts/src/lower/mir/place.rs +++ b/ts/src/lower/mir/place.rs @@ -2000,7 +2000,7 @@ impl<'tcx> Fx<'_, '_, '_, 'tcx> { } /// Whether `local` is read once, as the reference std makes a raw pointer of, or as - /// one `mem::replace`, `swap`, or `take` gives what it points at another value through. + /// one that [`rebinds`] says std may give what it points at another value through. fn read_by_std(&self, local: Local) -> bool { use crate::lower::pointer::{from_reference, rebinds}; self.uses[local] == 1 @@ -2014,8 +2014,9 @@ impl<'tcx> Fx<'_, '_, '_, 'tcx> { let given = args .iter() .position(|a| a.node.place().and_then(|p| p.as_local()) == Some(local)); - given - .is_some_and(|i| i == 0 && from_reference(self.tcx, def_id, gargs) || i < rebinds(self.tcx, def_id)) + given.is_some_and(|i| { + i == 0 && from_reference(self.tcx, def_id, gargs) || rebinds(self.tcx, def_id).contains(&i) + }) }) } @@ -2218,11 +2219,11 @@ impl<'tcx> Fx<'_, '_, '_, 'tcx> { { let rebound = func .const_fn_def() - .map_or(0, |(def_id, _)| crate::lower::pointer::rebinds(tcx, def_id)); + .map_or(&[][..], |(def_id, _)| crate::lower::pointer::rebinds(tcx, def_id)); if (assigns(*destination) - || args[..rebound] + || rebound .iter() - .filter_map(|a| a.node.place()) + .filter_map(|&i| args.get(i)?.node.place()) .any(|r| assigns(tcx.mk_place_deref(r)))) && read_after(self.mir.terminator_loc(bb)) { diff --git a/ts/src/lower/mod.rs b/ts/src/lower/mod.rs index 337667fc5..a04f1c783 100644 --- a/ts/src/lower/mod.rs +++ b/ts/src/lower/mod.rs @@ -1345,14 +1345,18 @@ impl<'a, 'tcx> Translator<'a, 'tcx> { /// The kind of a `pointee`'s object, through the `Pin`s and `Box`es JS erases, where a /// whole value of it can be written into the object in place: one only its owner /// holds, unlike an `Arc`'s, which its clones share, and whose parts `Object.assign` - /// copies, unlike a binding's, an `rt.PollFn`'s or a future's private fields, or a - /// trait object's, whatever class it is. + /// copies, unlike a binding's, the private fields of an `rt.PollFn`, an `rt.LazyCell`, + /// an `rt.LocalKey`, or a future, or a trait object's, whatever class it is. pub fn write_in(&self, pointee: Ty<'tcx>) -> Option { use library::Std; let erased = self.erased(pointee); let hidden = match erased.kind() { ty::Adt(adt, _) => { - self.bound_drops(adt.did()).is_some() || Std::of(self.tcx, adt.did()) == Some(Std::PollFn) + self.bound_drops(adt.did()).is_some() + || matches!( + Std::of(self.tcx, adt.did()), + Some(Std::PollFn | Std::LazyCell | Std::LazyLock | Std::LocalKey) + ) } ty::Dynamic(..) | ty::Closure(..) => true, // A `Uint8Array`'s length never changes, as a boxed slice's may. diff --git a/ts/src/lower/pointer.rs b/ts/src/lower/pointer.rs index 4020436c3..1a3c695d3 100644 --- a/ts/src/lower/pointer.rs +++ b/ts/src/lower/pointer.rs @@ -229,8 +229,8 @@ impl<'a, 'tcx> Translator<'a, 'tcx> { } /// Whether std's `def_id` with `args` makes a raw pointer to what its first argument, a -/// reference, points at: `UnsafeCell::get`, `MaybeUninit::as_ptr` and `as_mut_ptr`, and -/// `NonNull::from` and `into`. +/// reference, points at: `UnsafeCell::get`, `MaybeUninit::as_ptr` and `as_mut_ptr`, +/// `ptr::from_ref` and `from_mut`, and `NonNull::from` and `into`. pub fn from_reference<'tcx>( tcx: ty::TyCtxt<'tcx>, def_id: rustc_hir::def_id::DefId, @@ -240,7 +240,7 @@ pub fn from_reference<'tcx>( return false; }; match (owner.as_str(), name.as_str()) { - ("UnsafeCell", "get") | ("MaybeUninit", "as_ptr" | "as_mut_ptr") => true, + ("UnsafeCell", "get") | ("MaybeUninit", "as_ptr" | "as_mut_ptr") | ("ptr", "from_ref" | "from_mut") => true, ("From", "from") | ("Into", "into") => { let (to, from) = match owner.as_str() { "From" => (args.type_at(0), args.type_at(1)), @@ -314,17 +314,20 @@ pub fn allocates(tcx: ty::TyCtxt<'_>, def_id: rustc_hir::def_id::DefId) -> bool ) } -/// How many of std's `def_id`'s first arguments are `&mut`s whose lowering gives what -/// they borrow another value, rather than writing into it, where one is an alias of a -/// borrowed place: the place is assigned again. `mem::replace`'s value is no such one. -pub fn rebinds(tcx: ty::TyCtxt<'_>, def_id: rustc_hir::def_id::DefId) -> usize { +/// Which of std's `def_id`'s arguments are `&mut`s whose lowering may give what they +/// borrow another value, rather than writing into it, where one is an alias of a borrowed +/// place: the place is assigned again, as `mem::replace`, `clone_from`, and `clone_into` +/// assign it, and a whole write of what `slice::from_mut`, `array::from_mut`, or +/// `Cell::from_mut` makes does. `mem::replace`'s value is no such one. +pub fn rebinds(tcx: ty::TyCtxt<'_>, def_id: rustc_hir::def_id::DefId) -> &'static [usize] { match super::library::key(tcx, def_id) { - Some((owner, name)) if owner == "mem" => match name.as_str() { - "replace" | "take" => 1, - "swap" => 2, - _ => 0, + Some((owner, name)) => match (owner.as_str(), name.as_str()) { + ("mem", "replace" | "take") | ("Clone", "clone_from") | ("raw" | "array" | "Cell", "from_mut") => &[0], + ("ToOwned", "clone_into") => &[1], + ("mem", "swap") => &[0, 1], + _ => &[], }, - _ => 0, + _ => &[], } } @@ -436,6 +439,10 @@ pub fn call<'tcx>( span, "a raw pointer to a place of `()`, which has no address of its own", ), + ("ptr", "from_ref") if b.t.identity_pointee(pointee()) => b.err( + span, + "a raw pointer to a place of `()`, which has no address of its own", + ), ("From", "from") if pointer_self(b, call).is_some_and(|t| b.t.identity_pointee(t)) => b.err( span, "a raw pointer to a place of `()`, which has no address of its own", @@ -501,6 +508,12 @@ pub fn call<'tcx>( _ => arg(), } } + // As `NonNull::from` makes one, of a `[u8; N]` given as the view of its bytes. + ("ptr", "from_ref") => match kind(b, pointee()) { + Some(Pointee::Place) => Expr::Object(vec![(crate::ts::Key::Name("v".into()), arg())]), + Some(Pointee::Bytes) => to_pointer(arg()), + _ => arg(), + }, ("NonNull", "new") => { let p = b.spill(arg(), "pointer", out); Expr::Cond(